Does anyone know a client proxy implementation in Jersey, for example, Apache CXF offers for REST

The Apache CXF project offers a proxy-based client implementation for REST services. It looks like this:

Resource resource = JAXRSClientFactory.create( baseAddress, Resource.class ) 

Does anyone know a similar implementation for jersey?

I noticed an approach using @HyperMediaController annotations, but I want to stick with the default JSR-311 annotations like @Path and @Get ...

Does anyone have an idea?

+4
source share
3 answers

I created my own implementation. See the utils-apl-wiki page .

0
source

There is a proxy server implementation, but, unfortunately, it is not even mentioned in the Jersey API client documentation (nor in the Jersey User Guide ) since version 2.22.1.

I found a JavaDoc for WebResourceFactory , an even better JavaDoc package . Here is a snippet from a JavaDoc on using WebResourceFactory:

 Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8080/"); MyResourceIfc resource = WebResourceFactory.newResource(MyResourceIfc.class, target); 

In Maven you then need to:

  <dependency> <groupId>org.glassfish.jersey.ext</groupId> <artifactId>jersey-proxy-client</artifactId> <version>2.22.1</version> </dependency> 

in addition to

  <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> <version>2.22.1</version> </dependency> 
+3
source

I found that supports for the common WebResourceFactory roles are supported, and the source code is really hard to understand. Thus, we have created https://github.com/adaptris/jaxrs-client-proxy , and we are currently disclosing it.

To use it, you need to create a resource:

 ResourceBuilder builder = new ResourceBuilder(); resource = builder. url("https://host/api"). build(Resource.class); client = resource.get(); 

Then you can call client - which is the proxy server of the described jax-rs interface, indicated by the annotation ( Resource.class ). You must close the resource after stopping its use, as recommended by the jax-rs api client.

 resource.close() 

Learn more about the github projet page.

-1
source

All Articles