org.glassfish.jersey.client.proxy
Class WebResourceFactory

java.lang.Object
  extended by org.glassfish.jersey.client.proxy.WebResourceFactory
All Implemented Interfaces:
InvocationHandler

public final class WebResourceFactory
extends Object
implements InvocationHandler

Factory for client-side representation of a resource. See the package overview for an example on how to use this class.

Author:
Martin Matula (martin.matula at oracle.com)

Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
           
static
<C> C
newResource(Class<C> resourceInterface, WebTarget target)
          Creates a new client-side representation of a resource described by the interface passed in the first argument.
static
<C> C
newResource(Class<C> resourceInterface, WebTarget target, boolean ignoreResourcePath, MultivaluedMap<String,Object> headers, List<Cookie> cookies, Form form)
          Creates a new client-side representation of a resource described by the interface passed in the first argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newResource

public static <C> C newResource(Class<C> resourceInterface,
                                WebTarget target)
Creates a new client-side representation of a resource described by the interface passed in the first argument. Calling this method has the same effect as calling WebResourceFactory.newResource(resourceInterface, rootTarget, false).

Type Parameters:
C - Type of the resource to be created.
Parameters:
resourceInterface - Interface describing the resource to be created.
target - WebTarget pointing to the resource or the parent of the resource.
Returns:
Instance of a class implementing the resource interface that can be used for making requests to the server.

newResource

public static <C> C newResource(Class<C> resourceInterface,
                                WebTarget target,
                                boolean ignoreResourcePath,
                                MultivaluedMap<String,Object> headers,
                                List<Cookie> cookies,
                                Form form)
Creates a new client-side representation of a resource described by the interface passed in the first argument.

Type Parameters:
C - Type of the resource to be created.
Parameters:
resourceInterface - Interface describing the resource to be created.
target - WebTarget pointing to the resource or the parent of the resource.
ignoreResourcePath - If set to true, ignores path annotation on the resource interface (this is used when creating sub-resources)
headers - Header params collected from parent resources (used when creating a sub-resource)
cookies - Cookie params collected from parent resources (used when creating a sub-resource)
form - Form params collected from parent resources (used when creating a sub-resource)
Returns:
Instance of a class implementing the resource interface that can be used for making requests to the server.

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable


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