You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/04/04 06:15:31 UTC

[2/2] git commit: CAMEL-7341 Fixed the issue that cxfrs:InInterceptor defined in Spring is ignored

CAMEL-7341 Fixed the issue that cxfrs:InInterceptor defined in Spring is ignored


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/773e5dab
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/773e5dab
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/773e5dab

Branch: refs/heads/camel-2.12.x
Commit: 773e5dab87dda7995966e50e24fedf010a087d6d
Parents: c65737b
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Apr 4 11:32:11 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Apr 4 12:14:35 2014 +0800

----------------------------------------------------------------------
 .../component/cxf/jaxrs/CxfRsEndpoint.java      | 17 +++++++---
 .../cxf/jaxrs/CxfRsSpringEndpointTest.java      |  3 ++
 .../component/cxf/jaxrs/TestInInterceptor.java  | 33 ++++++++++++++++++++
 .../cxf/jaxrs/CxfRsSpringEndpointBeans-2.6.xml  |  9 +++++-
 4 files changed, 57 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/773e5dab/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
index f5360b8..8c3ff1b 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpoint.java
@@ -222,10 +222,19 @@ public class CxfRsEndpoint extends DefaultEndpoint implements HeaderFilterStrate
             factory.getFeatures().addAll(getFeatures());
         }
         
-        factory.setInInterceptors(interceptorHolder.getInInterceptors());
-        factory.setOutInterceptors(interceptorHolder.getOutInterceptors());
-        factory.setOutFaultInterceptors(interceptorHolder.getOutFaultInterceptors());
-        factory.setInFaultInterceptors(interceptorHolder.getInFaultInterceptors()); 
+        // we need to avoid flushing the setting from spring or blueprint
+        if (!interceptorHolder.getInInterceptors().isEmpty()) {
+            factory.setInInterceptors(interceptorHolder.getInInterceptors());
+        } 
+        if (!interceptorHolder.getOutInterceptors().isEmpty()) {
+            factory.setOutInterceptors(interceptorHolder.getOutInterceptors());
+        }
+        if (!interceptorHolder.getOutFaultInterceptors().isEmpty()) {
+            factory.setOutFaultInterceptors(interceptorHolder.getOutFaultInterceptors());
+        }
+        if (!interceptorHolder.getInFaultInterceptors().isEmpty()) {
+            factory.setInFaultInterceptors(interceptorHolder.getInFaultInterceptors()); 
+        }
         
         if (getProperties() != null) {
             if (factory.getProperties() != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/773e5dab/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointTest.java
index d80441e..23a7adb 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointTest.java
@@ -43,6 +43,7 @@ public class CxfRsSpringEndpointTest extends CamelSpringTestSupport {
         assertEquals("Get a wrong resource class", sfb.getResourceClasses().get(0), CustomerService.class);
         assertEquals("Got the wrong loggingFeatureEnabled", true, sfb.isLoggingFeatureEnabled());
         assertEquals("Got the wrong loggingSizeLimit", 200, sfb.getLoggingSizeLimit());
+        assertEquals("Got a wrong size of interceptors", 1, sfb.getInInterceptors().size());
         
         Map<String, Object> endpointProps = sfb.getProperties();
         // The beanId key is put by the AbstractCxfBeanDefinitionParser, so the size is 2
@@ -59,6 +60,8 @@ public class CxfRsSpringEndpointTest extends CamelSpringTestSupport {
         assertTrue("Get a wrong resource class instance", cfb.create() instanceof CustomerService);
         assertEquals("Got the wrong loggingFeatureEnabled", false, cfb.isLoggingFeatureEnabled());
         assertEquals("Got the wrong loggingSizeLimit", 0, cfb.getLoggingSizeLimit());
+        assertEquals("Got a wrong size of interceptors", 1, cfb.getInInterceptors().size());
+
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/773e5dab/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/TestInInterceptor.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/TestInInterceptor.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/TestInInterceptor.java
new file mode 100644
index 0000000..c96d0a5
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/TestInInterceptor.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.cxf.jaxrs;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+public class TestInInterceptor extends AbstractPhaseInterceptor<Message> {
+    public TestInInterceptor() {
+        super(Phase.RECEIVE);
+    }
+
+    @Override
+    public void handleMessage(Message message) throws Fault {
+        // do thing here
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/773e5dab/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointBeans-2.6.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointBeans-2.6.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointBeans-2.6.xml
index 1290c71..09bf7bd 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointBeans-2.6.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringEndpointBeans-2.6.xml
@@ -33,10 +33,17 @@
     <cxf:providers>
        <ref bean="jsonProvider"/>
     </cxf:providers>
+    <cxf:inInterceptors>
+        <bean class="org.apache.camel.component.cxf.jaxrs.TestInInterceptor"/>
+    </cxf:inInterceptors>
   </cxf:rsServer>
 
   <cxf:rsClient id="rsClient" address="http://localhost:9002/helloworld"
-    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService"/>
+    serviceClass="org.apache.camel.component.cxf.jaxrs.testbean.CustomerService">
+    <cxf:inInterceptors>
+        <bean class="org.apache.camel.component.cxf.jaxrs.TestInInterceptor"/>
+    </cxf:inInterceptors>
+  </cxf:rsClient>
 
   <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider"/>