camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r995636 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/cxfbean/ main/java/org/apache/camel/component/cxf/feature/ main/java/org/apache/camel/component/cxf/spring/ test/java/org/apache/camel/component/cx...
Date Fri, 10 Sep 2010 01:43:40 GMT
Author: ningjiang
Date: Fri Sep 10 01:43:40 2010
New Revision: 995636

URL: http://svn.apache.org/viewvc?rev=995636&view=rev
Log:
CAMEL-3113 Fixed the issue that @QueryParam doesn't work for CxfBeans

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/DefaultCxfBeanBinding.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBean.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/DefaultCxfBeanBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/DefaultCxfBeanBinding.java?rev=995636&r1=995635&r2=995636&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/DefaultCxfBeanBinding.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/cxfbean/DefaultCxfBeanBinding.java
Fri Sep 10 01:43:40 2010
@@ -59,6 +59,8 @@ public class DefaultCxfBeanBinding imple
         // verb
         String verb = getVerb(camelMessage);
         
+        String queryString = getQueryString(camelMessage);
+        
         if (LOG.isTraceEnabled()) {
             LOG.trace("Processing " + camelExchange + ", requestContentType = " + requestContentType

                     + ", acceptContentTypes = " + acceptContentTypes + ", encoding = " +
enc
@@ -76,6 +78,7 @@ public class DefaultCxfBeanBinding imple
         answer.put(org.apache.cxf.message.Message.CONTENT_TYPE, requestContentType);
         answer.put(org.apache.cxf.message.Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
         answer.put(org.apache.cxf.message.Message.ENCODING, enc);
+        answer.put(org.apache.cxf.message.Message.QUERY_STRING, queryString);
         
         // TODO propagate security context
 
@@ -147,6 +150,11 @@ public class DefaultCxfBeanBinding imple
         String answer = camelMessage.getHeader(Exchange.HTTP_METHOD, String.class);
         return answer;
     }
+    
+    protected String getQueryString(org.apache.camel.Message camelMessage) {
+        String answer = camelMessage.getHeader(Exchange.HTTP_QUERY, String.class);
+        return answer;
+    }
 
     protected String getCharacterEncoding(org.apache.camel.Message camelMessage) {
         String answer = camelMessage.getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class);

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java?rev=995636&r1=995635&r2=995636&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
Fri Sep 10 01:43:40 2010
@@ -23,6 +23,7 @@ import java.util.logging.Logger;
 
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.PhaseInterceptor;
 
 /**
@@ -32,7 +33,7 @@ public abstract class AbstractDataFormat
 
     protected abstract Logger getLogger();
     
-    protected void removeInterceptorWhichIsInThePhases(List<Interceptor> interceptors,
String[] phaseNames) {
+    protected void removeInterceptorWhichIsInThePhases(List<Interceptor<? extends Message>>
interceptors, String[] phaseNames) {
         for (Interceptor i : interceptors) {
             if (i instanceof PhaseInterceptor) {
                 PhaseInterceptor p = (PhaseInterceptor)i;
@@ -47,7 +48,7 @@ public abstract class AbstractDataFormat
         }
     }
 
-    protected void removeInterceptorWhichIsOutThePhases(List<Interceptor> interceptors,
String[] phaseNames) {
+    protected void removeInterceptorWhichIsOutThePhases(List<Interceptor<? extends
Message>> interceptors, String[] phaseNames) {
         for (Interceptor i : interceptors) {
             boolean outside = false;
             if (i instanceof PhaseInterceptor) {
@@ -67,7 +68,7 @@ public abstract class AbstractDataFormat
     }
     
       
-    protected void removeInterceptors(List<Interceptor> interceptors,
+    protected void removeInterceptors(List<Interceptor<? extends Message>> interceptors,
                                       Collection<Class> toBeRemovedInterceptors) {
         for (Interceptor interceptor : interceptors) {
             if (toBeRemovedInterceptors.contains(interceptor.getClass())) {

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBean.java?rev=995636&r1=995635&r2=995636&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBean.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/spring/CxfEndpointBean.java
Fri Sep 10 01:43:40 2010
@@ -19,14 +19,16 @@ package org.apache.camel.component.cxf.s
 import java.util.List;
 
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.frontend.AbstractServiceFactory;
 import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.apache.cxf.wsdl11.WSDLEndpointFactory;
 
 import org.springframework.beans.factory.BeanNameAware;
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.NamedBean;
 
-public class CxfEndpointBean extends AbstractWSDLBasedEndpointFactory
+public class CxfEndpointBean extends AbstractServiceFactory
     implements DisposableBean, BeanNameAware, NamedBean {
     
     private List handlers;
@@ -62,4 +64,5 @@ public class CxfEndpointBean extends Abs
     public String getBeanName() {
         return beanName;
     }
+
 }

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java?rev=995636&r1=995635&r2=995636&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
Fri Sep 10 01:43:40 2010
@@ -68,6 +68,18 @@ public class CxfBeanTest extends Abstrac
         assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", CxfUtils.getStringFromInputStream(in));
         // END SNIPPET: clientInvocation
     }
+    
+    @Test
+    public void testGetConsumerWithQueryParam() throws Exception {
+        URL url = new URL("http://localhost:9000/customerservice/customers?id=123");
+
+        try {
+            InputStream in = url.openStream();
+            assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", CxfUtils.getStringFromInputStream(in));
+        } catch (Exception ex) {
+            Thread.sleep(3000000);
+        }
+    }
 
     @Test
     public void testGetConsumerAfterReStartCamelContext() throws Exception {

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java?rev=995636&r1=995635&r2=995636&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/testbean/CustomerService.java
Fri Sep 10 01:43:40 2010
@@ -28,6 +28,7 @@ import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Response;
 
 
@@ -55,12 +56,21 @@ public class CustomerService {
     }
     
     @GET
+    @Path("/customers")
+    public Customer getCustomerByQueryParam(@QueryParam("id") String id) {
+        long idNumber = Long.parseLong(id);
+        Customer c = customers.get(idNumber);
+        return c;
+    }
+    
+    @GET
     @Path("/customers/")
     @Produces("application/xml")
     public List<Customer> getCustomers() {
         List<Customer> l = new ArrayList<Customer>(customers.values());
         return l;
     }
+    
 
     @PUT
     @Path("/customers/")



Mime
View raw message