Class Invocable
- All Implemented Interfaces:
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.
- Author:
- Marek Potociar
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 a new resource method invocable model backed by an inflector class.static <T> Invocable
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>
Should return all existing resource model sub-components.Getter for the Java method that should be executed.Get the model of the resource method handler that will be used to invoke thehandling resource method
on.Getter for the Java methodProvides access to all parameters associated with given Parameterized instance.Class<?>
Get the resource method raw response type.Class<?>
Get the responseClass
of thehandlingMethod
that will be used during the routing for the purpose of selection of the resource method.Get the resource method generic response type information.Get the response type of thehandlingMethod
that will be used during the routing for the purpose of selection of the resource method.boolean
Check if the invocable represents aninflector processing method
.boolean
Provides information on presence of an entity parameter.toString()
-
Method Details
-
create
Create a new resource method invocable model backed by an inflector instance.- Parameters:
inflector
- inflector processing the request method.- Returns:
- Invocable.
-
create
Create a new resource method invocable model backed by an inflector class.- Parameters:
inflectorClass
- inflector syb-type processing the request method.- Returns:
- Invocable.
-
create
Create a new resource method invocable model. Parameter values will be automatically decoded.- Parameters:
handler
- resource method handler.handlingMethod
- handling Java method.- Returns:
- Invocable.
-
create
public static Invocable create(MethodHandler handler, Method definitionMethod, boolean encodedParameters) Create a new resource method invocable model.- Parameters:
handler
- resource method handler.definitionMethod
- method that is defined to be executed on thehandler
.encodedParameters
-true
if the automatic parameter decoding should be disabled, false otherwise.- Returns:
- Invocable
-
create
public static Invocable create(MethodHandler handler, Method definitionMethod, Method handlingMethod, boolean encodedParameters) Create a new resource method invocable model.- Parameters:
handler
- resource method handler.definitionMethod
- method that is defined to be executed on thehandler
.handlingMethod
- specific and concrete method to be actually executed as a resource method. Ifnull
then thedefinitionMethod
will be used.encodedParameters
-true
if the automatic parameter decoding should be disabled, false otherwise.- Returns:
- Invocable.
-
create
public static Invocable create(MethodHandler handler, Method definitionMethod, Method handlingMethod, boolean encodedParameters, Type routingResponseType) Create a new resource method invocable model.- Parameters:
handler
- resource method handler.definitionMethod
- method that is defined to be executed on thehandler
.handlingMethod
- specific and concrete method to be actually executed as a resource method. Ifnull
then thedefinitionMethod
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 thethe Java handling method
) for purposes of resource method selection. This might be useful in cases when resource method returns a typeA
but thanks to registered providers (eg.WriterInterceptor
) it will be always converted to typeB
. Then the method selecting algorithm would check presence ofMessageBodyWriter
for typeA
(which will never be actually needed) and might result in choosing undesired method. If the parameter isnull
then the default response type will be used.- Returns:
- Invocable.
-
getHandler
Get the model of the resource method handler that will be used to invoke thehandling resource method
on.- Returns:
- resource method handler model.
-
getHandlingMethod
Getter for the Java method- Returns:
- corresponding Java method
-
getDefinitionMethod
Getter for the Java method that should be executed.- Returns:
- corresponding Java method.
-
getResponseType
Get the resource method generic response type information.The returned value provides the Type information that contains additional generic declaration information for generic Java class types.
- Returns:
- resource method generic response type information.
-
getRawResponseType
Get the resource method raw response type.The returned value provides information about the raw Java class.
- Returns:
- resource method raw response type information.
-
isInflector
public boolean isInflector()Check if the invocable represents aninflector processing method
.- Returns:
true
, if this invocable represents an inflector invocation,false
otherwise.
-
requiresEntity
public boolean requiresEntity()Description copied from interface:Parameterized
Provides information on presence of an entity parameter.- Specified by:
requiresEntity
in interfaceParameterized
- Returns:
- true if entity parameter is present, false otherwise
-
getParameters
Description copied from interface:Parameterized
Provides access to all parameters associated with given Parameterized instance.- Specified by:
getParameters
in interfaceParameterized
- Returns:
- list of actual parameters
-
accept
Description copied from interface:ResourceModelComponent
A component should call the visitor back with an appropriate visitor interface method to give it a chance to process.- Specified by:
accept
in interfaceResourceModelComponent
- Parameters:
visitor
- resource model visitor.
-
getComponents
Description copied from interface:ResourceModelComponent
Should return all existing resource model sub-components.- Specified by:
getComponents
in interfaceResourceModelComponent
- Returns:
- list of all sub-components
-
toString
-
getRoutingResponseType
Get the response type of thehandlingMethod
that will be used during the routing for the purpose of selection of the resource method. Returned value is in most cases equal to theresponse 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 availablemessage body writers
.- Returns:
- Response type used for the routing.
-
getRawRoutingResponseType
Get the responseClass
of thehandlingMethod
that will be used during the routing for the purpose of selection of the resource method. Returned value is in most cases equal to theresponse 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 availablemessage body writers
.- Returns:
- Response type used for the routing.
-