camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r979644 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/jaxrs/ test/java/org/apache/camel/component/cxf/ test/java/org/apache/camel/component/cxf/jaxrs/
Date Tue, 27 Jul 2010 11:23:27 GMT
Author: ningjiang
Date: Tue Jul 27 11:23:27 2010
New Revision: 979644

URL: http://svn.apache.org/viewvc?rev=979644&view=rev
Log:
CAMEL-2997 Made camel-cxfrs endpoint's URI to be unique

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java

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=979644&r1=979643&r2=979644&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 Jul 27 11:23:27 2010
@@ -106,8 +106,8 @@ public class CxfEndpoint extends Default
         setAddress(remaining);
     }
     
-    // This path is for CxfComponent setting the EndpointUri
-    void updateEndpointUri(String endpointUri) {
+    // This method is for CxfComponent setting the EndpointUri
+    protected void updateEndpointUri(String endpointUri) {
         super.setEndpointUri(endpointUri);
     }
 

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java?rev=979644&r1=979643&r2=979644&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsComponent.java
Tue Jul 27 11:23:27 2010
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.component.cxf.CxfConstants;
+import org.apache.camel.component.cxf.CxfEndpoint;
 import org.apache.camel.impl.HeaderFilterStrategyComponent;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.CastUtils;
@@ -74,4 +75,10 @@ public class CxfRsComponent extends Head
         setEndpointHeaderFilterStrategy(answer);
         return answer;
     }
+    
+    @Override
+    protected void afterConfiguration(String uri, String remaining, Endpoint endpoint, Map<String,
Object> parameters) throws Exception {
+        CxfRsEndpoint cxfRsEndpoint = (CxfRsEndpoint) endpoint;
+        cxfRsEndpoint.updateEndpointUri(uri);
+    }
 }

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java?rev=979644&r1=979643&r2=979644&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
Tue Jul 27 11:23:27 2010
@@ -45,15 +45,23 @@ public class CxfRsEndpoint extends Defau
     private HeaderFilterStrategy headerFilterStrategy;
     private CxfRsBinding binding;
     private boolean httpClientAPI = true;
