|Re: Is it possible to use two different versions from single DM bundle? [message #647604 is a reply to message #647595]
||Fri, 07 January 2011 09:59
| Frieder Heugel
Registered: October 2010
Location: Basel, CH
|Martin Schmied wrote on Fri, 07 January 2011 04:18|
it's not possible to have two different version of a bundle (BundleB_v1 and BundleB_v2) on a single classpath (in this case BundleA) - so using imports is not an option here. You can however list all installed bundles from your BundleA through BundleContext (which you get in the bundle's Activator or you get it injected in case of Spring / DS bundle) - you can find both versions of BundleB, get their's classloaders (and use them to instantiate classes from these bundles), list registered services, load resources and more. BundleContext.getBundles() is where you want to start.
That said, I cannot think of a valid use-case for combining different versions of classes on a single classpath aside from doing some support work on behalf of other bundles.
I am not sure what you mean with "access two different versions of same bundle". In case you need to access the same class in BundleB_v? stick with Martin's solution. On the other hand if you just need to access different packages in both BundleB bundles then Import-Package in combination with package versions might be another solution (e.g. import package foo.bar[1.0.0] and hello.world[2.0.0]).
[Updated on: Fri, 07 January 2011 10:05]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01612 seconds