public final class Invocable extends 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 | 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(Class<? extends Inflector> inflectorClass)
Create a new resource method invocable model backed by an inflector class.
|
static <T> Invocable |
create(Inflector<Request,T> inflector)
Create a new resource method invocable model backed by an inflector instance.
|
static Invocable |
create(MethodHandler handler,
Method handlingMethod)
Create a new resource method invocable model.
|
static Invocable |
create(MethodHandler handler,
Method definitionMethod,
boolean encodedParameters)
Create a new resource method invocable model.
|
static Invocable |
create(MethodHandler handler,
Method definitionMethod,
Method handlingMethod,
boolean encodedParameters)
Create a new resource method invocable model.
|
static Invocable |
create(MethodHandler handler,
Method definitionMethod,
Method handlingMethod,
boolean encodedParameters,
Type routingResponseType)
Create a new resource method invocable model.
|
List<? extends ResourceModelComponent> |
getComponents()
Should return all existing resource model sub-components.
|
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. |
Method |
getHandlingMethod()
Getter for the Java method
|
List<Parameter> |
getParameters()
Provides access to all parameters associated with given Parameterized instance.
|
Class<?> |
getRawResponseType()
Get the resource method raw response type.
|
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. |
Type |
getResponseType()
Get the resource method generic response type information.
|
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. |
boolean |
isInflector()
Check if the invocable represents an
inflector
processing method . |
boolean |
requiresEntity()
Provides information on presence of an entity parameter.
|
String |
toString() |
public static <T> Invocable create(Inflector<Request,T> inflector)
inflector
- inflector processing the request method.public static Invocable create(Class<? extends Inflector> inflectorClass)
inflectorClass
- inflector syb-type processing the request method.public static Invocable create(MethodHandler handler, Method handlingMethod)
handler
- resource method handler.handlingMethod
- handling Java method.public static Invocable create(MethodHandler handler, 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, Method definitionMethod, 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, Method definitionMethod, Method handlingMethod, boolean encodedParameters, 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 Method getHandlingMethod()
public Method getDefinitionMethod()
public Type getResponseType()
The returned value provides the Type information that contains additional generic declaration information for generic Java class types.
public 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 List<Parameter> getParameters()
Parameterized
getParameters
in interface Parameterized
public void accept(ResourceModelVisitor visitor)
ResourceModelComponent
accept
in interface ResourceModelComponent
visitor
- resource model visitor.public List<? extends ResourceModelComponent> getComponents()
ResourceModelComponent
getComponents
in interface ResourceModelComponent
public 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 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
.Copyright © 2007-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.