org.apache.felix.ipojo.composite

## Class CompositeManager

- java.lang.Object
- - org.apache.felix.ipojo.composite.CompositeManager

All Implemented Interfaces:
  ComponentInstance, InstanceStateListener

    public class CompositeManager
    extends java.lang.Object
    implements ComponentInstance, InstanceStateListener

iPOJO Composite manager. The composite manager class manages one instance of a component type which is a composition. It manages component lifecycle, and handlers...

Author:
  Felix Project Team

### Field Summary

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

`DISPOSED, INVALID, STOPPED, VALID`

### Constructor Summary

Constructors
Constructor and Description
`CompositeManager(CompositeFactory factory, org.osgi.framework.BundleContext context, HandlerManager[] handlers)` Construct a new Component Manager.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCompositeHandler(HandlerManager handler)` Plug the given handler to the current container.
`void` `addInstanceStateListener(InstanceStateListener listener)` Add an instance to the created instance list.
`void` `configure(org.apache.felix.ipojo.metadata.Element metadata, java.util.Dictionary configuration)` Configure the instance manager.
`void` `dispose()` Dispose the instance.
`CompositeHandler` `getCompositeHandler(java.lang.String name)` Return a specified handler.
`org.osgi.framework.BundleContext` `getContext()` Get the bundle context used by this instance.
`ComponentFactory` `getFactory()` Get the factory which create this instance.
`org.osgi.framework.BundleContext` `getGlobalContext()` Get the global bundle context.
`InstanceDescription` `getInstanceDescription()` Return the instance description of this instance.
`java.lang.String` `getInstanceName()` Get the instance name.
`ServiceContext` `getParentServiceContext()` Get the parent service context.
`CompositeHandler[]` `getRegistredCompositeHandlers()` REturn the list of handlers plugged on this instance.
`ServiceContext` `getServiceContext()` Get the internal service context of this instance.
`int` `getState()` Get the actual state of the instance.
`boolean` `isStarted()` Check if the instance is started.
`protected void` `kill()` Kill the current instance.
`void` `reconfigure(java.util.Dictionary configuration)` Reconfigure the current instance.
`void` `removeInstanceStateListener(InstanceStateListener listener)` Remove an instance state listener.
`void` `setState(int state)` Set the state of the component.
`void` `start()` Start the instance manager.
`void` `stateChanged(ComponentInstance instance, int newState)` State Change listener callback.
`void` `stop()` Stop the instance manager.

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

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

### Constructor Detail

#### CompositeManager

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

Construct a new Component Manager.

Parameters:
  `factory` - : the factory managing the instance manager
  `context` - : the bundle context to give to the instance
  `handlers` - : the handlers to plug

### Method Detail

#### addCompositeHandler

    public void addCompositeHandler(HandlerManager handler)

Plug the given handler to the current container.

Parameters:
  `handler` - : the handler to plug.

#### addInstanceStateListener

    public void addInstanceStateListener(InstanceStateListener listener)

Add an instance to the created instance list.

Specified by:
  `addInstanceStateListener` in interface `ComponentInstance`
Parameters:
  `listener` - : the instance state listener to add.
See Also:
  `ComponentInstance.addInstanceStateListener(org.apache.felix.ipojo.InstanceStateListener)`

#### configure

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

Configure the instance manager. Stop the existing handler, clear the handler list, change the metadata, recreate the handler

Parameters:
  `metadata` - : the component type metadata
  `configuration` - : the configuration of the instance
Throws:
  `ConfigurationException` - : occurs when the component type are incorrect.

#### dispose

    public void dispose()

Dispose the instance.

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

#### getCompositeHandler

    public CompositeHandler getCompositeHandler(java.lang.String name)

Return a specified handler.

Parameters:
  `name` - : class name of the handler to find
Returns:
  : the handler, or null if not found

#### getContext

    public org.osgi.framework.BundleContext getContext()

Get the bundle context used by this instance.

Specified by:
  `getContext` in interface `ComponentInstance`
Returns:
  the parent context of the instance.
See Also:
  `ComponentInstance.getContext()`

#### getFactory

    public ComponentFactory getFactory()

Get the factory which create this instance.

Specified by:
  `getFactory` in interface `ComponentInstance`
Returns:
  the factory of the component
See Also:
  `ComponentInstance.getFactory()`

#### getGlobalContext

    public org.osgi.framework.BundleContext getGlobalContext()

Get the global bundle context.

Returns:
  the global bundle context.

#### getInstanceDescription

    public InstanceDescription getInstanceDescription()

Return the instance description of this instance.

Specified by:
  `getInstanceDescription` in interface `ComponentInstance`
Returns:
  the instance description.
See Also:
  `ComponentInstance.getInstanceDescription()`

#### getInstanceName

    public java.lang.String getInstanceName()

Get the instance name.

Specified by:
  `getInstanceName` in interface `ComponentInstance`
Returns:
  the instance name
See Also:
  `ComponentInstance.getInstanceName()`

#### getParentServiceContext

    public ServiceContext getParentServiceContext()

Get the parent service context.

Returns:
  the parent service context.

#### getRegistredCompositeHandlers

    public CompositeHandler[] getRegistredCompositeHandlers()

REturn the list of handlers plugged on this instance.

Returns:
  the list of the registered handlers.

#### getServiceContext

    public ServiceContext getServiceContext()

Get the internal service context of this instance.

Returns:
  the internal service context.

#### getState

    public int getState()

Get the actual state of the instance.

Specified by:
  `getState` in interface `ComponentInstance`
Returns:
  the actual state of the instance
See Also:
  `ComponentInstance.getState()`

#### isStarted

    public boolean isStarted()

Check if the instance is started.

Specified by:
  `isStarted` in interface `ComponentInstance`
Returns:
  true if the instance is started.
See Also:
  `ComponentInstance.isStarted()`

#### reconfigure

    public void reconfigure(java.util.Dictionary configuration)

Reconfigure the current instance.

Specified by:
  `reconfigure` in interface `ComponentInstance`
Parameters:
  `configuration` - : the new instance configuration.
See Also:
  `ComponentInstance.reconfigure(java.util.Dictionary)`

#### removeInstanceStateListener

    public void removeInstanceStateListener(InstanceStateListener listener)

Remove an instance state listener.

Specified by:
  `removeInstanceStateListener` in interface `ComponentInstance`
Parameters:
  `listener` - : the listener to remove
See Also:
  `ComponentInstance.removeInstanceStateListener(org.apache.felix.ipojo.InstanceStateListener)`

#### setState

    public void setState(int state)

Set the state of the component. if the state changed call the stateChanged(int) method on the handlers.

Parameters:
  `state` - : new state

#### start

    public void start()

Start the instance manager.

Specified by:
  `start` in interface `ComponentInstance`

#### 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`
Parameters:
  `instance` - : changing instance
  `newState` - : new state
See Also:
  `InstanceStateListener.stateChanged(org.apache.felix.ipojo.ComponentInstance, int)`

#### stop

    public void stop()

Stop the instance manager.

Specified by:
  `stop` in interface `ComponentInstance`

#### kill

    protected void kill()

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