org.glassfish.jersey.server.model
Class MethodHandler

java.lang.Object
  extended by 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 (marek.potociar at oracle.com)

Constructor Summary
MethodHandler()
           
 
Method Summary
 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 MethodHandler create(Class<?> handlerClass)
          Create a class-based method handler from a class.
static MethodHandler create(Class<?> handlerClass, boolean disableParamDecoding)
          Create a class-based method handler from a class.
static MethodHandler create(Object handlerInstance)
          Create a instance-based (singleton) method handler from a class.
static MethodHandler create(Object handlerInstance, Class<?> handlerClass)
          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  Object getHandlerInstance()
          Get the raw handler instance that is backing this method handler.
abstract  Object getInstance(ServiceLocator locator)
          Get the injected resource method handler instance.
abstract  boolean isClassBased()
          Return whether the method handler creates instances based on classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodHandler

public MethodHandler()
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 disableParamDecoding)
Create a class-based method handler from a class.

Parameters:
handlerClass - method handler class.
disableParamDecoding - if set to true, 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. This method

Parameters:
handlerInstance - method handler instance (singleton).
handlerClass - declared handler class.
Returns:
new instance-based method handler.

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(ServiceLocator locator)
Get the injected resource method handler instance.

Parameters:
locator - service locator that can be used to inject get the instance.
Returns:
injected resource method handler instance.

isClassBased

public abstract boolean isClassBased()
Return whether the method handler creates instances based on classes.

Returns:
True is instances returned bu this method handler are created from classes given to HK2, false\ otherwise (for example when method handler was initialized from instance)

getComponents

public List<? extends ResourceModelComponent> getComponents()
Description copied from interface: ResourceModelComponent
Should return all existing resource model sub-components.

Specified by:
getComponents in interface ResourceModelComponent
Returns:
list of all sub-components

accept

public void accept(ResourceModelVisitor visitor)
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 interface ResourceModelComponent
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 null if the handler is class-based.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.