Class AbstractJavaResourceMethodDispatcher
java.lang.Object
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher
- All Implemented Interfaces:
ResourceMethodDispatcher
- Direct Known Subclasses:
JavaResourceMethodDispatcherProvider.AbstractMethodParamInvoker
,VoidVoidDispatcherProvider.VoidToVoidDispatcher
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
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher
ResourceMethodDispatcher.Provider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Method
private final InvocationHandler
private final Invocable
private final ConfiguredValidator
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractJavaResourceMethodDispatcher
(Invocable resourceMethod, InvocationHandler methodHandler, ConfiguredValidator validator) Initialize common java resource method dispatcher structures. -
Method Summary
Modifier and TypeMethodDescriptionfinal javax.ws.rs.core.Response
dispatch
(Object resource, ContainerRequest request) Reflectively dispatch a request to the underlyinginvocable resource method
via the configuredinvocation handler
using the provided resource class instance.protected abstract javax.ws.rs.core.Response
doDispatch
(Object resource, ContainerRequest request) Dispatching functionality to be implemented by a concrete dispatcher implementation sub-class.(package private) final Object
invoke
(ContainerRequest containerRequest, 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.private static RuntimeException
mapTargetToRuntimeEx
(Throwable throwable) toString()
-
Field Details
-
method
-
methodHandler
-
resourceMethod
-
validator
-
-
Constructor Details
-
AbstractJavaResourceMethodDispatcher
AbstractJavaResourceMethodDispatcher(Invocable resourceMethod, InvocationHandler methodHandler, ConfiguredValidator validator) Initialize common java resource method dispatcher structures.- Parameters:
resourceMethod
- invocable resource class Java method.methodHandler
- method invocation handler.validator
- input/output parameter validator.
-
-
Method Details
-
dispatch
public final javax.ws.rs.core.Response dispatch(Object resource, ContainerRequest request) throws javax.ws.rs.ProcessingException Description copied from interface:ResourceMethodDispatcher
Reflectively dispatch a request to the underlyinginvocable resource method
via the configuredinvocation 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-RSresponse
instance. When the method is invoked, the dispatcher will extract theJava 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-RSResponse
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 interfaceResourceMethodDispatcher
- Parameters:
resource
- the resource class instance.request
- request to be dispatched.- Returns:
response
for the dispatched request.- Throws:
javax.ws.rs.ProcessingException
- (possiblymappable
) container exception that will be handled by the Jersey server container.
-
doDispatch
protected abstract javax.ws.rs.core.Response doDispatch(Object resource, ContainerRequest request) throws javax.ws.rs.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:
javax.ws.rs.ProcessingException
- in case of a processing error.- See Also:
-
invoke
final Object invoke(ContainerRequest containerRequest, Object resource, Object... args) throws javax.ws.rs.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:
containerRequest
- container request.resource
- resource class instance.args
- input argument values for the invoked Java method.- Returns:
- invocation result.
- Throws:
javax.ws.rs.ProcessingException
- (possiblymappable
) container exception in case the invocation failed.
-
mapTargetToRuntimeEx
-
toString
-