|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.felix.ipojo.Handler
org.apache.felix.ipojo.PrimitiveHandler
public abstract class PrimitiveHandler
This class defines common mechanisms of primitive handlers. Primitive handlers are handler composing the container of primitive component instances (declared by the 'component' element inside the iPOJO descriptor). Note that this class also defines default method implementation. Classes overriding this class can change the behavior of those methods.
Field Summary | |
---|---|
static String |
HANDLER_TYPE
The "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)
Attaches the current handler to the given instance. |
Object |
getConstructorParameter(int index)
Gets the object to inject as a constructor parameter |
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(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(Object instance)
Callback method called when an instance of the component is created, but before someone can use it. |
void |
onEntry(Object pojo,
Method method,
Object[] args)
Callback method called when a method will be invoked. |
void |
onError(Object pojo,
Method method,
Throwable throwable)
Callback method called when an error occurs. |
void |
onExit(Object pojo,
Method method,
Object returnedObj)
Callback method called when a method ends. |
void |
onFinally(Object pojo,
Method method)
Callback method called when the execution of a method will terminate : just before to throw an exception or before to return. |
Object |
onGet(Object pojo,
String fieldName,
Object value)
Callback method called when a managed field asks for a value. |
void |
onSet(Object pojo,
String fieldName,
Object value)
Callback method called when a managed field receives a new value. |
void |
setFactory(Factory factory)
Sets the factory of the managed instance. |
Methods inherited from class org.apache.felix.ipojo.Handler |
---|
configure, debug, 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 |
---|
public static final String HANDLER_TYPE
Constructor Detail |
---|
public PrimitiveHandler()
Method Detail |
---|
protected final 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(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(Object pojo, String fieldName, 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 Object onGet(Object pojo, String fieldName, 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 Object getConstructorParameter(int index)
getConstructorParameter
in interface ConstructorInjector
index
- the index of the parameter
null
if no
objects are injected. This implementation returns null
ConstructorInjector.getConstructorParameter(int)
public 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 index
null
ConstructorInjector.getConstructorParameterType(int)
public void onEntry(Object pojo, Method method, 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, Method, Object[])
public void onExit(Object pojo, Method method, 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, Method, Object)
public void onError(Object pojo, Method method, Throwable throwable)
onError
in interface MethodInterceptor
pojo
- the pojo on which the method was accessed.method
- the invoked method.throwable
- the thrown exceptionMethodInterceptor.onError(java.lang.Object, java.lang.reflect.Method, java.lang.Throwable)
public void onFinally(Object pojo, Method method)
MethodInterceptor.onExit(Object, Method, Object)
or
MethodInterceptor.onError(Object, Method, Throwable)
were already called.
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(Object instance)
instance
- the created instance
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |