org.apache.felix.ipojo

## Class HandlerManager

- java.lang.Object
- - org.apache.felix.ipojo.InstanceManager
  - - org.apache.felix.ipojo.HandlerManager

All Implemented Interfaces:
  ComponentInstance, InstanceBundleContextAware, InstanceStateListener

    public class HandlerManager
    extends InstanceManager

The handler manager manages an handler instance.

Author:
  Felix Project Team

### Field Summary

### Fields inherited from class org.apache.felix.ipojo.InstanceManager

`m_className, m_handlers, m_listeners, m_name, m_pojoObjects, m_state`

### Fields inherited from interface org.apache.felix.ipojo.ComponentInstance

`DISPOSED, INVALID, STOPPED, VALID`

### Constructor Summary

Constructors
Constructor and Description
`HandlerManager(ComponentFactory factory, org.osgi.framework.BundleContext context, HandlerManager[] handlers)` Creates a handler manager.

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.Object` `createPojoObject()` Creates an instance of the content.
`void` `dispose()` Disposes the instance.
`Handler` `getHandler()` Gets the contained handler object.
`void` `init(ComponentInstance instance, org.apache.felix.ipojo.metadata.Element metadata, java.util.Dictionary configuration)` Creates and initializes the handler object.
`protected void` `kill()` Kills the current instance.
`void` `start()` Starts the instance manager.
`void` `stateChanged(ComponentInstance instance, int newState)` State Change listener callback.
`void` `stop()` Stops the instance manager.

### Methods inherited from class org.apache.felix.ipojo.InstanceManager

`addInstanceStateListener, configure, createObject, deletePojoObject, getClassName, getClazz, getContext, getFactory, getFieldValue, getFieldValue, getGlobalContext, getHandler, getInstanceContext, getInstanceDescription, getInstanceName, getLocalServiceContext, getLogger, getPojoObject, getPojoObjects, getRegisteredHandlers, getRegistredFields, getRegistredMethods, getState, isStarted, load, onEntry, onError, onExit, onGet, onSet, reconfigure, register, register, register, register, register, removeInstanceStateListener, setInstanceBundleContext, setState`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### HandlerManager

    public HandlerManager(ComponentFactory factory,
                          org.osgi.framework.BundleContext context,
                          HandlerManager[] handlers)

Creates a handler manager.

Parameters:
  `factory` - the handler factory
  `context` - the bundle context
  `handlers` - the handler array

### Method Detail

#### getHandler

    public Handler getHandler()

Gets the contained handler object. If not already created it creates the object.

Returns:
  the handler object.

#### init

    public void init(ComponentInstance instance,
                     org.apache.felix.ipojo.metadata.Element metadata,
                     java.util.Dictionary configuration)
              throws ConfigurationException

Creates and initializes the handler object.

Parameters:
  `instance` - the component instance on which the handler will be attached.
  `metadata` - the component metadata.
  `configuration` - the instance configuration.
Throws:
  `ConfigurationException` - if the handler configuration failed.

#### createPojoObject

    public java.lang.Object createPojoObject()

Creates an instance of the content. This method needs to be called once only for singleton provided service. This methods call the `InstanceManager.createObject()` method, and adds the created object to the `InstanceManager.m_pojoObjects` list. Then, it calls the `PrimitiveHandler.onCreation(Object)` methods on attached handlers.

Overrides:
  `createPojoObject` in class `InstanceManager`
Returns:
  a new instance or `null` if an error occurs during the creation.

#### start

    public void start()

Starts the instance manager.

Specified by:
  `start` in interface `ComponentInstance`
Overrides:
  `start` in class `InstanceManager`

#### stop

    public void stop()

Stops the instance manager.

Specified by:
  `stop` in interface `ComponentInstance`
Overrides:
  `stop` in class `InstanceManager`

#### dispose

    public void dispose()

Disposes the instance.

Specified by:
  `dispose` in interface `ComponentInstance`
Overrides:
  `dispose` in class `InstanceManager`
See Also:
  `ComponentInstance.dispose()`

#### kill

    protected void kill()

Kills the current instance. Only the factory of this instance can call this method.

#### stateChanged

    public void stateChanged(ComponentInstance instance,
                             int newState)

State Change listener callback. This method is notified at each time a plugged handler becomes invalid.

Specified by:
  `stateChanged` in interface `InstanceStateListener`
Overrides:
  `stateChanged` in class `InstanceManager`
Parameters:
  `instance` - the changing instance
  `newState` - the new state
See Also:
  `InstanceStateListener.stateChanged(org.apache.felix.ipojo.ComponentInstance, int)`