Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The ManagedService is a service specified in the OSGi Compendium. It allows reconfiguring an instance with the Configuration Admin. There is two way for an iPOJO instance to expose a Managed Service.

  • In the component type description by adding the pid attribute in the properties element

...

  • In the instance configuration by configuring the managed.service.pid property
    Code Block
    xml
    xml
    
    <iPOJO>
    <Component className="fr.imag.adele.escoffier.hello.impl.HelloServiceImpl">
       <Provides>
           <Property name="foo" field="m_foo"/>
       </Provides>
       <Properties propagation="false" pid="mymanagedservicepid"/>
           <Property name="foo" field="m_foo"/>
           <Property name="array" method="updateArray"/>
           <Property 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"/>
       <property name="managed.service.pid" value="mymanagedservicepid2"/>
    </instance>
    </iPOJO>
    
    Info
    titleType vs. Instance configuration

    If the managed service pid is specified both in the component type and in the instance configuration, the instance configuration is used.

The managed service pid is the identifier used by the Configuration Admin to attach configuration to Managed Services. First this pid must be unique (as any pid in OSGi). Moreover, this pid cannot be the same one that the pid used in the Managed Service Factory to create the instance (if you use this way to create your instance).

...