camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r629333 - in /activemq/camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/feature/ main/java/org/apache/camel/component/cxf/interceptors/ main/java/org/apache/camel/compo...
Date Wed, 20 Feb 2008 03:35:07 GMT
Author: ningjiang
Date: Tue Feb 19 19:35:01 2008
New Revision: 629333

URL: http://svn.apache.org/viewvc?rev=629333&view=rev
Log:
CAMEL-339 Added the support of throw the customer exception in MESSAGE and PAYLOAD mode

Modified:
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java?rev=629333&r1=629332&r2=629333&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
Tue Feb 19 19:35:01 2008
@@ -24,6 +24,7 @@
 import java.util.logging.Logger;
 
 import org.apache.camel.ExchangePattern;
+import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.frontend.MethodDispatcher;
 import org.apache.cxf.helpers.CastUtils;
@@ -98,9 +99,8 @@
             if (outMessage == null) {
                 outMessage = endpoint.getBinding().createMessage();
             }
-            exchange.setOutMessage(outMessage);
         }
-
+        exchange.setOutMessage(outMessage);
     }
 
     @SuppressWarnings("unchecked")

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?rev=629333&r1=629332&r2=629333&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
Tue Feb 19 19:35:01 2008
@@ -223,9 +223,6 @@
                 Object params = invokingContext.getRequestContent(inMessage);
                 // invoke the stream message with the exchange context
                 CxfClient cxfClient = (CxfClient) client;
-                // invoke the message
-                //TODO need setup the call context here
-                Object result = cxfClient.dispatch(params, null, ex);
                 // need to get the binding object to create the message
                 BindingOperationInfo boi = ex.get(BindingOperationInfo.class);
                 Message response = null;
@@ -238,9 +235,17 @@
                     response = ep.getBinding().createMessage();
                 }
                 response.setExchange(ex);
-                ex.setOutMessage(response);
-                invokingContext.setResponseContent(response, result);
-                cxfBinding.storeCxfResponse(exchange, response);
+                // invoke the message
+                //TODO need setup the call context here
+                try {
+                    Object result = cxfClient.dispatch(params, null, ex);
+                    ex.setOutMessage(response);
+                    invokingContext.setResponseContent(response, result);
+                    cxfBinding.storeCxfResponse(exchange, response);
+                } catch (Exception e) {
+                    response.setContent(Exception.class, e);
+                    cxfBinding.storeCxfFault(exchange, response);
+                }
             }
         } catch (Exception e) {
             //TODO add the falut message handling work

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java?rev=629333&r1=629332&r2=629333&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
Tue Feb 19 19:35:01 2008
@@ -21,6 +21,7 @@
 
 import org.apache.camel.component.cxf.interceptors.DOMInInterceptor;
 import org.apache.camel.component.cxf.interceptors.DOMOutInterceptor;
+import org.apache.camel.component.cxf.interceptors.FaultOutInterceptor;
 import org.apache.camel.component.cxf.interceptors.PayloadContentRedirectInterceptor;
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.Binding;
@@ -52,6 +53,7 @@
         removeInterceptorWhichIsInThePhases(client.getEndpoint().getBinding().getOutInterceptors(),
REMOVING_OUT_PHASES);
 
         addDataHandlingInterceptors(client.getEndpoint().getBinding());
+        client.getEndpoint().getBinding().getOutFaultInterceptors().add(new FaultOutInterceptor());
     }
 
     @Override
@@ -69,6 +71,7 @@
         resetServiceInvokerInterceptor(server);
 
         addDataHandlingInterceptors(server.getEndpoint().getBinding());
