Contact me:
Contact me

OSGI Configuration Admin + Declarative Services


Application configuration is really important when developing it. OSGI provides a configuration admin specfication which describes how to use it.
The OSGi Configuration Admin Service is defined in Chapter 104 of the OSGi Compendium Specification.

Here I will try to explain an example of how to use the configuration admin and declarative services all together. You can find more information in other tutorials

Configuration admin specification

As commented in this tutorial , there are multiple implementation of the configuration admin OSGI service.

Here equinox implementation will be used with PAX ConfMan

Note- ManagedService interface (OSGI compendium ):

    The Configuration Admin service is an important aspect of the deployment
    of an OSGi Service Platform. It allows an Operator to set the configuration
    information of deployed bundles.
    Configuration is the process of defining the configuration data of bundles
    and assuring that those bundles receive that data when they are active in the
    OSGi Service Platform.
    In simple words, the Configuration Admin service provides…


To use it, we will use to download the configuration admin implementation located in the OPS4j web:

When running the platform, introduce a JVM argument:

In the configuration directory, create two subdirectories: services and factories.
Within these directories, create a properties file for each PID you have (
In these example:

$ tree configuration/
|-- factories
`-- services

This file,, will be a standard properties file.

$ more
hola prueba
eb bakb

Using declarative services

In the component file, you will need to declare that you are going to implements ManagedService class of the configuration admin service. The component declaration will be something like this:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component name=""
        xsi:schemaLocation=" ">
        <implementation class=""/>
<property name="" value="provider.application"/>
                <provide interface="" />
                <provide interface="" />

Pay attention to the properties tag

                <provide interface="" />

where it is printed the pid name using the property name

and the service implementation:

       <implementation class=""/>

                <provide interface="" />

where it is said that the configuration admin service will be implemented in the class Implementation.

Implementation class

I will like to remark that here, you must override the following methods:

  • protected void activate(ComponentContext context)
  • protected void deactivate(ComponentContext context)
  • public void updated(Dictionary arg0) throws ConfigurationException

Target Platform

Framework is launched.

id State       Bundle
0 ACTIVE      org.eclipse.osgi_3.5.1.R35x_v20090827
1 ACTIVE      org.ops4j.pax.logging.pax-logging-service_1.4.0
2 ACTIVE      org.apache.commons.logging_1.0.4.v200904062259
3 ACTIVE      org.eclipse.equinox.cm_1.0.100.v20090520-1800
4 ACTIVE      org.apache.felix.scr_1.0.6
5 ACTIVE      org.ops4j.pax.logging.pax-logging-api_1.4.0
7 ACTIVE      org.eclipse.osgi.services_3.2.0.v20090520-1800
8 ACTIVE      org.ops4j.pax.configmanager_0.2.2

Declarative sercie bundle: 4 ACTIVE org.apache.felix.scr_1.0.6
Config admin bundles:

  • 8 ACTIVE org.ops4j.pax.configmanager_0.2.2
  • 3 ACTIVE org.eclipse.equinox.cm_1.0.100.v20090520-1800

Binaries and source

You can download all the used bundles and the dummy source code of the configuration bundle here

There, you will find a script, that starts up the equinox platform.
First you will need to set up the path to the directory where you configuration will go. This path setup is found in the config.ini file.

be free to ask or report any problems!

Share it!

Twitter Gmail Delicious Google Bookmarks Hotmail Yahoo Mail Share/Bookmark