Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Is it possible to use two different versions from single DM bundle?(Is it possible to use two different versions from single DM bundle?)
Is it possible to use two different versions from single DM bundle? [message #647572] Fri, 07 January 2011 06:38 Go to next message
Thiru  is currently offline Thiru Friend
Messages: 5
Registered: December 2010
Junior Member
Hi,
My requirement is I need to access two different versions of same bundle inside my bundle.
Ex: BundleA--dependency->BundleB_version1.0 and BundleB_version2.0

Is it possible?.If yes how to do it?

Thanks,
Thiru
Re: Is it possible to use two different versions from single DM bundle? [message #647595 is a reply to message #647572] Fri, 07 January 2011 09:18 Go to previous messageGo to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 7
Registered: July 2009
Junior Member
Hi Thiru,

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.

Regards,
Martin
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 Go to previous messageGo to next message
Frieder Heugel is currently offline Frieder HeugelFriend
Messages: 61
Registered: October 2010
Location: Basel, CH
Member
Martin Schmied wrote on Fri, 07 January 2011 04:18
Hi Thiru,

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.

Regards,
Martin


Hi Thiru,

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]).

Bye
Frieder

[Updated on: Fri, 07 January 2011 10:05]

Report message to a moderator

Re: Is it possible to use two different versions from single DM bundle? [message #647669 is a reply to message #647572] Fri, 07 January 2011 16:58 Go to previous message
Thiru  is currently offline Thiru Friend
Messages: 5
Registered: December 2010
Junior Member
Hi ,
Thanks Martin and Frieder for your suggestions.

I need to access same class from both versions of BundleB
inside BundleA.

It would be great if you can provide code sample.

Thanks,
Thiru
Previous Topic:Spring Security
Next Topic:Running in STS
Goto Forum:
  


Current Time: Thu Apr 25 06:59:43 GMT 2024

Powered by FUDForum. Page generated in 0.03856 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top