Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Any way to know when bundles are started?
Any way to know when bundles are started? [message #543863] Wed, 30 June 2010 21:31 Go to next message
Randy Hudson is currently offline Randy HudsonFriend
Messages: 123
Registered: July 2009
Senior Member
My bundle activator schedules a background job for 5 seconds in the future. The job should only run after "startup" has completed, and since this is a server, all bundles are activated at startup.

Instead of waiting 5 seconds, how can I wait for "startup" (StartLevelManager#resumeBundles) to complete? Do I use EventHook, or the EventDispatcher service?
Re: Any way to know when bundles are started? [message #544854 is a reply to message #543863] Mon, 05 July 2010 17:36 Go to previous messageGo to next message
Andrew Niefer is currently offline Andrew NieferFriend
Messages: 990
Registered: July 2009
Senior Member
You can try listening for FrameworkEvent.STARTED :
* This event is fired when the Framework has started after all installed
* bundles that are marked to be started have been started and the Framework
* has reached the initial start level. The source of this event is the
* System Bundle.

These events are delivered asynchronously to FrameworkListener's registered
on BundleContext.addFrameworkListener

-Andrew
Randy Hudson wrote:

> My bundle activator schedules a background job for 5 seconds in the
> future. The job should only run after "startup" has completed, and since
> this is a server, all bundles are activated at startup.
>
> Instead of waiting 5 seconds, how can I wait for "startup"
> (StartLevelManager#resumeBundles) to complete? Do I use EventHook, or the
> EventDispatcher service?
Re: Any way to know when bundles are started? [message #545183 is a reply to message #544854] Wed, 07 July 2010 01:36 Go to previous messageGo to next message
Randy Hudson is currently offline Randy HudsonFriend
Messages: 123
Registered: July 2009
Senior Member
Thanks! And one last thing. If I'm not adding the listener directly in my Activator's start(BundleContext context), then it's possible that this event has already come and gone. So is there a "pull" mechanism to query whether or not the "framework" has already published the "STARTED" event?
Re: Any way to know when bundles are started? [message #545430 is a reply to message #545183] Wed, 07 July 2010 17:45 Go to previous messageGo to next message
Andrew Niefer is currently offline Andrew NieferFriend
Messages: 990
Registered: July 2009
Senior Member
You can probably check StartLevel#getStartLevel() and compare it to
BundleContext.getProperty("osgi.startLevel")

Randy Hudson wrote:

> Thanks! And one last thing. If I'm not adding the listener directly in
> my Activator's start(BundleContext context), then it's possible that this
> event has already come and gone. So is there a "pull" mechanism to query
> whether or not the "framework" has already published the "STARTED" event?
Re: Any way to know when bundles are started? [message #545496 is a reply to message #545430] Thu, 08 July 2010 04:22 Go to previous message
Randy Hudson is currently offline Randy HudsonFriend
Messages: 123
Registered: July 2009
Senior Member
Andrew Niefer wrote on Wed, 07 July 2010 13:45
You can probably check StartLevel#getStartLevel() and compare it to
BundleContext.getProperty("osgi.startLevel")



When my bundle is starting,
getStartLevel() returns 4,
context.getProperty("osgi.bundles.defaultStartLevel") returns 4 too.

But, when the event type STARTED is fired, getStartLevel() returns 6, (as set by EclipseStarter). It seems like getStartLevel() returns the current level obtained, not the target level. "osgi.startLevel" is on FrameworkProperties, but that's an eclipse internal class.
Previous Topic:My editor is filtered out during junit test, any ideas why?
Next Topic:Include one directory from one java project into current project
Goto Forum:
  


Current Time: Thu Apr 25 09:08:53 GMT 2024

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

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

Back to the top