Skip to main content



      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 01:38 Go to next message
Eclipse UserFriend
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 04:18 Go to previous messageGo to next message
Eclipse UserFriend
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 04:59 Go to previous messageGo to next message
Eclipse UserFriend
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 05:05] by 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 11:58 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 06:17:28 EDT 2025

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

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

Back to the top