Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » HowTo change order of bundle stop
HowTo change order of bundle stop [message #63778] Wed, 22 March 2006 14:22 Go to next message
Eclipse UserFriend
Originally posted by: yavin.gmx.com

Hello everybody,

I have several bundles all of them hold a ServiceTracker to a
LogService. If I shutdown the framework the logger is the first bundle
that is stopped. This is bad for me because all following log messages
go only to system.out and are mot formatted.

Is there any chance to change the order of a shutdown?

Regards, Kai
Re: HowTo change order of bundle stop [message #63804 is a reply to message #63778] Wed, 22 March 2006 15:06 Go to previous messageGo to next message
Jeremy Volkman is currently offline Jeremy VolkmanFriend
Messages: 14
Registered: July 2009
Junior Member
You could write your own system shutdown bundle. Have it loop through all
of the installed bundles and stop them in whichever order you need to. In
your case, you could stop all bundles other than the logging bundle and
the system bundle (0). Once all of the bundles are stopped, stop your
logging bundle, and then sto p the system bundle to shutdown the framework.
Re: HowTo change order of bundle stop [message #63827 is a reply to message #63804] Wed, 22 March 2006 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yavin.gmx.com

> You could write your own system shutdown bundle. Have it loop through
> all of the installed bundles and stop them in whichever order you need
> to. In your case, you could stop all bundles other than the logging
> bundle and the system bundle (0). Once all of the bundles are stopped,
> stop your logging bundle, and then sto p the system bundle to shutdown
> the framework.

Thanks, but how/where to start? Is this documented?
Re: HowTo change order of bundle stop [message #63894 is a reply to message #63778] Thu, 23 March 2006 02:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

That seems like a bug to me. If it's starting bundles, it does them to ensure that the bundles that are started in the appropriate order. I'd have expected the same to be true in reverse.

How is your logging bundle related to the other bundles? If there's a direct bundle dependency, I'd expect not to see this. If there's an indirect dependency (by services) then perhaps this could be an issue.

Alex.
Re: HowTo change order of bundle stop [message #63916 is a reply to message #63894] Thu, 23 March 2006 07:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yavin.gmx.com

> How is your logging bundle related to the other bundles? If there's a direct bundle dependency, I'd expect not to see this. If there's an indirect dependency (by services) then perhaps this could be an issue.

It's an indirect dependency because I register the logger as
org.osgi.service.log.LogService at the framework and depending bundles
get that service from the framework.

I thought about a solution with service trackers. If a bundle holds an
instance of a service, the bundle that manages this instance should be
stopped after all references are gone (all service trackers closed).
Does the framework care about service references?
Re: HowTo change order of bundle stop [message #63937 is a reply to message #63916] Thu, 23 March 2006 08:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: yavin.gmx.com

Kai schrieb:
> I thought about a solution with service trackers. If a bundle holds an
> instance of a service, the bundle that manages this instance should be
> stopped after all references are gone (all service trackers closed).
> Does the framework care about service references?

The OSGI R4 spec says the following:

5.2.1 Service References
....
A ServiceReference object is valid only as long as the service object is
registered. However, its properties must remain available as long as the
ServiceReference object exists.

5.2.9 Getting Service Objects
The BundleContext object is used to obtain the actual service object so
that the Framework can manage dependencies. If a bundle retrieves a
service object, that bundle becomes dependent upon the life cycle of
that registered service object.
....

IMHO based on this spec the framework have to care about the life cycle
dependencies of a service. Am I wrong?
Re: HowTo change order of bundle stop [message #63960 is a reply to message #63778] Thu, 23 March 2006 09:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: neil.integility.com

Kai,

Have you tried using the framework Start Level facility?

If you start your logging bundle at a low start level, eg 1, and the other
bundles at a higher start level, then the logging bundle will be
deactivated towards the end of the shutdown. This is because the framework
is supposed to shutdown by decreasing the start level one point at a time
until it gets to zero.

You can control the start level of your bundles using the osgi.bundles
property in config.ini, eg:

osgi.bundles=<standard_bundles>,org.kai.logging@1:start,org.kai.another_bundle@2

Regards
Neil
Re: HowTo change order of bundle stop [message #63983 is a reply to message #63960] Thu, 23 March 2006 09:58 Go to previous message
Eclipse UserFriend
Originally posted by: yavin.gmx.com

> Have you tried using the framework Start Level facility?

No I didn't! Oh man thanks for that hint, sometimes I'm a little bit
stupid. :-D
Previous Topic:Platform
Next Topic:EclipseClassLoader, Bundle start and Threading
Goto Forum:
  


Current Time: Thu Apr 25 02:06:41 GMT 2024

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

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

Back to the top