camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem jiang <willem.ji...@gmail.com>
Subject Re: Access camel context from BundleActivator.stop() ?
Date Fri, 09 Nov 2012 07:40:38 GMT
Hi,

Did you create the camel context in the BundleActivator or using Blueprint, Spring to create
the camel context?

Why do you need to access the camel context when the bundle is stop?
 I think  the camel context should be deregistered already.

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: willemjiang





On Friday, November 9, 2012 at 5:29 AM, Bernard Ligny wrote:

> I am trying without success to look for CamelContext inside the stop method
> of a BundleActivator.
>  
>  
> I did follow the instructions of Jean-Baptiste Onofré's Blog ("/When Camel
> is used in an OSGi environment, it automatically exposes CamelContexts as
> OSGi services/"), eg:
>  
> public class MyBundleActivator implements BundleActivator {
>  
> public void stop(BundleContext bundleContext) throws Exception {
> ServiceReference[] references =
> bundleContext.getServiceReferences(CamelContext.class.getName(), null);
> CamelContext cc = null;
> if ( references != null && references.length>0 ) {
> cc = (CamelContext) bundleContext.getService(references[0]);
> }
> }
>  
> }
>  
> but it does not work :-(
> (I am using Camel 2.8.5 , ServiceMix 4.4.2)
>  
> What am i doing wrong ?
> Is it possible that at the time the shutdown hook is called, the camel
> context has been already deregistered ?
> If so, what would be an alternate(*) solution to do some work at bundle stop
> time, using spring beans ?
> (*) rather than getting camel context, and looking for such bean throuhg
> camel registry...
>  
> Thx,
>  
> Bernard.
>  
> Bernard.
>  
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Access-camel-context-from-BundleActivator-stop-tp5722376.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).
>  




Mime
View raw message