oh, after checking the code , the SpringBusFactory is calling the same method of BusFactory, I think we don't need to change the code now :)

Willem

Willem Jiang wrote:
No, I don't think the "setDefaultBus" is meaningless.
As the setDefaultBus just want to pass the Bus reference to the other component, all though the createBus method will try to set DefaultBus if the defaultBus is not set , but the "setDefaultBus" will make sure the default bus reference is updated.

You made a well spot of CxfEndpoint, we should not assume the SpringBusFactory is working there. I will do a quick fix for that.


Willem

William Tam wrote:
HI Willem,

What is the implication of always creating a new Bus in doGetBus()?
There is an set "setDefaultBus" option in CXF endpoint.  Does the
"setDefaultBus" becomes meaningless now?  If so, should we deprecate
this option?

In CxfEndpoint which is not Spring aware, is it safe to create a Bus
by calling the SpringBusFactory?

Thanks,
William




Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=883625&r1=883624&r2=883625&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Tue Nov 24 08:54:16 2009
@@ -40,6 +40,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.endpoint.Client;
@@ -189,7 +190,7 @@
    }

    protected Bus doGetBus() {
-        return BusFactory.getThreadDefaultBus();
+        return SpringBusFactory.newInstance().createBus();
    }

    /**

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java?rev=883625&r1=883624&r2=883625&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanDefinitionParser.java Tue Nov 24 08:54:16 2009
@@ -24,8 +24,8 @@
 import org.w3c.dom.Element;

 import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -33,8 +33,6 @@
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;

-
-
public class CxfEndpointBeanDefinitionParser extends AbstractCxfBeanDefinitionParser {

    @Override
@@ -93,7 +91,8 @@
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
            applicationContext = ctx;
            if (getBus() == null) {
-                Bus bus = BusFactory.getThreadDefaultBus();
+                // Don't relate on the DefaultBus
+                Bus bus = SpringBusFactory.newInstance().createBus();
                setBus(bus);
            }
BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(getBus(), ctx);

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsClientFactoryBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsClientFactoryBeanDefinitionParser.java?rev=883625&r1=883624&r2=883625&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsClientFactoryBeanDefinitionParser.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsClientFactoryBeanDefinitionParser.java Tue Nov 24 08:54:16 2009
@@ -25,6 +25,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -81,7 +82,8 @@

public void setApplicationContext(ApplicationContext ctx) throws BeansException {
            if (getBus() == null) {
-                Bus bus = BusFactory.getThreadDefaultBus();
+                // Don't relate on the DefaultBus
+                Bus bus = SpringBusFactory.newInstance().createBus();
BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
                setBus(bus);
            }

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsServerFactoryBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsServerFactoryBeanDefinitionParser.java?rev=883625&r1=883624&r2=883625&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsServerFactoryBeanDefinitionParser.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfRsServerFactoryBeanDefinitionParser.java Tue Nov 24 08:54:16 2009
@@ -26,6 +26,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
 import org.apache.cxf.jaxrs.model.UserResource;
@@ -98,7 +99,8 @@

public void setApplicationContext(ApplicationContext ctx) throws BeansException {
            if (getBus() == null) {
-                Bus bus = BusFactory.getThreadDefaultBus();
+                // Don't relate on the DefaultBus
+                Bus bus = SpringBusFactory.newInstance().createBus();
BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx);
                setBus(bus);
            }







Reply via email to