Package org.glassfish.jersey.client.proxy

This package defines a high-level (proxy-based) client API.

See:
          Description

Class Summary
WebResourceFactory Factory for client-side representation of a resource.
 

Package org.glassfish.jersey.client.proxy Description

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 c = ClientFactory.newClient();
 MyResourceIfc resource = WebResourceFactory.newWebResource(MyResourceIfc.class, c, "http://localhost:8080/");

 String responseFromGet = resource.get();
 MyBean responseFromPost = resource.postEcho(myBeanInstance);
 String responseFromGetById = resource.getById("abc");
 



Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.