org.apache.felix.ipojo.handlers.configuration

## Class ConfigurationHandler

- java.lang.Object
- - org.apache.felix.ipojo.Handler
  - - org.apache.felix.ipojo.PrimitiveHandler
    - - org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler

All Implemented Interfaces:
  ConstructorInjector, FieldInterceptor, MethodInterceptor, org.osgi.service.cm.ManagedService

    public class ConfigurationHandler
    extends PrimitiveHandler
    implements org.osgi.service.cm.ManagedService

Handler managing the Configuration Admin.

Author:
  Felix Project Team

### Field Summary

Fields
`static java.lang.String` `MANAGED_SERVICE_PID`

### 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

Constructors
Constructor and Description
`ConfigurationHandler()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addListener(ConfigurationListener listener)` Add the given listener to the configuration handler's list of listeners.
`protected void` `addProperty(Property prop)` Adds the given property metadata to the property metadata list.
`void` `configure(org.apache.felix.ipojo.metadata.Element metadata, java.util.Dictionary configuration)` Configures the handler.
`HandlerDescription` `getDescription()` Gets the configuration handler description.
`void` `initializeComponentFactory(ComponentTypeDescription desc, org.apache.felix.ipojo.metadata.Element metadata)` Initialize the component type.
`void` `onCreation(java.lang.Object instance)` Handler createInstance method.
`void` `reconfigure(java.util.Dictionary configuration)` Reconfigure the component instance.
`java.lang.Object` `reconfigureProperty(Property prop, java.lang.Object value)` Reconfigures the given property with the given value.
`void` `removeListener(ConfigurationListener listener)` Remove the given listener from the configuration handler's list of listeners.
`void` `start()` Start method.
`void` `stateChanged(int state)` This method is called when the component state changed.
`void` `stop()` Stop method.
`void` `updated(java.util.Dictionary conf)` Managed Service method.

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

`attach, getConstructorParameter, getConstructorParameterType, getFactory, getHandler, getInstanceManager, getLogger, getPojoMetadata, onEntry, onError, onExit, onFinally, onGet, onSet, setFactory`

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

`debug, error, error, getHandlerManager, getValidity, info, isValid, setValidity, warn, warn`

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

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

### Field Detail

#### MANAGED_SERVICE_PID

    public static final java.lang.String MANAGED_SERVICE_PID

See Also:
  Constant Field Values

### Constructor Detail

#### ConfigurationHandler

    public ConfigurationHandler()

### Method Detail

#### initializeComponentFactory

    public void initializeComponentFactory(ComponentTypeDescription desc,
                                           org.apache.felix.ipojo.metadata.Element metadata)
                                    throws ConfigurationException

Initialize the component type.

Overrides:
  `initializeComponentFactory` in class `Handler`
Parameters:
  `desc` - : component type description to populate.
  `metadata` - : component type metadata.
Throws:
  `ConfigurationException` - : metadata are incorrect.
See Also:
  `Handler.initializeComponentFactory(org.apache.felix.ipojo.architecture.ComponentTypeDescription, org.apache.felix.ipojo.metadata.Element)`

#### configure

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

Configures the handler. Access to field does not require synchronization as this method is executed before any thread access to this object.

Specified by:
  `configure` in class `Handler`
Parameters:
  `metadata` - the metadata of the component
  `configuration` - the instance configuration
Throws:
  `ConfigurationException` - one property metadata is not correct
See Also:
  `Handler.configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)`

#### stop

    public void stop()

Stop method. This method is synchronized to avoid the configuration admin pushing a configuration during the un-registration. Do nothing.

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

#### start

    public void start()

Start method. This method is synchronized to avoid the config admin pushing a configuration before ending the method. Propagate properties if the propagation is activated.

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

#### addProperty

    protected void addProperty(Property prop)

Adds the given property metadata to the property metadata list.

Parameters:
  `prop` - : property metadata to add

#### reconfigure

    public void reconfigure(java.util.Dictionary configuration)

Reconfigure the component instance. Check if the new configuration modifies the current configuration. Invokes the updated method if needed.

Overrides:
  `reconfigure` in class `Handler`
Parameters:
  `configuration` - : the new configuration
See Also:
  `Handler.reconfigure(java.util.Dictionary)`

#### reconfigureProperty

    public java.lang.Object reconfigureProperty(Property prop,
                                                java.lang.Object value)

Reconfigures the given property with the given value. This methods handles `InstanceManager.onSet(Object, String, Object)` call and the callback invocation. The reconfiguration occurs only if the value changes.

Parameters:
  `prop` - the property object to reconfigure
  `value` - the new value.
Returns:
  the new property value

#### onCreation

    public void onCreation(java.lang.Object instance)

Handler createInstance method. This method is override to allow delayed callback invocation. Invokes the updated method if needed.

Overrides:
  `onCreation` in class `PrimitiveHandler`
Parameters:
  `instance` - : the created object
See Also:
  `PrimitiveHandler.onCreation(Object)`

#### updated

    public void updated(java.util.Dictionary conf)
                 throws org.osgi.service.cm.ConfigurationException

Managed Service method. This method is called when the instance is reconfigured by the ConfigurationAdmin. When called, it must hold the monitor lock.

Specified by:
  `updated` in interface `org.osgi.service.cm.ManagedService`
Parameters:
  `conf` - : pushed configuration.
Throws:
  `org.osgi.service.cm.ConfigurationException` - the reconfiguration failed.
See Also:
  `ManagedService.updated(java.util.Dictionary)`

#### getDescription

    public HandlerDescription getDescription()

Gets the configuration handler description.

Overrides:
  `getDescription` in class `Handler`
Returns:
  the configuration handler description.
See Also:
  `Handler.getDescription()`

#### addListener

    public void addListener(ConfigurationListener listener)

Add the given listener to the configuration handler's list of listeners.

Parameters:
  `listener` - the `ConfigurationListener` object to be added
Throws:
  `java.lang.NullPointerException` - if `listener` is `null`

#### removeListener

    public void removeListener(ConfigurationListener listener)

Remove the given listener from the configuration handler's list of listeners. If the listeners is not registered, this method does nothing.

Parameters:
  `listener` - the `ConfigurationListener` object to be removed
Throws:
  `java.lang.NullPointerException` - if `listener` is `null`

#### stateChanged

    public void stateChanged(int state)

Description copied from class: `Handler`
This method is called when the component state changed. By default, this method does nothing.

Overrides:
  `stateChanged` in class `Handler`
Parameters:
  `state` - the new instance state `ComponentInstance`