Honestly, this isn't a use case we've ever really needed/considered. In the OSGi cases, we've always expected the container to pretty much create the appropriate context (Spring or Blueprint) and the Bus would be created and loaded by that context.
Most likely, you'd need to do something like create the Bus, grab the ConfiguredBeanLocator extension, wrapper it with a new one (likely use the Blueprint one as a starting point) that would delegate to the original instance as well as check the context, and set that back on the Bus. Dan On Mar 4, 2013, at 2:05 AM, liugang <[email protected]> wrote: > When I developed a camel route with spring configuration and cxf component > inside , and deployed into Karaf. > > > > I always got some exceptions when I'm trying to get some extensions, for > example, bus.getExtension(**Extension.class) > > > > I checked the code , the problem is caused by > org.apache.cxf.bus.spring.SpringBeanLocator. > > > > I'm not sure, this class should be improved or not. In below method: > > > > private void loadOSGIContext(Bus b) { > > try { > > //use a little reflection to allow this to work without the > spring-dm jars > > //for the non-osgi cases > > Method m = context.getClass().getMethod("getBundleContext"); > > bundleContext = m.invoke(context); > > if (b != null) { > > @SuppressWarnings("unchecked") > > Class<Object> cls = (Class<Object>)m.getReturnType(); > > b.setExtension(bundleContext, cls); > > } > > } catch (Throwable t) { > > //ignore > > osgi = false; > > } > > } > > > > The context object is always a BusApplicationContext, and it doen's have the > getBundleContext() method. > > > > And also in setApplicationContext() method of SpringBus class: > > > > ConfiguredBeanLocator loc = > getExtension(ConfiguredBeanLocator.class); > > if (!(loc instanceof SpringBeanLocator)) { > > setExtension(new SpringBeanLocator(applicationContext, this), > ConfiguredBeanLocator.class); > > } > > > > But in BluePrintBus, it's: > > setExtension(new > BlueprintBeanLocator(getExtension(ConfiguredBeanLocator.class), container, > context), > > ConfiguredBeanLocator.class); > > This one is ok for me. > > > > So I'd like to know it's a problem of SpringBus? Or I lost some > configuration? > > > > Thanks > > GangLiu > -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
