Search code examples
javaosgibundlesystem-properties

Can OSGi frameworks start bundles concurrently?


We have two bundles, both embed a different version of the same 3rd party library and we have to use them with different configurations. Unfortunately the library is only configurable via system properties.

So, we try to do the following the Activator classes:

  1. setting the required system properties,
  2. initializing the library,
  3. unsetting the former system properties.

It won't work if an OSGi framework starts the two bundles concurrently. Is it allowed for an OSGi framework implementation? Is this solution safe? Is there any other way to set the same system property to different values for different bundles?

(If it's possible we would like to avoid setting different start levels for these bundles.)


Solution

  • An OSGi framework implementation is allowed to start bundles, within a given start level, concurrently. So you can put the bundle's in different start levels to ensure one is started before the other.