+    private String address;
 
     private AtomicBoolean bindingInitialized = new AtomicBoolean(false);
     
     public CxfRsEndpoint(String endpointUri, CamelContext camelContext) {
-       super(endpointUri, camelContext);
+        super(endpointUri, camelContext);
+        setAddress(endpointUri);
     }
     
     public CxfRsEndpoint(String endpointUri, Component component) {
         super(endpointUri, component);
+        setAddress(endpointUri);
+    }
+    
+    // This method is for CxfRsComponent setting the EndpointUri
+    protected void updateEndpointUri(String endpointUri) {
+        super.setEndpointUri(endpointUri);
     }
     
     public void setParameters(Map<String, String> param) {
@@ -130,14 +138,14 @@ public class CxfRsEndpoint extends Defau
     
     protected void setupJAXRSServerFactoryBean(JAXRSServerFactoryBean sfb) {        
         // address
-        sfb.setAddress(getEndpointUri());
+        sfb.setAddress(getAddress());
         sfb.setResourceClasses(CastUtils.cast(getResourceClasses(), Class.class));
         sfb.setStart(false);
     }
     
     protected void setupJAXRSClientFactoryBean(JAXRSClientFactoryBean cfb) {        
         // address
-        cfb.setAddress(getEndpointUri());
+        cfb.setAddress(getAddress());
         if (getResourceClasses() != null) {
             cfb.setResourceClass(getResourceClasses().get(0));
         }    
@@ -167,4 +175,12 @@ public class CxfRsEndpoint extends Defau
         setResourceClasses(Arrays.asList(classes));
     }
 
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
 }

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java?rev=979644&r1=979643&r2=979644&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerStartTwiceTest.java
Tue Jul 27 11:23:27 2010
@@ -49,7 +49,7 @@ public class CxfConsumerStartTwiceTest e
             fail("Expect to catch an exception here");
         } catch (Exception ex) {
             assertTrue(ex.getMessage().endsWith(
-                "Multiple consumers for the same endpoint is not allowed: Endpoint[cxf:http://localhost:7070/test?serviceClass=org.apache.camel.component.cxf.HelloService]"));
+                "Multiple consumers for the same endpoint is not allowed: Endpoint[cxf://http://localhost:7070/test?serviceClass=org.apache.camel.component.cxf.HelloService]"));
         }
                 
         context.stop();

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java?rev=979644&r1=979643&r2=979644&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointTest.java
Tue Jul 27 11:23:27 2010
@@ -24,13 +24,14 @@ public class CxfRsEndpointTest extends C
     
     @Test
     public void testCreateCxfRsEndpoint() throws Exception {
-        CxfRsComponent component = new CxfRsComponent(context);
-        CxfRsEndpoint endpoint = (CxfRsEndpoint)component.createEndpoint("cxfrs://http://localhost:9000"
+        String endpointUri = "cxfrs://http://localhost:9000"
             + "?resourceClasses=org.apache.camel.component.cxf.jaxrs.testbean.CustomerService,
"
-            + "java.lang.String ; org.apache.camel.component.cxf.jaxrs.testbean.Order");
+            + "java.lang.String ; org.apache.camel.component.cxf.jaxrs.testbean.Order";
+        CxfRsComponent component = new CxfRsComponent(context);
+        CxfRsEndpoint endpoint = (CxfRsEndpoint)component.createEndpoint(endpointUri);
         
         assertNotNull("The endpoint should not be null ", endpoint);
-        assertEquals("Get a wrong address ", "http://localhost:9000", endpoint.getEndpointUri());
+        assertEquals("Get a wrong address ", endpointUri, endpoint.getEndpointUri());
         assertEquals("Get a wrong size of resouces classes", 3, endpoint.getResourceClasses().size());
         assertEquals("Get a wrong resources class", CustomerService.class, endpoint.getResourceClasses().get(0));
     }
@@ -41,7 +42,7 @@ public class CxfRsEndpointTest extends C
         CxfRsEndpoint endpoint = (CxfRsEndpoint)component.createEndpoint("cxfrs://http://localhost:9000/templatetest/TID/ranges/start=0;end=1?"
             + "httpClientAPI=true&q1=11&q2=12");
         
-        assertEquals("Get a wrong URI ", "http://localhost:9000/templatetest/TID/ranges/start=0;end=1",
endpoint.getEndpointUri());
+        assertEquals("Get a wrong URI ", "cxfrs://http://localhost:9000/templatetest/TID/ranges/start=0;end=1?httpClientAPI=true&q1=11&q2=12",
endpoint.getEndpointUri());
         assertEquals("Get a wrong usingClientAPI option", true, endpoint.isHttpClientAPI());
         assertNotNull("The Parameter should not be null" + endpoint.getParameters());
         assertEquals("Get a wrong parameter map", "{q1=11, q2=12}", endpoint.getParameters().toString());

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java?rev=979644&r1=979643&r2=979644&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
Tue Jul 27 11:23:27 2010
@@ -39,6 +39,16 @@ public class CxfRsRouterTest extends Cam
         return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsSpringRouter.xml");
     }
     
+    @Test 
+    public void testEndpointUris() throws Exception {
+        CxfRsEndpoint cxfRsEndpoint = context.getEndpoint("cxfrs://bean://rsServer", CxfRsEndpoint.class);
+        assertEquals("Get a wrong endpoint uri", "cxfrs://bean://rsServer", cxfRsEndpoint.getEndpointUri());
+        
+        cxfRsEndpoint = context.getEndpoint("cxfrs://bean://rsClient", CxfRsEndpoint.class);
+        assertEquals("Get a wrong endpoint uri", "cxfrs://bean://rsClient", cxfRsEndpoint.getEndpointUri());
+        
+    }
+    
     @Test
     public void testGetCustomer() throws Exception {      
         HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123");



Mime
View raw message