liugang created CXF-4870:
----------------------------

             Summary: osgi field is always false when creating a SpringBus via 
SpringBusFactory in OSGI ENV
                 Key: CXF-4870
                 URL: https://issues.apache.org/jira/browse/CXF-4870
             Project: CXF
          Issue Type: Bug
          Components: OSGi
    Affects Versions: 2.7.3
            Reporter: liugang


when using following code to create Camel CXF endpoint bus:
{code}
SpringCamelContext springCamelContext = (SpringCamelContext) context;
ApplicationContext applicationContext = 
springCamelContext.getApplicationContext();
busFactory = new SpringBusFactory(applicationContext);
busFactory.createBus();
{code}
after deployed into Karaf, some extension can't be loaded.

I checked the source code, the *osgi* flag of *SpringBeanLocator* is always 
false, because the *context* is an instanceof *BusApplicationContext* (created 
in method *createApplicationContext()* of SpringBusFactory), and it has no 
*getBundleContext* method.

and in *OSGIBusListener* class, only when registered *ConfiguredBeanLocator* 
object is an instanceof *ExtensionManagerImpl*, the *OSGiBeanLocator* will be 
used:
{code}
    private void registerConfiguredBeanLocator() {
        final ConfiguredBeanLocator cbl = 
bus.getExtension(ConfiguredBeanLocator.class);
        if (cbl instanceof ExtensionManagerImpl) {
            // wire in the OSGi things
            bus.setExtension(new OSGiBeanLocator(cbl, defaultContext), 
                             ConfiguredBeanLocator.class);
        }
    }
{code}

and *SpringBeanLocator* is not an instanceof *ExtensionManagerImpl*, so we 
can't load the extensions in OSGI ENV.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to