On Fri, Sep 20, 2013 at 10:42 AM, Frizz <[email protected]> wrote: > Hi there, > > I made a SynchronousBundleListener listening for bundle 0 to detect when > the container shuts down, because I want to do some cleanup stuff before.
When the framework shuts down, each bundle will be deactivated first. Anything that your bundle has created can be cleaned up by that bundles BundleActivator.stop() method. There is no need to use a BundleListener for this. As for the framework itself... it is already quite capable of cleaning up its own resources, so there is nothing you need to do here. > > In theory this works. > > Problem is: There are lots of other bundles that use the same "technique" > (like Camel, Blueprint, etc.). And their SynchronousBundleListeners are > called before mine is called. > > At the time my SynchronousBundleListener is called a lot of the > functionality that I need is already gone. > > It seems the only way to "control" the order in which > SynchronousBundleListenes are called is via the bundle start level (e.g. > etc/startup.properties). No. Start level only controls the start ordering of the bundles. It has no impact on BundleListeners. > > 1) I would have expected that SynchronousBundleListenes are called in LIFO, > like bundles with a high bundle start level are removed first when then > container shuts down. But that's not the case. > > Imho that's a bug. What do you think? No it's not a bug. > > > 2) It would be nice to have something like in Apache CXF: addBefore() and > addAfter() to control the order in which SynchronousBundleListenes are > called. I'm very unclear why you need this. It sounds like you are trying to create an extremely fragile system if it requires listeners from multiple modules to be called in a specific order. There is really no way to enforce this except by sacrificing modularity, i.e. by creating some kind of "God bundle" that controls all the others. Regards, Neil > > cheers, > F. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

