Search code examples
osgiapache-felixobr

When a bundle is programmatically started, should dependencies also be started?


Here's the scenario:

I have a bundle 'BundleA' installed and started in an OSGi container. A new version of BundleA is available. BundleA is provisioned using Felix Bundle Repository. The new version of BundleA declares a new package level requirement on a package from 'BundleB'.

Before I update BundleA (using OBR's deploy()) I stop BundleA because I want all threads to stop running and the deactivator provides this ability.

When I perform a deploy() on BundleA, BundleB is also installed, as expected.

I then programmatically start() BundleA again, and BundleA starts. But BundleB is 'resolved', not 'active'. I can manually start BundleB and it works as expected.

Is this expected, related to a way I am programmatically calling OSGi API, or did something go wrong?


Solution

  • That's the expected default behavior.

    You can enable automatic activation of bundles as soon as any class from them is loaded. In order to do so, you need to set the Bundle-ActivationPolicy: lazy header.

    In Eclipse that's the checkbox "Activate this plug-in when one of its classes is loaded" in the Manifest editor on the Overview page.