finding bundle name? [message #289433] |
Thu, 04 August 2005 13:16  |
Eclipse User |
|
|
|
Originally posted by: sgollery.cadrc.calpoly.edu
Is there a way for a class to find out the name of the bundle that is
contained in, or alternately to get the Bundle object itself? I see how to
do that if the class is derived from WorkbenchPart, but what about classes
that are not part of any specific class hierarchy?
Thanks,
Steve Gollery
|
|
|
|
|
|
|
Re: finding bundle name? [message #289440 is a reply to message #289438] |
Thu, 04 August 2005 18:07  |
Eclipse User |
|
|
|
Originally posted by: sgollery.cadrc.calpoly.edu
John Arthorne wrote:
> You at least need access to a BundleContext, passed to the
> BundleActivator.start(...) method. Once you have the context:
> Object object = ...; //the object you want to find bundle for
> BundleContext context = ...;
> ServiceReference ref =
> context.getServiceReference(PackageAdmin.class.getName());
> if (ref != null) {
> PackageAdmin admin = (PackageAdmin)context.getService(ref);
> Bundle bundle = admin.getBundle(object.getClass());
> bundle.getSymbolicName() -> voila...
> }
> --
Which works fine unless you've created a plugin from an existing Jar file,
in which case there is no BundleActivator class in the plugin.
But I've worked out another way to solve the problem that I thought I
needed a bundle for, so thanks to you and to Sunil for your input.
Steve
> Steven Gollery wrote:
>> Is there a way for a class to find out the name of the bundle that is
>> contained in, or alternately to get the Bundle object itself? I see how
>> to do that if the class is derived from WorkbenchPart, but what about
>> classes that are not part of any specific class hierarchy?
>>
>> Thanks,
>>
>> Steve Gollery
>>
|
|
|
Powered by
FUDForum. Page generated in 0.04862 seconds