+        server.getEndpoint().getBinding().getOutFaultInterceptors().add(new FaultOutInterceptor());
     }
 
     private void addDataHandlingInterceptors(Binding binding) {

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java?rev=629333&r1=629332&r2=629333&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/interceptors/PayloadContentRedirectInterceptor.java
Tue Feb 19 19:35:01 2008
@@ -32,11 +32,17 @@
 public class PayloadContentRedirectInterceptor extends AbstractPhaseInterceptor<Message>
{
 
     public PayloadContentRedirectInterceptor() {
-        super(Phase.POST_STREAM);        
+        super(Phase.POST_STREAM);
     }
 
     @SuppressWarnings("unchecked")
     public void handleMessage(Message message) throws Fault {
+        // check the fault from the message
+        Exception ex = message.getContent(Exception.class);
+        if (ex != null) {
+            throw new Fault(ex);
+        }
+
         XMLStreamWriter out = message.getContent(XMLStreamWriter.class);
         List<Element> in = message.get(List.class);
         try {

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java?rev=629333&r1=629332&r2=629333&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
Tue Feb 19 19:35:01 2008
@@ -28,6 +28,7 @@
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -42,11 +43,9 @@
 
     private static final Logger LOG = Logger.getLogger(CxfClient.class.getName());
 
-    private Endpoint endpoint;
-
     public CxfClient(Bus b, Endpoint e) {
         super(b, e);
-        endpoint = e;
+
     }
 
     public Object dispatch(Object params,
@@ -99,21 +98,18 @@
 
         Exchange exchange = new ExchangeImpl();
         // put the message Observer to call the CxfClient onMessage()
-        exchange.put(MessageObserver.class, this);
+        setExchangeProperties(exchange, getEndpoint(), bi);
         exchange.put(InvokingContext.class, invokingContext);
-        exchange.put(Bus.class, bus);
-        exchange.put(Endpoint.class, getEndpoint());
-        exchange.put(BindingInfo.class, getEndpoint().getEndpointInfo().getBinding());
+
         if (bi != null) {
             //Set The InputMessage
-            exchange.put(BindingOperationInfo.class, bi);
             exchange.put(BindingMessageInfo.class, bi.getInput());
             exchange.setOneWay(bi.getOperationInfo().isOneWay());
         }
 
         Message message = prepareMessage(exchange, requestContext, param, invokingContext);
 
-        PhaseInterceptorChain chain = setupInterceptorChain(endpoint);
+        PhaseInterceptorChain chain = setupInterceptorChain(getEndpoint());
 
         message.setInterceptorChain(chain);
         modifyChain(chain, requestContext);
@@ -202,12 +198,5 @@
         return message;
     }
 
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public Bus getBus() {
-        return bus;
-    }
 }
 

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java?rev=629333&r1=629332&r2=629333&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFGreeterRouterTest.java
Tue Feb 19 19:35:01 2008
@@ -26,6 +26,7 @@
 import org.apache.camel.spring.processor.SpringTestHelper;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.GreeterImpl;
+import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
 
 public class CXFGreeterRouterTest extends CxfSpringRouterTest {
     private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
@@ -46,19 +47,24 @@
                         "http://localhost:9003/CamelContext/RouterPort");
         Greeter greeter = service.getPort(routerPortName, Greeter.class);
 
-        try {
+        String reply = greeter.greetMe("test");
+        assertNotNull("No response received from service", reply);
+        assertEquals("Got the wrong reply ", "Hello test", reply);
+        reply = greeter.sayHi();
+        assertNotNull("No response received from service", reply);
+        assertEquals("Got the wrong reply ", "Bonjour", reply);
+
+        greeter.greetMeOneWay("call greetMe OneWay !");
 
-            String reply = greeter.greetMe("test");
-            assertNotNull("No response received from service", reply);
-            assertEquals("Got the wrong reply ", "Hello test", reply);
-            reply = greeter.sayHi();
-            assertNotNull("No response received from service", reply);
-            assertEquals("Got the wrong reply ", "Bonjour", reply);
-
-            greeter.greetMeOneWay("call greetMe OneWay !");
-        } catch (UndeclaredThrowableException ex) {
-            throw (Exception)ex.getCause();
+        // test throw the exception
+        try {
+            greeter.testDocLitFault("NoSuchCodeLitFault");
+            // should get the exception here
+            fail("Should get the NoSuchCodeLitFault here.");
+        } catch (NoSuchCodeLitFault fault) {
+            // expect the fault here
         }
+
     }
 
     @Override



Mime
View raw message