Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Getting the bundle from the classloader?
Getting the bundle from the classloader? [message #63197] Tue, 07 March 2006 15:34 Go to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

I recently blogged about <a href=" http://alblue.blogspot.com/2006/03/javaeclipse-running-all-t ests-in.html">running all tests in Eclipse</a>, using a dynamic mechanism to query all classes ending in *Test, instead of having to create an AllTests class manually. (Apart from anything else, it can selectively ignore platform tests as well as span projects.)

When I was implenting the code, I wanted to get hold of the Bundle that was associated with a particular class (e.g. via the classloader), to get the bundle name and from there the list of the bundle's contents. I couldn't find an easy way to do it, so in the end I went for an implementation that used conventions rather than a proper lookup (by using the package name and assuming package name == bundle name).

Is there a public API to query this information?

Alex.
Re: Getting the bundle from the classloader? [message #63220 is a reply to message #63197] Tue, 07 March 2006 16:04 Go to previous messageGo to next message
Jeremy Volkman is currently offline Jeremy VolkmanFriend
Messages: 14
Registered: July 2009
Junior Member
The proper way would be to use the PackageAdmin service provided by
Equinox (and part of the OSGi specification). In particular, I think
you're looking for:

PackageAdmin.getBundle(Class) : Bundle

which returns the Bundle which owns the given Class.

Jeremy Volkman
Re: Getting the bundle from the classloader? [message #63244 is a reply to message #63220] Tue, 07 March 2006 18:07 Go to previous message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Thanks, that's exactly what I was looking for :-)

Alex.
Previous Topic:Problems moving to latest serverside OSGI code
Next Topic:Programatically launch Equinox from Eclipse
Goto Forum:
  


Current Time: Thu Apr 18 05:07:28 GMT 2024

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

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

Back to the top