org.apache.felix.ipojo
Class PrimitiveHandler

java.lang.Object
  extended by org.apache.felix.ipojo.Handler
      extended by org.apache.felix.ipojo.PrimitiveHandler
All Implemented Interfaces:
FieldInterceptor, MethodInterceptor
Direct Known Subclasses:
ArchitectureHandler, ConfigurationHandler, ControllerHandler, DependencyHandler, LifecycleCallbackHandler, ProvidedServiceHandler

public abstract class PrimitiveHandler
extends Handler
implements FieldInterceptor, MethodInterceptor

Abstract class to extends for primitive handler.

Author:
Felix Project Team

Field Summary
static java.lang.String HANDLER_TYPE
          "Primitive" Handler type (value).
 
Fields inherited from class org.apache.felix.ipojo.Handler
HANDLER_LEVEL_PROPERTY, HANDLER_NAME_PROPERTY, HANDLER_NAMESPACE_PROPERTY, HANDLER_TYPE_PROPERTY, m_instance, m_isValid
 
Constructor Summary
PrimitiveHandler()
           
 
Method Summary
protected  void attach(ComponentInstance manager)
          Attach the current handler to the given instance.
 ComponentFactory getFactory()
           
 Handler getHandler(java.lang.String name)
          Get a plugged handler of the same container.
 InstanceManager getInstanceManager()
           
 Logger getLogger()
          Get the logger to use in the handler.
 org.apache.felix.ipojo.metadata.Element[] getMetadata()
           
 PojoMetadata getPojoMetadata()
           
 void onCreation(java.lang.Object instance)
          This method is called when an instance of the component is created, but before someone can use it.
 void onEntry(java.lang.Object pojo, java.lang.reflect.Method method, java.lang.Object[] args)
          This method is called when the execution enter in a method.
 void onError(java.lang.Object pojo, java.lang.reflect.Method method, java.lang.Throwable throwable)
          This method is called when the execution throw an exception in the given method.
 void onExit(java.lang.Object pojo, java.lang.reflect.Method method, java.lang.Object returnedObj)
          This method is called when the execution exit a method (before a return or a throw).
 void onFinally(java.lang.Object pojo, java.lang.reflect.Method method)
          This method is called when the execution of a method will terminate : just before to throw an exception or before to return.
 java.lang.Object onGet(java.lang.Object pojo, java.lang.String fieldName, java.lang.Object value)
          This method is called when a GETFIELD operation is detected.
 void onSet(java.lang.Object pojo, java.lang.String fieldName, java.lang.Object value)
          This method is called when a PUTFIELD operation is detected.
 void setFactory(Factory factory)
          Set the factory attached to this handler object.
 
Methods inherited from class org.apache.felix.ipojo.Handler
configure, error, error, getDescription, getHandlerManager, getValidity, info, initializeComponentFactory, isValid, reconfigure, setValidity, start, stateChanged, stop, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLER_TYPE

public static final java.lang.String HANDLER_TYPE
"Primitive" Handler type (value).

See Also:
Constant Field Values
Constructor Detail

PrimitiveHandler

public PrimitiveHandler()
Method Detail

attach

protected final void attach(ComponentInstance manager)
Attach the current handler to the given instance.

Specified by:
attach in class Handler
Parameters:
manager - ! the instance on which the current handler will be attached.
See Also:
Handler.attach(org.apache.felix.ipojo.ComponentInstance)

setFactory

public final void setFactory(Factory factory)
Description copied from class: Handler
Set the factory attached to this handler object. This method must be override to depend on each component factory type.

Specified by:
setFactory in class Handler
Parameters:
factory - : the factory.

getLogger

public Logger getLogger()
Description copied from class: Handler
Get the logger to use in the handler. This method must be override to depend on each component factory type logging policy.

Specified by:
getLogger in class Handler
Returns:
the logger.

getInstanceManager

public InstanceManager getInstanceManager()

getFactory

public ComponentFactory getFactory()

getMetadata

public org.apache.felix.ipojo.metadata.Element[] getMetadata()

getPojoMetadata

public PojoMetadata getPojoMetadata()

getHandler

public final Handler getHandler(java.lang.String name)
Get a plugged handler of the same container. This method must be call only in the start method (or after). In the configure method, this method can not return a consistent result as all handlers are not plugged.

Specified by:
getHandler in class Handler
Parameters:
name - : name of the handler to find (class name or qualified handler name (ns:name)).
Returns:
the handler object or null if the handler is not found.

onSet

public void onSet(java.lang.Object pojo,
                  java.lang.String fieldName,
                  java.lang.Object value)
This method is called when a PUTFIELD operation is detected.

Specified by:
onSet in interface FieldInterceptor
Parameters:
pojo - : the pojo object setting the value
fieldName - : the field name
value - : the value passed to the field

onGet

public java.lang.Object onGet(java.lang.Object pojo,
                              java.lang.String fieldName,
                              java.lang.Object value)
This method is called when a GETFIELD operation is detected.

Specified by:
onGet in interface FieldInterceptor
Parameters:
pojo - : the pojo object getting the value
fieldName - : the field name
value - : the value passed to the field (by the previous call)
Returns:
: the managed value of the field

onEntry

public void onEntry(java.lang.Object pojo,
                    java.lang.reflect.Method method,
                    java.lang.Object[] args)
This method is called when the execution enter in a method.

Specified by:
onEntry in interface MethodInterceptor
Parameters:
pojo - : pojo on which the method is called.
method - : method invoked.
args - arguments array.

onExit

public void onExit(java.lang.Object pojo,
                   java.lang.reflect.Method method,
                   java.lang.Object returnedObj)
This method is called when the execution exit a method (before a return or a throw). If the given returned object is null, either the method is void, either it returns null. You must not modified the returned object.

Specified by:
onExit in interface MethodInterceptor
Parameters:
pojo - : the pojo on which the method exits.
method - : exiting method.
returnedObj - : the returned object (boxed for primitive type)

onError

public void onError(java.lang.Object pojo,
                    java.lang.reflect.Method method,
                    java.lang.Throwable throwable)
This method is called when the execution throw an exception in the given method.

Specified by:
onError in interface MethodInterceptor
Parameters:
pojo - : the pojo on which the method was accessed.
method - : invoked method.
throwable - : the thrown exception

onFinally

public void onFinally(java.lang.Object pojo,
                      java.lang.reflect.Method method)
This method is called when the execution of a method will terminate : just before to throw an exception or before to return. OnError or OnExit was already called.

Specified by:
onFinally in interface MethodInterceptor
Parameters:
pojo - : the pojo on which the method was accessed.
method - : invoked method.

onCreation

public void onCreation(java.lang.Object instance)
This method is called when an instance of the component is created, but before someone can use it.

Parameters:
instance - : the created instance