Search code examples
javaeclipseosgiequinox

Different versions of extensions running concurrently


Is it possible to run concurrently two versions of an extension in an OSGi application with an extension point?

This is what I would like to accomplish:
I have an extension point Foo and a module with symbolic name Bar and version 1.0.0 plugged to the extension point and running (i.e. instantiated) in module A and module B. Then I install a new extension bundle with a bug fix, symbolicName Bar and version 1.0.1. and I want to run this new version only in module B, so module A still uses Bar v1.0.0 and module B uses now Bar v1.0.1.

From what I have seen, it is not possible since an extension needs to be a singleton so there can't be two versions of the same symbolic name. So our current solution is to have the symbolic name contain the version as well: symbolicName Bar_1_0_0 and symbolicName Bar_1_0_1. Doing this we can run each version in each module independently and concurrently since they are technically unrelated bundles that just happen to plug into the same extension point.

However, putting the version in the symbolic name seems like the wrong way to do it. Can this be accomplished without changing the symbolic name? am I missing something?


Solution

  • You aren't missing anything. Eclipse extension system (plugin.xml) only works with singleton bundles, which means multiple versions cannot be active at the same time. To have non-singleton extensions, you'd have to use a different extension system. I understand that OSGi services can handle this scenario. May want to take a look at the OSGi spec.