camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject svn commit: r1167458 - in /camel/branches/camel-2.8.x: ./ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/ components/camel-cxf/src/test/java/org/apache/camel/co...
Date Sat, 10 Sep 2011 05:08:28 GMT
Author: wtam
Date: Sat Sep 10 05:08:28 2011
New Revision: 1167458

URL: http://svn.apache.org/viewvc?rev=1167458&view=rev
Log:
Merged revisions 1167448 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1167448 | wtam | 2011-09-09 23:23:25 -0400 (Fri, 09 Sep 2011) | 1 line
  
  [CAMEL-4436] CxfRsProducer clientFactoryBean's bus should be initialized
........

Added:
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
      - copied, changed from r1167448, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/Bethal.jks
      - copied unchanged from r1167448, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/Bethal.jks
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml
      - copied, changed from r1167448, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml
      - copied unchanged from r1167448, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest2.xml
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/Morpit.jks
      - copied unchanged from r1167448, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/Morpit.jks
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/Truststore.jks
      - copied unchanged from r1167448, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/Truststore.jks
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Sep 10 05:08:28 2011
@@ -1 +1 @@
-/camel/trunk:1148706,1148710,1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157749,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395,1163231,1163420,1164557,1164633,1164973-1165000,1165152,1165157,1165658,1165971,1165987,1167098
+/camel/trunk:1148706,1148710,1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157749,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395,1163231,1163420,1164557,1164633,1164973-1165000,1165152,1165157,1165658,1165971,1165987,1167098,1167448

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1167458&r1=1167457&r2=1167458&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Sat Sep 10 05:08:28 2011
@@ -43,7 +43,6 @@ import org.apache.camel.impl.DefaultEndp
 import org.apache.camel.impl.SynchronousDelegateProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
-import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.cxf.Bus;
@@ -72,7 +71,6 @@ import org.apache.cxf.service.model.Bind
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
 
 /**
  * Defines the <a href="http://camel.apache.org/cxf.html">CXF Endpoint</a>.
@@ -290,19 +288,6 @@ public class CxfEndpoint extends Default
         };
     }
 
-    protected Bus doGetBus() {
-        BusFactory busFactory = BusFactory.newInstance();
-        // need to check if the camelContext is SpringCamelContext and
-        // update the bus configuration with the applicationContext
-        // which SpringCamelContext holds
-        if (getCamelContext() instanceof SpringCamelContext) {
-            SpringCamelContext springCamelContext = (SpringCamelContext) getCamelContext();
-            ApplicationContext applicationContext = springCamelContext.getApplicationContext();
-            busFactory = new org.apache.cxf.bus.spring.SpringBusFactory(applicationContext);
-        }
-        return busFactory.createBus();
-    }
-
     /**
      * Populate a client factory bean
      */
@@ -629,7 +614,7 @@ public class CxfEndpoint extends Default
 
     public Bus getBus() {
         if (bus == null) {
-            bus = doGetBus();
+            bus = CxfEndpointUtils.createBus(getCamelContext());
             LOG.debug("Using DefaultBus {}", bus);
         }
 

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java?rev=1167458&r1=1167457&r2=1167458&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpointUtils.java
Sat Sep 10 05:08:28 2011
@@ -22,17 +22,23 @@ import javax.jws.WebService;
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceProvider;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.CamelException;
 import org.apache.camel.Exchange;
 import org.apache.camel.component.cxf.common.message.CxfConstants;
 import org.apache.camel.component.cxf.util.WSDLSoapServiceFactoryBean;
+import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
 
 public final class CxfEndpointUtils {
     private static final Logger LOG = LoggerFactory.getLogger(CxfEndpointUtils.class);
@@ -170,6 +176,24 @@ public final class CxfEndpointUtils {
         }
         return retval;
     }
+    
+    /**
+     * Create a CXF bus with either BusFactory or SpringBusFactory if Camel Context
+     * is SpringCamelContext.  In the latter case, this method updates the bus 
+     * configuration with the applicationContext which SpringCamelContext holds 
+     * 
+     * @param context - the Camel Context
+     */
+    public static Bus createBus(CamelContext context) {
+        BusFactory busFactory = BusFactory.newInstance();
+
+        if (context instanceof SpringCamelContext) {
+            SpringCamelContext springCamelContext = (SpringCamelContext) context;
+            ApplicationContext applicationContext = springCamelContext.getApplicationContext();
+            busFactory = new SpringBusFactory(applicationContext);
+        }
+        return busFactory.createBus();
+    }
 }
 
 

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java?rev=1167458&r1=1167457&r2=1167458&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
Sat Sep 10 05:08:28 2011
@@ -28,9 +28,12 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.cxf.spring.SpringJAXRSClientFactoryBean;
 import org.apache.camel.component.cxf.spring.SpringJAXRSServerFactoryBean;
