abstract class AbstractJavaResourceMethodDispatcher extends java.lang.Object implements ResourceMethodDispatcher
Java method
using supplied
Java method invocation handler
.ResourceMethodDispatcher.Provider
Modifier and Type | Field and Description |
---|---|
private java.lang.reflect.Method |
method |
private java.lang.reflect.InvocationHandler |
methodHandler |
private Invocable |
resourceMethod |
private ConfiguredValidator |
validator |
Constructor and Description |
---|
AbstractJavaResourceMethodDispatcher(Invocable resourceMethod,
java.lang.reflect.InvocationHandler methodHandler,
ConfiguredValidator validator)
Initialize common java resource method dispatcher structures.
|
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.core.Response |
dispatch(java.lang.Object resource,
ContainerRequest 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(java.lang.Object resource,
ContainerRequest request)
Dispatching functionality to be implemented by a concrete dispatcher
implementation sub-class.
|
(package private) java.lang.Object |
invoke(ContainerRequest containerRequest,
java.lang.Object resource,
java.lang.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 java.lang.RuntimeException |
mapTargetToRuntimeEx(java.lang.Throwable throwable) |
java.lang.String |
toString() |
private final java.lang.reflect.Method method
private final java.lang.reflect.InvocationHandler methodHandler
private final Invocable resourceMethod
private final ConfiguredValidator validator
AbstractJavaResourceMethodDispatcher(Invocable resourceMethod, java.lang.reflect.InvocationHandler methodHandler, ConfiguredValidator validator)
resourceMethod
- invocable resource class Java method.methodHandler
- method invocation handler.validator
- input/output parameter validator.public final javax.ws.rs.core.Response dispatch(java.lang.Object resource, ContainerRequest request) throws javax.ws.rs.ProcessingException
ResourceMethodDispatcher
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.dispatch
in interface ResourceMethodDispatcher
resource
- the resource class instance.request
- request to be dispatched.response
for the dispatched request.javax.ws.rs.ProcessingException
- (possibly mappable
)
container exception that will be handled by the Jersey server container.protected abstract javax.ws.rs.core.Response doDispatch(java.lang.Object resource, ContainerRequest request) throws javax.ws.rs.ProcessingException
resource
- resource class instance.request
- request to be dispatched.javax.ws.rs.ProcessingException
- in case of a processing error.ResourceMethodDispatcher.dispatch(Object, org.glassfish.jersey.server.ContainerRequest)
final java.lang.Object invoke(ContainerRequest containerRequest, java.lang.Object resource, java.lang.Object... args) throws javax.ws.rs.ProcessingException
containerRequest
- container request.resource
- resource class instance.args
- input argument values for the invoked Java method.javax.ws.rs.ProcessingException
- (possibly mappable
)
container exception in case the invocation failed.private static java.lang.RuntimeException mapTargetToRuntimeEx(java.lang.Throwable throwable)
public java.lang.String toString()
toString
in class java.lang.Object