org.apache.felix.ipojo.handlers.lifecycle.controller
Class ControllerHandler

java.lang.Object
  extended by org.apache.felix.ipojo.Handler
      extended by org.apache.felix.ipojo.PrimitiveHandler
          extended by org.apache.felix.ipojo.handlers.lifecycle.controller.ControllerHandler
All Implemented Interfaces:
ConstructorInjector, FieldInterceptor, MethodInterceptor

public class ControllerHandler
extends PrimitiveHandler

Lifecycle Controller handler. This handler allow a POJO to vote for the instance state. By setting a boolean field to true or false, the handler state changed.

Author:
Felix Project Team

Field Summary
 
Fields inherited from class org.apache.felix.ipojo.PrimitiveHandler
HANDLER_TYPE
 
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
ControllerHandler()
           
 
Method Summary
 void configure(Element metadata, Dictionary configuration)
          Configure method.
 void initializeComponentFactory(ComponentTypeDescription desc, Element metadata)
          Initialize the component factory.
 Object onGet(Object pojo, String field, Object value)
          GetterCallback.
 void onSet(Object pojo, String field, Object value)
          SetterCallback.
 void start()
          Start method.
 void stop()
          Stop method.
 
Methods inherited from class org.apache.felix.ipojo.PrimitiveHandler
attach, getConstructorParameter, getConstructorParameterType, getFactory, getHandler, getInstanceManager, getLogger, getPojoMetadata, onCreation, onEntry, onError, onExit, onFinally, setFactory
 
Methods inherited from class org.apache.felix.ipojo.Handler
debug, error, error, getDescription, getHandlerManager, getValidity, info, isValid, reconfigure, setValidity, stateChanged, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerHandler

public ControllerHandler()
Method Detail

configure

public void configure(Element metadata,
                      Dictionary configuration)
               throws ConfigurationException
Configure method. Look for the first 'controller' element.

Specified by:
configure in class Handler
Parameters:
metadata - : metadata
configuration - : configuration
Throws:
ConfigurationException - : the field attribute is missing or does not exist in the class.
See Also:
org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.InstanceManager, org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)

start

public void start()
Start method. This methods initializes the controller value.

Specified by:
start in class Handler
See Also:
Handler.start()

stop

public void stop()
Stop method. Nothing to do.

Specified by:
stop in class Handler
See Also:
Handler.stop()

onGet

public Object onGet(Object pojo,
                    String field,
                    Object value)
GetterCallback.

Specified by:
onGet in interface FieldInterceptor
Overrides:
onGet in class PrimitiveHandler
Parameters:
pojo - : the pojo object on which the field is accessed Return the stored value.
field - : field name.
value - : value given by the previous handler.
Returns:
: the handler state.
See Also:
FieldInterceptor.onGet(Object, String, Object)

onSet

public void onSet(Object pojo,
                  String field,
                  Object value)
SetterCallback.

Specified by:
onSet in interface FieldInterceptor
Overrides:
onSet in class PrimitiveHandler
Parameters:
pojo - : the pojo object on which the field is accessed Store the new field value & invalidate / validate the handler is required.
field - : field name.
value - : new value.
See Also:
FieldInterceptor.onSet(Object, String, Object)

initializeComponentFactory

public void initializeComponentFactory(ComponentTypeDescription desc,
                                       Element metadata)
                                throws ConfigurationException
Initialize the component factory. The controller field is checked to avoid configure check.

Overrides:
initializeComponentFactory in class Handler
Parameters:
desc - : component description
metadata - : component type metadata
Throws:
ConfigurationException - : occurs if the controller field is not in the POJO class or is not a boolean.
See Also:
Handler.initializeComponentFactory(org.apache.felix.ipojo.architecture.ComponentTypeDescription, org.apache.felix.ipojo.metadata.Element)


Copyright © 2011 Apache Software Foundation. All Rights Reserved.