[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [equinox-dev] org.osgi.framework.Bundle from java.lang.Class
- From: "Neil Bartlett" <njbartlett@xxxxxxxxx>
- Date: Wed, 22 Nov 2006 12:13:36 -0000 (GMT)
- Delivered-to: firstname.lastname@example.org
- Importance: Normal
- User-agent: SquirrelMail/1.4.5
Sounds like a job for Package Admin:
* Returns the bundle from which the specified class is loaded. The class
* loader of the returned bundle must have been used to load the specified
* class. If the class was not loaded by a bundle class loader then
* <code>null</code> is returned.
public Bundle getBundle(Class clazz);
But what does "outside the framework" mean? If you mean hat you're outside
an OSGi runtime, and therefore don't have access to the PackageAdmin
service, then you shouldn't need to care about the x-internal either.
> I would like to know, from outside the framework, which bundle a
> particular class belongs to. I can use the following code snippet
> ClassLoader loader = clazz.getClassLoader();
> BaseClassLoader baseClassLoader = (BaseClassLoader)loader;
> Bundle bundle =
> but I get "Discouraged access ..." warnings because the
> org.eclipse.osgi.baseadaptor package is x-internal. Is there another way
> to do it?
> Thanks in advance.
> Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester, SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139 (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
> equinox-dev mailing list