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

Compare with Current View Page History

« Previous Version 5 Next »

Configuration Handler

The configuration handler aims to manage component configuration. This handler allows the configuration and dynamic reconfiguration of instances. A configuration is a set of couple (name, value). The name can be a field name or a property name associated to a field or/and a method.

Configurable Property configuration

To support configuration, the component type needs to declare which properties are configurable. These properties are not necessarily service property but can be internal component property.

Examples

<iPOJO>
<Component className="fr.imag.adele.escoffier.hello.impl.HelloServiceImpl">
   <Provides>
       <Property name="foo" field="m_foo"/>
   </Provides>
   <Properties configurable="false"/>
       <Property name="foo" field="m_foo"/>
       <Property name="array" method="updateArray"/>
       <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="\{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 attached to a method (updatArray). The third property is a static property, in the sense that neither field nor method is attached to this property.

These three properties are configured by the instance configuration.

By setting the attribute configurable to "true", you allow the property propagation to the service registration. It means that at each time that  the configuration of the instance is updated, all property contained in the configuration is propagate to the service registrations. For example, in the previous example, not only foo will be published but array and hello.lanaguage too.allows the exposition of the ManagedService service. Therefore, when a new configuration is pushed, the published service properties changes too.

If a property has a method, this method in invoke each time that the proeprty value changes. The method receive one argument of the type of the property (int array int the example).

Dynamic Reconfiguration

The handler supports reconfiguration. To reconfigure an instance you can use both iPOJO Factory and the ManagedServiceFactory exposed by the factory of the targetted instance. By calling the method reconfigure or update (according of the service do you use), the handler receive the new configuratino and apply it. If the propagation is activated, the service registratinos are updated too.

  • No labels