Associating a service with a persisted identity
You associate a set of configuration properties with its consuming component as described in the OSGi Configuration Admin specification by using the the persisted identity (PID).
About this task
- Register an implementation of org.osgi.service.cm.ManagedService or org.osgi.service.cm.ManagedServiceFactory directly with the OSGi Configuration Admin service (CA)
- This is most commonly used in low-level kernel bundles, where service management through OSGi Declarative Services (DS) or Blueprint is not available at bundle start time. The registration specifies the PID that identifies the configuration set to be received.
- Define a service to DS
- This is the most common way for services in feature bundles to receive their configuration. The service name is used as the PID to associate configuration data. DS receives the configuration set from CA and passes it on to the defined service.
Example
A service might be declared by using the following entry in the project
*.bnd
file:
Service-Component: com.ibm.ws.transaction; \
provide:='com.ibm.tx.config.ConfigurationProvider'; \
immediate:='true'; \
modified:='modified'; \
implementation:=com.ibm.ws.transaction.services.JTMConfigurationProvider
This generates the following XML code, which can also be coded by the developer instead of using
the bnd
Service-Component entry:
<component name="com.ibm.ws.transaction" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0"
immediate="true" modified="modified">
<implementation class="com.ibm.ws.transaction.services.JTMConfigurationProvider" />
<service>
<provide interface="com.ibm.tx.config.ConfigurationProvider" />
</service>
<property name="service.vendor" value="IBM" />
</component>
The component name, com.ibm.ws.transaction in this example, is used as the PID
for the association of configuration data. If this component does not provide any metadata to
describe its configuration, you can specify configuration properties for the component by using that
PID in the server.xml file, or an included file, by defining an entry of the
following form:
<com.ibm.ws.transaction made.up.property.key="47">