org.apache.felix.ipojo
Class Handler

java.lang.Object
  extended by org.apache.felix.ipojo.Handler
Direct Known Subclasses:
PrimitiveHandler

public abstract class Handler
extends java.lang.Object

Handler Abstract Class.

Author:
Felix Project Team

Field Summary
static java.lang.String HANDLER_LEVEL_PROPERTY
          Handler priority.
static java.lang.String HANDLER_NAME_PROPERTY
          Handler name property.
static java.lang.String HANDLER_NAMESPACE_PROPERTY
          Handler namespace property.
static java.lang.String HANDLER_TYPE_PROPERTY
          Handler type property.
protected  HandlerManager m_instance
          HandlerManager managing the current handler.
protected  boolean m_isValid
          Handler validity.
 
Constructor Summary
Handler()
           
 
Method Summary
protected abstract  void attach(ComponentInstance instance)
          Attach the current handler object to the given component instance.
abstract  void configure(org.apache.felix.ipojo.metadata.Element metadata, java.util.Dictionary configuration)
          Configure the handler.
 void error(java.lang.String message)
          Log method (error).
 void error(java.lang.String message, java.lang.Throwable exception)
          Log method (error).
 HandlerDescription getDescription()
          Return the current handler description.
abstract  Handler getHandler(java.lang.String name)
          Get a plugged handler of the same container.
 HandlerManager getHandlerManager()
          Get the component instance of the current handler.
abstract  Logger getLogger()
          Get the logger to use in the handler.
 boolean getValidity()
           
 void info(java.lang.String message)
          Log method (info).
 void initializeComponentFactory(ComponentTypeDescription typeDesc, org.apache.felix.ipojo.metadata.Element metadata)
          Initialize component factory.
 boolean isValid()
          Check if the current handler is valid.
 void reconfigure(java.util.Dictionary configuration)
          The instance is reconfiguring.
abstract  void setFactory(Factory factory)
          Set the factory attached to this handler object.
 void setValidity(boolean isValid)
          Set the validity of the current handler.
abstract  void start()
          Start the handler : start the management.
 void stateChanged(int state)
          This method is called when the component state changed.
abstract  void stop()
          Stop the handler : stop the management.
 void warn(java.lang.String message)
          Log method (warning).
 void warn(java.lang.String message, java.lang.Throwable exception)
          Log method (warning).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLER_NAMESPACE_PROPERTY

public static final java.lang.String HANDLER_NAMESPACE_PROPERTY
Handler namespace property.

See Also:
Constant Field Values

HANDLER_NAME_PROPERTY

public static final java.lang.String HANDLER_NAME_PROPERTY
Handler name property.

See Also:
Constant Field Values

HANDLER_TYPE_PROPERTY

public static final java.lang.String HANDLER_TYPE_PROPERTY
Handler type property.

See Also:
Constant Field Values

HANDLER_LEVEL_PROPERTY

public static final java.lang.String HANDLER_LEVEL_PROPERTY
Handler priority.

See Also:
Constant Field Values

m_isValid

protected boolean m_isValid
Handler validity.


m_instance

protected HandlerManager m_instance
HandlerManager managing the current handler.

Constructor Detail

Handler

public Handler()
Method Detail

setFactory

public abstract void setFactory(Factory factory)
Set the factory attached to this handler object. This method must be override to depend on each component factory type.

Parameters:
factory - : the factory.

getLogger

public abstract Logger getLogger()
Get the logger to use in the handler. This method must be override to depend on each component factory type logging policy.

Returns:
the logger.

warn

public final void warn(java.lang.String message)
Log method (warning).

Parameters:
message - : message to log

error

public final void error(java.lang.String message)
Log method (error).

Parameters:
message - : message to log

info

public final void info(java.lang.String message)
Log method (info).

Parameters:
message - : message to log

warn

public final void warn(java.lang.String message,
                       java.lang.Throwable exception)
Log method (warning).

Parameters:
message - : message to log
exception - : exception to attach to the message

error

public final void error(java.lang.String message,
                        java.lang.Throwable exception)
Log method (error).

Parameters:
message - : message to log
exception - : exception to attach to the message

getHandler

public abstract 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.

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.

attach

protected abstract void attach(ComponentInstance instance)
Attach the current handler object to the given component instance. An attached handler becomes a part of the instance container.

Parameters:
instance - : the component instance on which the current handler will be attached.

isValid

public final boolean isValid()
Check if the current handler is valid. This check test the handlers validity. This method must not be override.

Returns:
true if the handler is valid.

setValidity

public final void setValidity(boolean isValid)
Set the validity of the current handler.

Parameters:
isValid - : if true the handler becomes valid, else it becomes invalid.

getValidity

public final boolean getValidity()

getHandlerManager

public final HandlerManager getHandlerManager()
Get the component instance of the current handler.

Returns:
: the component instance.

initializeComponentFactory

public void initializeComponentFactory(ComponentTypeDescription typeDesc,
                                       org.apache.felix.ipojo.metadata.Element metadata)
                                throws ConfigurationException
Initialize component factory. This method aims to gather component factory properties. Each handler wanting to contribute need to override this method and add properties to the given component description.

Parameters:
typeDesc - : component description.
metadata - : component type metadata.
Throws:
ConfigurationException - : if the metadata are not correct (early detection).

configure

public abstract void configure(org.apache.felix.ipojo.metadata.Element metadata,
                               java.util.Dictionary configuration)
                        throws ConfigurationException
Configure the handler.

Parameters:
metadata - : the metadata of the component
configuration - : the instance configuration
Throws:
ConfigurationException - : if the metadata are not correct.

stop

public abstract void stop()
Stop the handler : stop the management.


start

public abstract void start()
Start the handler : start the management.


stateChanged

public void stateChanged(int state)
This method is called when the component state changed.

Parameters:
state - : the new state

getDescription

public HandlerDescription getDescription()
Return the current handler description. The simplest description contains only the name and the validity of the handler.

Returns:
the description of the handler..

reconfigure

public void reconfigure(java.util.Dictionary configuration)
The instance is reconfiguring.

Parameters:
configuration - : New instance configuration.