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

Compare with Current View Page History

Version 1 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" name="Adele.HelloService">
<Provides>
<DynamicProperty name="language" value="fr" field="language"/>
</Provides>
<ConfigurableProperty field="language" name="lang"/>
<ConfigurableProperty field="user" value="Clement"/>
</Component>
</iPOJO>

In the previous snippet, you can see two configurable properties. The first is a configurable property attached to the field language that is a service property too. Therefore, when a new configuration is pushed, the published service properties changes too. The second configurable property just pushed a value to the field user. But this property has an initial value: "Clement".

The name attribute of the component element is the name of the component. The configuration admin uses this name to know which configuration is associated with which component. The name needs to be unique for the framework. If the attribute name does not exist, the class name is used as name.
Manifest Metadata
The following code snippet shows you the same metadata but in the manifest format:

Component { $className=fr.imag.adele.escoffier.hello.impl.HelloServiceImpl $name=Adele.HelloService
Provides { $interface=fr.imag.adele.escoffier.hello.HelloService
DynamicProperty { $name=language $value=fr $field=language }
}
ConfigurableProperty { $field=language $name=lang }
ConfigurableProperty { $field=user $value=Clement }
}

Technical Explanations

In fact, when an iPOJO container uses one or several configurable property, it 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.

Limitation and perspectives

The configuration admin uses two kind of service the ManagedService and the ManagedServiceFactory. Today, iPOJO support only ManagedService. Therefore, one of the next improvements of the configuration feature is to support the ManagedServiceFactory.

  • No labels