JAX-RS compliant implementation on mobile devices

2019-08-25 18:12发布

I'm writing an application that should run on both desktop and mobile and it needs to communicate with a server using REST. I'm Using Gluon Mobile.

The code I write on the client side is jax-rs-compliant and looks like this:

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;

Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target("http://www...").path("/login/...");
Future<Response> future = target.request().async().get();
Response response = future.get();

and I specify a dependency on an implementation like RESTEASY or Jersey clients.

Gluon Connect has REST implementation but it is not JAX-RS compliant:

RestClient restClient = RestClient.create()
        .method("GET")
        .host("https://...")
        .path("/login/...")
...

It means that my client needs 2 code versions. I would like write once run anywhere like I get with the rest of my code. Is it possible? Is there a JAX-RS implementation I can use on android and ios? I need to tell gradle to use one implementation when building desktop and others for android and ios right?

0条回答
登录 后发表回答