TPcm

Un article de EOSGi.

Sommaire

[modifier] Configuration de bundles OSGi

La spécification Configuration Admin[1] permet de configurer et de reconfigurer les propriétés de bundles déployés sur une plateforme OSGi.

Ce TP vise à présenter la manipulation de ces configurations.

EN CHANTIER

[modifier] Publication du service ManagedService

vendor.weiner.cm


[modifier] Configuration avec iPOJO

[modifier] Configuration avec Spring/OSGi

@see A bean with several properties set via the configuration admin service and using the “update” facility will see multiple property updates (one for each changed property) when a set of related changes are made to the configuration.

The <osgi:config> element defines a bean of type Map containing all of the properties registered under the given persistent-id.

  <osgi:config id="myVendorProperties" persistent-id="eosgi.snackbar.vendor.weiner.cm"/>

It supports zero or more nested config-listener elements that are used to define listener beans to be notified when the contents of the Map changes. The update-method attribute of config-listener is mandatory. The value of this attribute is the name of the method in the referenced listener bean to be invoked when the configuration changes. For example:

  <osgi:config id="myVendorProperties" persistent-id="eosgi.snackbar.vendor.weiner.cm">
    <osgi:config-listener ref="aListenerBean" 
          update-method="setVendorProperties"/>
  </osgi:config>

The method named in the update-method attribute must have a signature with one of the following forms:

public void update_method_name(java.util.Map properties)

or

public void update_method_name(String pid, java.util.Map properties)

The second form is intended for use with managed service factories (see section 104.6 of the OSGi services compendium). If the persistent-id specified for an <osgi:config> element is actually a factory PID for configuration information managed by an ManagedServiceFactory then the update-method will be invoked once for each set of properties registered under the factory PID.