org.glassfish.jersey.server.model
Class AbstractJavaResourceMethodDispatcher

java.lang.Object
  extended by org.glassfish.jersey.server.model.AbstractJavaResourceMethodDispatcher
All Implemented Interfaces:
ResourceMethodDispatcher

public abstract class AbstractJavaResourceMethodDispatcher
extends Object
implements ResourceMethodDispatcher

Abstract resource method dispatcher that provides skeleton implementation of dispatching requests to a particular Java method using supplied Java method invocation handler.

Author:
Marek Potociar (marek.potociar at oracle.com)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher
ResourceMethodDispatcher.Provider
 
Constructor Summary
protected AbstractJavaResourceMethodDispatcher(InvocableResourceMethod resourceMethod, InvocationHandler methodHandler)
          Initialize common java resource method dispatcher structures.
 
Method Summary
 javax.ws.rs.core.Response dispatch(Object resource, javax.ws.rs.core.Request request)
          Reflectively dispatch a request to the underlying invocable resource method via the configured invocation handler using the provided resource class instance.
protected abstract  javax.ws.rs.core.Response doDispatch(Object resource, javax.ws.rs.core.Request request)
          Dispatching functionality to be implemented by a concrete dispatcher implementation sub-class.
protected  Object invoke(Object resource, Object... args)
          Use the underlying invocation handler to invoke the underlying Java method with the supplied input method argument values on a given resource instance.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractJavaResourceMethodDispatcher

protected AbstractJavaResourceMethodDispatcher(InvocableResourceMethod resourceMethod,
                                               InvocationHandler methodHandler)
Initialize common java resource method dispatcher structures.

Parameters:
resourceMethod - invocable resource class Java method.
methodHandler - method invocation handler.
Method Detail

dispatch

public final javax.ws.rs.core.Response dispatch(Object resource,
                                                javax.ws.rs.core.Request request)
                                         throws ProcessingException
Description copied from interface: ResourceMethodDispatcher
Reflectively dispatch a request to the underlying invocable resource method via the configured invocation handler using the provided resource class instance.

In summary, the main job of the dispatcher is to convert a request into an array of the Java method input parameters and subsequently convert the returned response of an arbitrary Java type to a JAX-RS response instance.

When the method is invoked, the dispatcher will extract the Java method information from the invocable resource method and use the information to retrieve the required input parameters from either the request instance or any other available run-time information. Once the set of input parameter values is computed, the underlying invocation handler instance is invoked to process (invoke) the Java resource method with the computed input parameter values. The returned response is subsequently converted into a JAX-RS Response type and returned from the dispatcher.

It is assumed that the supplied resource implements the invocable method. Dispatcher implementation should not need to do any additional checks in that respect.

Specified by:
dispatch in interface ResourceMethodDispatcher
Parameters:
resource - the resource class instance.
request - request to be dispatched.
Returns:
response for the dispatched request.
Throws:
ProcessingException - (possibly mappable) container exception that will be handled by the Jersey server container.

doDispatch

protected abstract javax.ws.rs.core.Response doDispatch(Object resource,
                                                        javax.ws.rs.core.Request request)
                                                 throws ProcessingException
Dispatching functionality to be implemented by a concrete dispatcher implementation sub-class.

Parameters:
resource - resource class instance.
request - request to be dispatched.
Returns:
response for the dispatched request.
Throws:
ProcessingException
See Also:
ResourceMethodDispatcher.dispatch(java.lang.Object, javax.ws.rs.core.Request)

invoke

protected final Object invoke(Object resource,
                              Object... args)
                       throws ProcessingException
Use the underlying invocation handler to invoke the underlying Java method with the supplied input method argument values on a given resource instance.

Parameters:
resource - resource class instance.
args - input argument values for the invoked Java method.
Returns:
invocation result.
Throws:
ProcessingException - (possibly mappable) container exception in case the invocation failed.

toString

public String toString()
Overrides:
toString in class Object


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