public abstract class PrimitiveHandler extends Handler implements FieldInterceptor, MethodInterceptor, ConstructorInjector
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HANDLER_TYPE
The "Primitive" Handler type (value).
|
HANDLER_LEVEL_PROPERTY, HANDLER_NAME_PROPERTY, HANDLER_NAMESPACE_PROPERTY, HANDLER_TYPE_PROPERTY, m_instance, m_isValid
Constructor and Description |
---|
PrimitiveHandler() |
Modifier and Type | Method and Description |
---|---|
protected void |
attach(ComponentInstance manager)
Attaches the current handler to the given instance.
|
java.lang.Object |
getConstructorParameter(int index)
Gets the object to inject as a constructor parameter
|
java.lang.Class |
getConstructorParameterType(int index)
Gets the type of the object to inject in the constructor parameter.
|
ComponentFactory |
getFactory()
Gets the factory which creates the managed instance.
|
Handler |
getHandler(java.lang.String name)
Gets a plugged handler of the same container.
|
InstanceManager |
getInstanceManager()
Gets the instance manager managing the instance.
|
Logger |
getLogger()
Gets the logger of the managed instance.
|
PojoMetadata |
getPojoMetadata()
Gets the PojoMetadata of the content of the managed
instance.
|
void |
onCreation(java.lang.Object instance)
Callback method called when an instance of the component is created, but
before someone can use it.
|
void |
onEntry(java.lang.Object pojo,
java.lang.reflect.Member method,
java.lang.Object[] args)
Callback method called when a method will be invoked.
|
void |
onError(java.lang.Object pojo,
java.lang.reflect.Member method,
java.lang.Throwable throwable)
Callback method called when an error occurs.
|
void |
onExit(java.lang.Object pojo,
java.lang.reflect.Member method,
java.lang.Object returnedObj)
Callback method called when a method ends.
|
void |
onFinally(java.lang.Object pojo,
java.lang.reflect.Member method)
Callback method 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)
Callback method called when a managed field
asks for a value.
|
void |
onSet(java.lang.Object pojo,
java.lang.String fieldName,
java.lang.Object value)
Callback method called when a managed field
receives a new value.
|
void |
setFactory(Factory factory)
Sets the factory of the managed instance.
|
configure, debug, error, error, getDescription, getHandlerManager, getValidity, info, initializeComponentFactory, isValid, reconfigure, setValidity, start, stateChanged, stop, warn, warn
public static final java.lang.String HANDLER_TYPE
protected void attach(ComponentInstance manager)
attach
in class Handler
manager
- the instance on which the current handler will be attached.Handler.attach(org.apache.felix.ipojo.ComponentInstance)
public final void setFactory(Factory factory)
setFactory
in class Handler
factory
- the factoryHandler.setFactory(org.apache.felix.ipojo.Factory)
public Logger getLogger()
getLogger
in class Handler
Handler.getLogger()
public InstanceManager getInstanceManager()
public ComponentFactory getFactory()
public PojoMetadata getPojoMetadata()
public final Handler getHandler(java.lang.String name)
getHandler
in class Handler
name
- the name of the handler to find (class name or qualified
handler name (ns:name
)).null
if the handler is not found.public void onSet(java.lang.Object pojo, java.lang.String fieldName, java.lang.Object value)
onSet
in interface FieldInterceptor
pojo
- the pojo object setting the valuefieldName
- the field namevalue
- the value received by the fieldFieldInterceptor.onSet(Object, String, Object)
public java.lang.Object onGet(java.lang.Object pojo, java.lang.String fieldName, java.lang.Object value)
onGet
in interface FieldInterceptor
pojo
- the pojo object requiring the valuefieldName
- the field namevalue
- the value passed to the field (by the previous call)FieldInterceptor.onGet(Object, String, Object)
public java.lang.Object getConstructorParameter(int index)
getConstructorParameter
in interface ConstructorInjector
index
- the index of the parameternull
if no
objects are injected. This implementation returns null
ConstructorInjector.getConstructorParameter(int)
public java.lang.Class getConstructorParameterType(int index)
null
will try to get the class from the
injected object, however this can be wrong (implementation instead of interface,
boxed objects...) and error-prone.getConstructorParameterType
in interface ConstructorInjector
index
- the parameter indexnull
ConstructorInjector.getConstructorParameterType(int)
public void onEntry(java.lang.Object pojo, java.lang.reflect.Member method, java.lang.Object[] args)
onEntry
in interface MethodInterceptor
pojo
- the pojo on which the method is called.method
- the method invoked.args
- the arguments array.MethodInterceptor.onEntry(Object, java.lang.reflect.Member, Object[])
public void onExit(java.lang.Object pojo, java.lang.reflect.Member method, java.lang.Object returnedObj)
null
, either the method is
void
, or it returns null
.
You must not modified the returned object.
The default implementation does nothing.onExit
in interface MethodInterceptor
pojo
- the pojo on which the method exits.method
- the exiting method.returnedObj
- the returned object (boxed for primitive type)MethodInterceptor.onExit(Object, java.lang.reflect.Member, Object)
public void onError(java.lang.Object pojo, java.lang.reflect.Member method, java.lang.Throwable throwable)
onError
in interface MethodInterceptor
pojo
- the pojo on which the method was accessed.method
- the invoked method.throwable
- the thrown exceptionMethodInterceptor.onError(Object, java.lang.reflect.Member, Throwable)
public void onFinally(java.lang.Object pojo, java.lang.reflect.Member method)
MethodInterceptor.onExit(Object, java.lang.reflect.Member, Object)
and
MethodInterceptor.onError(Object, java.lang.reflect.Member, Throwable)
This default implementation does nothing.onFinally
in interface MethodInterceptor
pojo
- the pojo on which the method was accessed.method
- the invoked method.public void onCreation(java.lang.Object instance)
instance
- the created instanceCopyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.