Sometimes there is a need to persist state of BUG between launches, this can be achieved using OSGi's Configuration Admin (CM). There is an implementation of CM provided by com.buglabs.osgi.cm that can be obtained from CVS and is available in SDK. Also test cases are available in com.buglabs.osgi.cm.tests
Bellow is short how-to on how to use CM:
Configuration Admin HOW-TO:
Upon unregistering a bundle from the OSGi Framework all configuration data that might have been set to define its state is gone. To relieve user of pains of reconfiguring the bundle
once its active, Configuration Admin can be used to persist configuration data so that upon the bundle's being active again its states can be set to those when they were before bundle was
Get Configuration Admin Service:
or use a ServiceTracker in order to know when service will be available.
Get the Configuration:
Each Configuration contains a Dictionary that holds properties for service of interest, to initiate a new store or retrieve an existing one:
Retrieve properties for the service:
Update service with properties:
Refer to section 10.4.2 of OSGi R3 specifications for valid types that can be used in Dictionary.
Configuration's properties can also be cleared by executing
Complete specifications for OSGi including CM can be downloaded from http://www2.osgi.org/Specifications/HomePage.