+import org.apache.camel.component.cxf.CxfEndpointUtils;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -40,6 +43,8 @@ import org.slf4j.LoggerFactory;
 public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware {
     private static final Logger LOG = LoggerFactory.getLogger(CxfRsEndpoint.class);
 
+    protected Bus bus;
+
     private Map<String, String> parameters;
     private List<Class<?>> resourceClasses;
     private HeaderFilterStrategy headerFilterStrategy;
@@ -50,6 +55,9 @@ public class CxfRsEndpoint extends Defau
     private int maxClientCacheSize = 10;
     
     private AtomicBoolean bindingInitialized = new AtomicBoolean(false);
+    private AtomicBoolean getBusHasBeenCalled = new AtomicBoolean(false);
+
+	private boolean isSetDefaultBus;
 
     public CxfRsEndpoint(String endpointUri, CamelContext camelContext) {
         super(endpointUri, camelContext);
@@ -205,4 +213,29 @@ public class CxfRsEndpoint extends Defau
     public int getMaxClientCacheSize() {
         return maxClientCacheSize;
     }
+    
+    public void setBus(Bus bus) {
+        this.bus = bus;
+    }
+
+    public Bus getBus() {
+        if (bus == null) {
+            bus = CxfEndpointUtils.createBus(getCamelContext());
+            LOG.debug("Using DefaultBus {}", bus);
+        }
+
+        if (!getBusHasBeenCalled.getAndSet(true) && isSetDefaultBus) {
+            BusFactory.setDefaultBus(bus);
+            LOG.debug("Set bus {} as thread default bus", bus);
+        }
+        return bus;
+    }
+    
+    public void setSetDefaultBus(boolean isSetDefaultBus) {
+        this.isSetDefaultBus = isSetDefaultBus;
+    }
+
+    public boolean isSetDefaultBus() {
+        return isSetDefaultBus;
+    }
 }

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java?rev=1167458&r1=1167457&r2=1167458&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
Sat Sep 10 05:08:28 2011
@@ -87,6 +87,7 @@ public class CxfRsProducer extends Defau
         JAXRSClientFactoryBean cfb = clientFactoryBeanCache.get(CxfEndpointUtils
             .getEffectiveAddress(exchange, ((CxfRsEndpoint)getEndpoint()).getAddress()));
         
+        cfb.setBus(((CxfRsEndpoint)getEndpoint()).getBus());
         WebClient client = cfb.createWebClient();
         String httpMethod = inMessage.getHeader(Exchange.HTTP_METHOD, String.class);
         Class responseClass = inMessage.getHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS,
Class.class);

Copied: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
(from r1167448, camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java?p2=camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java&p1=camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java&r1=1167448&r2=1167458&rev=1167458&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest.java
Sat Sep 10 05:08:28 2011
@@ -22,10 +22,10 @@ import org.apache.camel.ExchangePattern;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.cxf.CXFTestSupport;
 import org.apache.camel.component.cxf.common.message.CxfConstants;
 import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -37,7 +37,10 @@ import org.springframework.context.suppo
  *
  */
 public class CxfRsProducerClientFactoryCacheTest extends Assert {
-    private static int port1 = CXFTestSupport.getPort1(); 
+    private static int port1 = AvailablePortFinder.getNextAvailable(); 
+    static {
+        System.setProperty("CxfRsProducerClientFactoryCacheTest.port1", Integer.toString(port1));
+    }
     
     private CamelContext context1;
     private CamelContext context2;

Copied: camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml
(from r1167448, camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml?p2=camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml&p1=camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml&r1=1167448&r2=1167458&rev=1167458&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsProducerClientFactoryCacheTest1.xml
Sat Sep 10 05:08:28 2011
@@ -28,7 +28,7 @@
   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
 
   <jaxrs:server id="restService"
-		        address="http://localhost:${CXFTestSupport.port1}/CxfRsProducerTest/" 
+		        address="http://localhost:${CxfRsProducerClientFactoryCacheTest.port1}/CxfRsProducerTest/"

 		        staticSubresourceResolution="true">
     <jaxrs:serviceBeans>
       <ref bean="customerService"/>
@@ -37,7 +37,7 @@
   
   <bean id="customerService" class="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"
/>
    
-  <cxf:rsClient id="rsClientHttp" address="http://localhost:${CXFTestSupport.port1}/CxfRsProducerTest/"/>
+  <cxf:rsClient id="rsClientHttp" address="http://localhost:${CxfRsProducerClientFactoryCacheTest.port1}/CxfRsProducerTest/"/>
 
   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
     <route>



Mime
View raw message