Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
None
-
None
-
None
Description
The SCR runtime does not set the bundle location of the configuration consuming component to the Configuration object. This is the case in the ManagedService-s and makes them more resilient to any external actions.
With Felix SCR currently if you have a component requiring a configuration PID (the component is activated successfully) and you get the configuration PID using the ConfigurationAdmin service without specifying "null" for the bundle location you will end up sending a ConfigurationEvent.CM_LOCATION_CHANGED event which in hand will trigger a component destruction.
Sample service:
import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.ConfigurationPolicy; import org.osgi.service.component.annotations.Deactivate; @Component( configurationPid = "com.softwareag.dummy.pid", configurationPolicy = ConfigurationPolicy.REQUIRE, immediate = true) public class Dummy{ @Activate public void activate() { System.out.println("Dummy is active"); } @Deactivate public void deactivate() { System.out.println("Dummy is deactivated"); } }
Sample snippet for consumer:
... Configuration ssoConf = configAdmin.getConfiguration("com.softwareag.dummy.pid"); System.out.println("Bundle location for the dummy configuration is: " + ssoConf.getBundleLocation()); }
If the bundle location in the configuration is null the second snippet sets the bundle location and deactivates the component.