Package org.glassfish.jersey.client.proxy
This package defines a high-level (proxy-based) client API.
The API enables utilization of the server-side JAX-RS annotations
to describe the server-side resources and dynamically generate client-side
proxy objects for them.
Consider a server which exposes a resource at http://localhost:8080. The resource can be described by the following interface:
@Path("myresource") public interface MyResourceIfc { @GET @Produces("text/plain") String get(); @POST @Consumes("application/xml") @Produces("application/xml") MyBean postEcho(MyBean bean); @Path("{id}") @GET @Produces("text/plain") String getById(@PathParam("id") String id); }
You can use WebResourceFactory class defined in this package to access the server-side resource using this interface. Here is an example:
Client client = ClientBuilder.newClient(); WebTarget target = client.target("http://localhost:8080/"); MyResourceIfc resource = WebResourceFactory.newResource(MyResourceIfc.class, target); String responseFromGet = resource.get(); MyBean responseFromPost = resource.postEcho(myBeanInstance); String responseFromGetById = resource.getById("abc");
-
Class Summary Class Description WebResourceFactory Factory for client-side representation of a resource.