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

Reply via email to