Great idea...that i previously tried ;-).
Unfortunately, I need also stuff from other bundles...which may have been
shut down in the meantime.
Therefore, I need to intervene a bit earlier in the shutdown process.
Up to now, the most satisfying found solution is this one:
public class StatsPersister implements Processor {
// Injected by Spring
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
bundleContext.addBundleListener( new MyBundleListener() );
}
public void persistStats() {
...
}
/**
* Shutdown hook
* We catch the STOPPING event of the felix framework OSGI bundle
* (which is hopefully the very first bundle that is shut down :-D)
*/
private class MyBundleListener implements SynchronousBundleListener {
public void bundleChanged(BundleEvent event) {
if ( event.getType()==BundleEvent.STOPPING &&
"org.apache.felix.framework".equals(
event.getBundle().getSymbolicName() ) ) {
persistStats();
}
}
}
}
Bernard.
--
View this message in context:
http://camel.465427.n5.nabble.com/Access-camel-context-from-BundleActivator-stop-tp5722376p5722395.html
Sent from the Camel - Users mailing list archive at Nabble.com.