You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Configuration Handler

The configuration handler aims to manage component configuration. This handler allows the OSGi configuration admin to push a configuration to a component. A configuration is a set of couple (name, value). The name can be a field name or a property name associated to a field.

Configurable Property configuration

Not all the component are configurable. A component set its configurable part by adding in this metadata a ConfigurableProperty element. These properties are not necessarily service property. Moreover, there are not declared inside a Provides element but directly under the Component element.

Examples

XML Metadata

<?xml version="1.0" encoding="UTF-8"?>
<iPOJO>
<Component className="fr.imag.adele.escoffier.hello.impl.HelloServiceImpl">
<Provides>
<Property name="foo" field="m_foo"/>
</Provides>
<Properties configurable="true"/>

  • <Property name="foo" field="m_foo"/>*
  • <Property name="array" field="my_array"/>*
  • <Properties name="hello.language" type="java.lang.String"/>
    *</Properties>
    </Component>
    <instance component="fr.imag.adele.escoffier.hello.impl.HelloServiceImpl" name="HelloService">
    <property name="foo" value="bar"/>
    *<property name="array" value="
    Unknown macro: {1, 2, 3}
    "/>*
    *<property name="hello.language" value="en"/>
    </instance>
    </iPOJO>

In the previous snippet, you can see three configurable properties. The first is a configurable property attached to the field foo that is a service property too. The second is an array property. The third property is a static property, in the sense that no field is attached to this property.

These three properties are configured by the instance configuration.

The attribute configurable="true" allows the exposition of the ManagedService service. Therefore, when a new configuration is pushed, the published service properties changes too. The configuration admin uses the name of the instance to know which configuration is associated with which component instance. The name needs to be unique for the framework.

Technical Explanations

This handler has two capacity :

  • first, pushing instance configuration to the component instance
  • and allowing the dynamic configuration of these properties

The second point is not enable by default. To enable it, the attribute configurable need to be true. Then the handlers provides the "org.osgi.service.cm.ManagedService" service. Therefore, the configuration admin looks for all this services and manages (push or update) configurations to the components.
When the configuration admin push a configuration to a component, the configurable property value change but it diffuses the change to service property if needed.

  • No labels