Willem.Jiang wrote
> Did you create the camel context in the BundleActivator or using
> Blueprint, Spring to create the camel context?

It is created using Spring,
(but my osgi bundle activator is registered through the manifest, not by
Spring)


Willem.Jiang wrote
> Why do you need to access the camel context when the bundle is stop?

Because upon shutdown, I need to persist some statistics into a database.
And this persistency job is provided by Spring beans (dao and service - in
the Spring meaning, not osgi - implementations).
eg:

ServiceReference[] references = 
bundleContext.getServiceReferences(CamelContext.class.getName(), null); 
CamelContext cc = null; 
if ( references != null && references.length>0 ) { 
  cc = (CamelContext) bundleContext.getService(references[0]);
  MySpringBean bean = Pcc.getRegistry().lookup("myBean",
MySpringBean.class); 
  bean.persistStats();
}

So the question is: where can we place some "finalization" work when a camel
context context (created by Spring) is shut down ? Note that as that work is
delegating most of a job to spring beans, all these beans must not be
deregistered yet. In that sense, it is more a "*before*-shutdown" hook that
we really need in my case...






--
View this message in context: 
http://camel.465427.n5.nabble.com/Access-camel-context-from-BundleActivator-stop-tp5722376p5722381.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to