camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1186840 - 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/blueprint/ components/camel-cxf/src/main/java/org/apache/came...
Date Thu, 20 Oct 2011 14:54:08 GMT
Author: ningjiang
Date: Thu Oct 20 14:54:08 2011
New Revision: 1186840

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

........
  r1186625 | ningjiang | 2011-10-20 14:16:04 +0800 (Thu, 20 Oct 2011) | 1 line
  
  CAMEL-4561 CxfComponent should create a new CxfEndpoint instance if the instance is lookup
from configuration registry
........
  r1186772 | ningjiang | 2011-10-20 20:49:55 +0800 (Thu, 20 Oct 2011) | 1 line
  
  CAMEL-4561 set the bean scope to be prototype
........

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/CxfComponent.java
    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/blueprint/AbstractBeanDefinitionParser.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 20 14:54:08 2011
@@ -1 +1 @@
-/camel/trunk:1186106
+/camel/trunk:1186106,1186625,1186772

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/CxfComponent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java?rev=1186840&r1=1186839&r2=1186840&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
Thu Oct 20 14:54:08 2011
@@ -68,10 +68,11 @@ public class CxfComponent extends Header
             }
 
             result = CamelContextHelper.mandatoryLookup(getCamelContext(), beanId, CxfEndpoint.class);
-            // need to set the CamelContext value 
-            if (result.getCamelContext() == null) {
+            // need to check the CamelContext value 
+            if (getCamelContext().equals(result.getCamelContext())) {
                 result.setCamelContext(getCamelContext());
             }
+            
         } else {
             // endpoint URI does not specify a bean
             result = new CxfEndpoint(remaining, this);

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=1186840&r1=1186839&r2=1186840&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
Thu Oct 20 14:54:08 2011
@@ -39,6 +39,7 @@ import org.apache.camel.CamelException;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.Service;
 import org.apache.camel.component.cxf.common.header.CxfHeaderFilterStrategy;
 import org.apache.camel.component.cxf.common.message.CxfConstants;
@@ -95,7 +96,7 @@ import org.slf4j.LoggerFactory;
  * {@link CxfBinding}, and {@link HeaderFilterStrategy}.  The default DataFormat
  * mode is {@link DataFormat#POJO}.
  */
-public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware, Service
{
+public class CxfEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware, Service,
Cloneable {
 
     private static final Logger LOG = LoggerFactory.getLogger(CxfEndpoint.class);
 
@@ -162,6 +163,14 @@ public class CxfEndpoint extends Default
     public CxfEndpoint() {
         super();
     }
+    
+    public CxfEndpoint copy() {
+        try {
+            return (CxfEndpoint)this.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
 
     // This method is for CxfComponent setting the EndpointUri
     protected void updateEndpointUri(String endpointUri) {

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/AbstractBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/AbstractBeanDefinitionParser.java?rev=1186840&r1=1186839&r2=1186840&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/AbstractBeanDefinitionParser.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/blueprint/AbstractBeanDefinitionParser.java
Thu Oct 20 14:54:08 2011
@@ -48,6 +48,8 @@ public class AbstractBeanDefinitionParse
         answer.setRuntimeClass(runtimeClass);
         answer.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
         answer.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
+        // set the Bean scope to be prototype, so we can get a new instance per looking up
+        answer.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
         
         if (!StringUtils.isEmpty(getIdOrName(element))) {
             answer.setId(getIdOrName(element));

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser.java?rev=1186840&r1=1186839&r2=1186840&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/AbstractCxfBeanDefinitionParser.java
Thu Oct 20 14:54:08 2011
@@ -23,6 +23,7 @@ import org.apache.cxf.common.util.String
 import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser;
 import org.springframework.beans.PropertyValue;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
@@ -57,7 +58,9 @@ public abstract class AbstractCxfBeanDef
         bean.setLazyInit(false);
         // put the bean id into the property map
         Map<String, Object> map = getPropertyMap(bean, true);
-        map.put("beanId", resolveId(element, bean.getBeanDefinition(), ctx));        
+        map.put("beanId", resolveId(element, bean.getBeanDefinition(), ctx));
+        // set the bean scope to be prototype, then we can get a new instance in each look
up 
+        bean.setScope(BeanDefinition.SCOPE_PROTOTYPE);
     }
 
     @Override

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java?rev=1186840&r1=1186839&r2=1186840&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
Thu Oct 20 14:54:08 2011
@@ -44,5 +44,4 @@ public class CxfEndpointBeanTest extends
         assertEquals("Got the wrong schemalocations size", 1, routerEndpoint.getSchemaLocations().size());
         assertEquals("Got the wrong schemalocation", "classpath:wsdl/Message.xsd", routerEndpoint.getSchemaLocations().get(0));
     }
-   
 }

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java?rev=1186840&r1=1186839&r2=1186840&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeansRouterTest.java
Thu Oct 20 14:54:08 2011
@@ -41,6 +41,18 @@ public class CxfEndpointBeansRouterTest 
                      "org.apache.camel.component.cxf.HelloService", 
                      routerEndpoint.getServiceClass().getName());
     }
+    
+    @Test
+    public void testCreateCxfEndpointFromURI() {
+        CamelContext camelContext = (CamelContext) ctx.getBean("camel");
+        CxfEndpoint endpoint1 = (CxfEndpoint)
+            camelContext.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:9000/test1");
+        CxfEndpoint endpoint2 = (CxfEndpoint)
+            camelContext.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:8000/test2");
+        assertEquals("Get a wrong endpoint address.", "http://localhost:9000/test1", endpoint1.getAddress());
+        assertEquals("Get a wrong endpoint address.", "http://localhost:8000/test2", endpoint2.getAddress());
+        assertFalse("Get a wrong endpoint key.",  endpoint1.getEndpointKey().equals(endpoint2.getEndpointKey()));
+    }
 
     @Test
     public void testCxfBusConfiguration() throws Exception {



Mime
View raw message