public final class Invocable extends java.lang.Object implements Parameterized, ResourceModelComponent
Class defines two kinds of java methods
: definition method
and
handling method
. Definition method is the java Method
that is defined
by the user to be
executed. This can be java Method
of the class but also method of the interface. If it is the
method of the interface (method handler class is the class
but method itself is from
the interface
) then the definition method is the method from the inherited class
. In other words, the
handling method is the concrete method but definition method can be its parent abstract definition. However, in most
cases these methods are the same.
ResourceMethod
,
ResourceMethodDispatcher
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.reflect.Method |
APPLY_INFLECTOR_METHOD
Method instance representing the
Inflector.apply(Object) method. |
private java.lang.reflect.Method |
definitionMethod |
private MethodHandler |
handler |
private java.lang.reflect.Method |
handlingMethod |
private java.util.List<Parameter> |
parameters |
private java.lang.Class<?> |
rawResponseType |
private java.lang.Class<?> |
rawRoutingResponseType |
private java.lang.reflect.Type |
responseType |
private java.lang.reflect.Type |
routingResponseType |
Modifier | Constructor and Description |
---|---|
private |
Invocable(MethodHandler handler,
java.lang.reflect.Method definitionMethod,
java.lang.reflect.Method handlingMethod,
boolean encodedParameters,
java.lang.reflect.Type routingResponseType) |
Modifier and Type | Method and Description |
---|---|
void |
accept(ResourceModelVisitor visitor)
A component should call the visitor back with an appropriate
visitor interface method to give it a chance to process.
|
static Invocable |
create(java.lang.Class<? extends Inflector> inflectorClass)
Create a new resource method invocable model backed by an inflector class.
|
static <T> Invocable |
create(Inflector<javax.ws.rs.core.Request,T> inflector)
Create a new resource method invocable model backed by an inflector instance.
|
static Invocable |
create(MethodHandler handler,
java.lang.reflect.Method handlingMethod)
Create a new resource method invocable model.
|
static Invocable |
create(MethodHandler handler,
java.lang.reflect.Method definitionMethod,
boolean encodedParameters)
Create a new resource method invocable model.
|
static Invocable |
create(MethodHandler handler,
java.lang.reflect.Method definitionMethod,
java.lang.reflect.Method handlingMethod,
boolean encodedParameters)
Create a new resource method invocable model.
|
static Invocable |
create(MethodHandler handler,
java.lang.reflect.Method definitionMethod,
java.lang.reflect.Method handlingMethod,
boolean encodedParameters,
java.lang.reflect.Type routingResponseType)
Create a new resource method invocable model.
|
java.util.List<? extends ResourceModelComponent> |
getComponents()
Should return all existing resource model sub-components.
|
java.lang.reflect.Method |
getDefinitionMethod()
Getter for the Java method that should be executed.
|
MethodHandler |
getHandler()
Get the model of the resource method handler that will be used to invoke
the
handling resource method on. |
java.lang.reflect.Method |
getHandlingMethod()
Getter for the Java method
|
java.util.List<Parameter> |
getParameters()
Provides access to all parameters associated with given Parameterized instance.
|
java.lang.Class<?> |
getRawResponseType()
Get the resource method raw response type.
|
java.lang.Class<?> |
getRawRoutingResponseType()
Get the response
Class of the handlingMethod that will be used during
the routing for the purpose
of selection of the resource method. |
java.lang.reflect.Type |
getResponseType()
Get the resource method generic response type information.
|
java.lang.reflect.Type |
getRoutingResponseType()
Get the response type of the
handlingMethod that will be used during
the routing for the purpose
of selection of the resource method. |
private static java.lang.reflect.Method |
initApplyMethod() |
boolean |
isInflector()
Check if the invocable represents an
inflector
processing method . |
boolean |
requiresEntity()
Provides information on presence of an entity parameter.
|
java.lang.String |
toString() |
static final java.lang.reflect.Method APPLY_INFLECTOR_METHOD
Inflector.apply(Object)
method.private final MethodHandler handler
private final java.lang.reflect.Method definitionMethod
private final java.lang.reflect.Method handlingMethod
private final java.util.List<Parameter> parameters
private final java.lang.Class<?> rawResponseType
private final java.lang.reflect.Type responseType
private final java.lang.reflect.Type routingResponseType
private final java.lang.Class<?> rawRoutingResponseType
private Invocable(MethodHandler handler, java.lang.reflect.Method definitionMethod, java.lang.reflect.Method handlingMethod, boolean encodedParameters, java.lang.reflect.Type routingResponseType)
private static java.lang.reflect.Method initApplyMethod()
public static <T> Invocable create(Inflector<javax.ws.rs.core.Request,T> inflector)
inflector
- inflector processing the request method.public static Invocable create(java.lang.Class<? extends Inflector> inflectorClass)
inflectorClass
- inflector syb-type processing the request method.public static Invocable create(MethodHandler handler, java.lang.reflect.Method handlingMethod)
handler
- resource method handler.handlingMethod
- handling Java method.public static Invocable create(MethodHandler handler, java.lang.reflect.Method definitionMethod, boolean encodedParameters)
handler
- resource method handler.definitionMethod
- method that is defined to be executed on the handler
.encodedParameters
- true
if the automatic parameter decoding
should be disabled, false otherwise.public static Invocable create(MethodHandler handler, java.lang.reflect.Method definitionMethod, java.lang.reflect.Method handlingMethod, boolean encodedParameters)
handler
- resource method handler.definitionMethod
- method that is defined to be executed on the handler
.handlingMethod
- specific and concrete method to be actually executed as a resource method. If null
then the definitionMethod
will be used.encodedParameters
- true
if the automatic parameter decoding
should be disabled, false otherwise.public static Invocable create(MethodHandler handler, java.lang.reflect.Method definitionMethod, java.lang.reflect.Method handlingMethod, boolean encodedParameters, java.lang.reflect.Type routingResponseType)
handler
- resource method handler.definitionMethod
- method that is defined to be executed on the handler
.handlingMethod
- specific and concrete method to be actually executed as a resource method. If null
then the definitionMethod
will be used.encodedParameters
- true
if the automatic parameter decoding
should be disabled, false otherwise.routingResponseType
- response type that will be used during the routing for purpose
of selection of the resource method to be executed. If this parameter is
non-null
then it will override the return type of the
the Java handling method
) for purposes of
resource method selection. This might be useful in cases when resource
method returns a type A
but thanks to registered providers
(eg. WriterInterceptor
) it will be always converted
to type B
. Then the method selecting algorithm would check presence of
MessageBodyWriter
for type A
(which will
never be actually needed) and might result in choosing undesired method.
If the parameter is null
then the default response type will be used.public MethodHandler getHandler()
handling resource method
on.public java.lang.reflect.Method getHandlingMethod()
public java.lang.reflect.Method getDefinitionMethod()
public java.lang.reflect.Type getResponseType()
The returned value provides the Type information that contains additional generic declaration information for generic Java class types.
public java.lang.Class<?> getRawResponseType()
The returned value provides information about the raw Java class.
public boolean isInflector()
inflector
processing method
.true
, if this invocable represents an inflector invocation,
false
otherwise.public boolean requiresEntity()
Parameterized
requiresEntity
in interface Parameterized
public java.util.List<Parameter> getParameters()
Parameterized
getParameters
in interface Parameterized
public void accept(ResourceModelVisitor visitor)
ResourceModelComponent
accept
in interface ResourceModelComponent
visitor
- resource model visitor.public java.util.List<? extends ResourceModelComponent> getComponents()
ResourceModelComponent
getComponents
in interface ResourceModelComponent
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.reflect.Type getRoutingResponseType()
handlingMethod
that will be used during
the routing for the purpose
of selection of the resource method. Returned value
is in most cases equal to the response type
.
If returned value is different then it overrides the response type for
purposes of resource method selection and will be used to look for available
message body writers
.public java.lang.Class<?> getRawRoutingResponseType()
Class
of the handlingMethod
that will be used during
the routing for the purpose
of selection of the resource method. Returned value
is in most cases equal to the response type
.
If returned value is different then it overrides the response type for
purposes of resource method selection and will be used to look for available
message body writers
.