Class MethodHandler
- java.lang.Object
-
- org.glassfish.jersey.server.model.MethodHandler
-
- All Implemented Interfaces:
ResourceModelComponent
public abstract class MethodHandler extends Object implements ResourceModelComponent
Resource method handler model.- Author:
- Marek Potociar
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMethodHandler()Create new instance of a resource method handler model.protectedMethodHandler(Collection<Parameter> parameters)Create new instance of a resource method handler model.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(ResourceModelVisitor visitor)A component should call the visitor back with an appropriate visitor interface method to give it a chance to process.static MethodHandlercreate(Class<?> handlerClass)Create a class-based method handler from a class.static MethodHandlercreate(Class<?> handlerClass, boolean keepConstructorParamsEncoded)Create a class-based method handler from a class.static MethodHandlercreate(Class<?> handlerClass, boolean keepConstructorParamsEncoded, Collection<Parameter> handlerParameters)Create a class-based method handler from a class.static MethodHandlercreate(Class<?> handlerClass, Collection<Parameter> handlerParameters)Create a class-based method handler from a class.static MethodHandlercreate(Object handlerInstance)Create a instance-based (singleton) method handler from a class.static MethodHandlercreate(Object handlerInstance, Class<?> handlerClass)Create a instance-based (singleton) method handler from a class.static MethodHandlercreate(Object handlerInstance, Class<?> handlerClass, Collection<Parameter> handlerParameters)Create a instance-based (singleton) method handler from a class.static MethodHandlercreate(Object handlerInstance, Collection<Parameter> handlerParameters)Create a instance-based (singleton) method handler from a class.List<? extends ResourceModelComponent>getComponents()Should return all existing resource model sub-components.List<HandlerConstructor>getConstructors()Get the resource method handler constructors.abstract Class<?>getHandlerClass()Get the resource method handler class.protected abstract ObjectgetHandlerInstance()Get the raw handler instance that is backing this method handler.abstract ObjectgetInstance(org.glassfish.jersey.internal.inject.InjectionManager injectionManager)Get the injected resource method handler instance.Collection<Parameter>getParameters()Get the parameters associated directly with the resource method handler, if any (e.g.abstract booleanisClassBased()Return whether the method handlercreates instancesbased onclasses.
-
-
-
Constructor Detail
-
MethodHandler
protected MethodHandler()
Create new instance of a resource method handler model.
-
MethodHandler
protected MethodHandler(Collection<Parameter> parameters)
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 Detail
-
create
public static MethodHandler create(Class<?> handlerClass)
Create a class-based method handler from a class.- Parameters:
handlerClass- method handler class.- Returns:
- new class-based method handler.
-
create
public static MethodHandler create(Class<?> handlerClass, boolean keepConstructorParamsEncoded)
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
public static MethodHandler create(Object handlerInstance)
Create a instance-based (singleton) method handler from a class.- Parameters:
handlerInstance- method handler instance (singleton).- Returns:
- new instance-based method handler.
-
create
public static MethodHandler create(Object handlerInstance, Class<?> handlerClass)
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
public static MethodHandler create(Class<?> handlerClass, Collection<Parameter> handlerParameters)
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
public static MethodHandler create(Object handlerInstance, Collection<Parameter> handlerParameters)
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
public abstract Class<?> getHandlerClass()
Get the resource method handler class.- Returns:
- resource method handler class.
-
getConstructors
public List<HandlerConstructor> 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 instancesbased onclasses.- Returns:
- True is instances returned by this method handler are created from
classesgiven toInjectionManager, false otherwise (for example when method handler was initialized from instance)
-
getParameters
public Collection<Parameter> 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
public List<? extends ResourceModelComponent> getComponents()
Description copied from interface:ResourceModelComponentShould return all existing resource model sub-components.- Specified by:
getComponentsin interfaceResourceModelComponent- Returns:
- list of all sub-components
-
accept
public void accept(ResourceModelVisitor visitor)
Description copied from interface:ResourceModelComponentA component should call the visitor back with an appropriate visitor interface method to give it a chance to process.- Specified by:
acceptin interfaceResourceModelComponent- Parameters:
visitor- resource model visitor.
-
getHandlerInstance
protected abstract Object getHandlerInstance()
Get the raw handler instance that is backing this method handler.- Returns:
- raw handler instance. May return
nullif the handler isclass-based.
-
-