Class MethodHandler
java.lang.Object
org.glassfish.jersey.server.model.MethodHandler
- All Implemented Interfaces:
ResourceModelComponent
Resource method handler model.
- Author:
- Marek Potociar
-
Constructor Summary
ModifierConstructorDescriptionprotected
Create new instance of a resource method handler model.protected
MethodHandler
(Collection<Parameter> parameters) Create new instance of a resource method handler model. -
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 MethodHandler
Create a class-based method handler from a class.static MethodHandler
Create a class-based method handler from a class.static MethodHandler
create
(Class<?> handlerClass, boolean keepConstructorParamsEncoded, Collection<Parameter> handlerParameters) Create a class-based method handler from a class.static MethodHandler
create
(Class<?> handlerClass, Collection<Parameter> handlerParameters) Create a class-based method handler from a class.static MethodHandler
Create a instance-based (singleton) method handler from a class.static MethodHandler
Create a instance-based (singleton) method handler from a class.static MethodHandler
create
(Object handlerInstance, Class<?> handlerClass, Collection<Parameter> handlerParameters) Create a instance-based (singleton) method handler from a class.static MethodHandler
create
(Object handlerInstance, Collection<Parameter> handlerParameters) Create a instance-based (singleton) method handler from a class.List<? extends ResourceModelComponent>
Should return all existing resource model sub-components.Get the resource method handler constructors.abstract Class<?>
Get the resource method handler class.protected abstract Object
Get the raw handler instance that is backing this method handler.abstract Object
getInstance
(org.glassfish.jersey.internal.inject.InjectionManager injectionManager) Get the injected resource method handler instance.Get the parameters associated directly with the resource method handler, if any (e.g.abstract boolean
Return whether the method handlercreates instances
based onclasses
.
-
Constructor Details
-
MethodHandler
protected MethodHandler()Create new instance of a resource method handler model. -
MethodHandler
Create new instance of a resource method handler model.- Parameters:
parameters
- handler parameters associated directly with the resource method handler (e.g. class-level property setters and fields). May benull
.- Since:
- 2.20
-
-
Method Details
-
create
Create a class-based method handler from a class.- Parameters:
handlerClass
- method handler class.- Returns:
- new class-based method handler.
-
create
Create a class-based method handler from a class.- Parameters:
handlerClass
- method handler class.keepConstructorParamsEncoded
- if set totrue
, any injected constructor parameters must be kept encoded and must not be automatically decoded.- Returns:
- new class-based method handler.
-
create
Create a instance-based (singleton) method handler from a class.- Parameters:
handlerInstance
- method handler instance (singleton).- Returns:
- new instance-based method handler.
-
create
Create a instance-based (singleton) method handler from a class.- Parameters:
handlerInstance
- method handler instance (singleton).handlerClass
- declared handler class.- Returns:
- new instance-based method handler.
-
create
Create a class-based method handler from a class.- Parameters:
handlerClass
- method handler class.handlerParameters
- method handler parameters (e.g. class-level property setters and fields).- Returns:
- new class-based method handler.
-
create
public static MethodHandler create(Class<?> handlerClass, boolean keepConstructorParamsEncoded, Collection<Parameter> handlerParameters) Create a class-based method handler from a class.- Parameters:
handlerClass
- method handler class.keepConstructorParamsEncoded
- if set totrue
, any injected constructor parameters must be kept encoded and must not be automatically decoded.handlerParameters
- method handler parameters (e.g. class-level property setters and fields).- Returns:
- new class-based method handler.
- Since:
- 2.20
-
create
Create a instance-based (singleton) method handler from a class.- Parameters:
handlerInstance
- method handler instance (singleton).handlerParameters
- method handler parameters (e.g. class-level property setters and fields).- Returns:
- new instance-based method handler.
- Since:
- 2.20
-
create
public static MethodHandler create(Object handlerInstance, Class<?> handlerClass, Collection<Parameter> handlerParameters) Create a instance-based (singleton) method handler from a class.- Parameters:
handlerInstance
- method handler instance (singleton).handlerClass
- declared handler class.handlerParameters
- method handler parameters (e.g. class-level property setters and fields).- Returns:
- new instance-based method handler.
- Since:
- 2.20
-
getHandlerClass
Get the resource method handler class.- Returns:
- resource method handler class.
-
getConstructors
Get the resource method handler constructors. The returned is empty by default. Concrete implementations may override the method to return the actual list of constructors that will be used for the handler initialization.- Returns:
- resource method handler constructors.
-
getInstance
public abstract Object getInstance(org.glassfish.jersey.internal.inject.InjectionManager injectionManager) Get the injected resource method handler instance.- Parameters:
injectionManager
- injection manager that can be used to inject get the instance.- Returns:
- injected resource method handler instance.
-
isClassBased
public abstract boolean isClassBased()Return whether the method handlercreates instances
based onclasses
.- Returns:
- True is instances returned by this method handler are created from
classes
given toInjectionManager
, false otherwise (for example when method handler was initialized from instance)
-
getParameters
Get the parameters associated directly with the resource method handler, if any (e.g. class-level property setters and fields).Note that this method does not return any parameters associated with
method handler constructors
.- Returns:
- parameters associated with the resource method handler. May return an empty collection
but does not return
null
. - Since:
- 2.20
-
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
-
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.
-
getHandlerInstance
Get the raw handler instance that is backing this method handler.- Returns:
- raw handler instance. May return
null
if the handler isclass-based
.
-