JAX-RS compliant implementation on mobile devices

不打扰是莪最后的温柔 提交于 2019-12-25 01:36:11

问题


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?

来源:https://stackoverflow.com/questions/53075476/jax-rs-compliant-implementation-on-mobile-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!