Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Find out bundle from BundleActivator
Find out bundle from BundleActivator [message #114903] Mon, 21 July 2008 17:16 Go to next message
No real name is currently offline No real nameFriend
Messages: 2
Registered: July 2009
Junior Member
Hello

I am very new to OSGi and a bit confused.

Within the activator I get the BundleContext. But there are multiple
bundles installed there, so how do I find out which bundle belongs to
this Activator?
I would like to load properties or other files from either the bundle
itself or a fragment of it. The OSGi spec says that only
bundle.findEntries() is good for that.
But how do I find out which bundle this is? One approach would be this,
but I think there should be an easier way:

Bundle[] bundles = context.getBundles();
for(Bundle b : bundles)
if(b.getHeaders().get("Bundle-Activator").equals(this.getClass().getName())
return b;

Maybe I have missed something?

Thanks in advance,
Stefan Ackermann
Re: Find out bundle from BundleActivator [message #114920 is a reply to message #114903] Mon, 21 July 2008 17:50 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Stivo schrieb:
> But how do I find out which bundle this is? One approach would be this,
> but I think there should be an easier way:

BundleContext#getBundle()

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Find out bundle from BundleActivator [message #114933 is a reply to message #114920] Mon, 21 July 2008 21:28 Go to previous message
No real name is currently offline No real nameFriend
Messages: 2
Registered: July 2009
Junior Member
Thanks Gunnar

I somehow got the idea there was only one BundleContext and that
getBundle would return the system Bundle.


Gunnar Wagenknecht wrote:
> Stivo schrieb:
>> But how do I find out which bundle this is? One approach would be this,
>> but I think there should be an easier way:
>
> BundleContext#getBundle()
>
> -Gunnar
>
Previous Topic:p2 detecting newly installed bundles
Next Topic:How to read file of the bundle in server-side equinox?
Goto Forum:
  


Current Time: Fri Mar 29 07:13:17 GMT 2024

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

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

Back to the top