You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/05/05 12:45:25 UTC

svn commit: r771659 - in /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf: AsyncProcessorDecorator.java CxfAroundProcessor.java CxfSoapConsumer.java CxfSoapProducer.java

Author: davsclaus
Date: Tue May  5 10:45:22 2009
New Revision: 771659

URL: http://svn.apache.org/viewvc?rev=771659&view=rev
Log:
CAMEL-1572: API cleanup.

Added:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java   (contents, props changed)
      - copied, changed from r771551, camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java
Removed:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java
Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java

Copied: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java (from r771551, camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java?p2=camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java&p1=camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java&r1=771551&r2=771659&rev=771659&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/AsyncProcessorDecorator.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java Tue May  5 10:45:22 2009
@@ -16,52 +16,32 @@
  */
 package org.apache.camel.component.cxf;
 
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
-import org.apache.camel.util.AsyncProcessorHelper;
 
 /**
- * A simple class to wrap an existing processor (synchronous or asynchronous)
- * with two synchronous processors that will be executed before and after the
+ * A simple class to wrap an existing processor in AOP around
+ * with two processors that will be executed before and after the
  * main processor.
  */
-public class AsyncProcessorDecorator implements AsyncProcessor {
+public class CxfAroundProcessor implements Processor {
 
-    private final AsyncProcessor processor;
+    // TODO: Should leverage AOP around when we have support for that in camel-core
+
+    private final Processor processor;
     private final Processor before;
     private final Processor after;
 
-    public AsyncProcessorDecorator(Processor processor, Processor before, Processor after) {
-        this.processor = AsyncProcessorTypeConverter.convert(processor);
+    public CxfAroundProcessor(Processor processor, Processor before, Processor after) {
+        this.processor = processor;
         this.before = before;
         this.after = after;
     }
 
     public void process(Exchange exchange) throws Exception {
-        AsyncProcessorHelper.process(this, exchange);
-    }
-
-    public boolean process(final Exchange exchange, final AsyncCallback callback) {
-        try {
-            before.process(exchange);
-        } catch (Exception e) {
-            exchange.setException(e);
-            callback.done(true);
-            return true;
-        }
-        return processor.process(exchange, new AsyncCallback() {
-            public void done(boolean doneSynchronously) {
-                try {
-                    after.process(exchange);
-                    callback.done(doneSynchronously);
-                } catch (Exception e) {
-                    exchange.setException(e);
-                }
-            }
-        });
+        before.process(exchange);
+        processor.process(exchange);
+        after.process(exchange);
     }
 
 }

Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfAroundProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java?rev=771659&r1=771658&r2=771659&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapConsumer.java Tue May  5 10:45:22 2009
@@ -54,7 +54,7 @@
 
     public CxfSoapConsumer(CxfSoapEndpoint endpoint, Processor processor) throws Exception {
         this.endpoint = endpoint;
-        Processor soapProcessor = new AsyncProcessorDecorator(processor,
+        Processor soapProcessor = new CxfAroundProcessor(processor,
                 new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         processSoapConsumerIn(exchange);
@@ -90,12 +90,11 @@
         server.start();
         inMessageObserver = server.getDestination().getMessageObserver();
         consumer.start();
-
     }
 
     public void stop() throws Exception {
-        server.stop();
         consumer.stop();
+        server.stop();
     }
 
     protected Bus getBus() {
@@ -103,7 +102,9 @@
     }
 
     protected void processSoapConsumerIn(Exchange exchange) throws Exception {
-        LOG.info("processSoapConsumerIn: " + exchange);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("processSoapConsumerIn: " + exchange);
+        }
         org.apache.cxf.message.Message inMessage = CxfSoapBinding.getCxfInMessage(
                 endpoint.getHeaderFilterStrategy(), exchange, false);
         org.apache.cxf.message.Exchange cxfExchange = inMessage.getExchange();
@@ -119,7 +120,9 @@
     }
 
     protected void processSoapConsumerOut(Exchange exchange) throws Exception {
-        LOG.info("processSoapConsumerOut: " + exchange);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("processSoapConsumerOut: " + exchange);
+        }
 
         // TODO check if the message is one-way message
         // Get the method name from the soap endpoint

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java?rev=771659&r1=771658&r2=771659&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapProducer.java Tue May  5 10:45:22 2009
@@ -18,11 +18,8 @@
 
 import java.io.OutputStream;
 import java.lang.reflect.Proxy;
-
 import javax.xml.transform.Source;
 
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
@@ -32,7 +29,6 @@
 import org.apache.camel.component.cxf.util.Dummy;
 import org.apache.camel.component.cxf.util.NullConduit;
 import org.apache.camel.component.cxf.util.NullConduitSelector;
-import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -52,20 +48,19 @@
  * The consumer will delegate to another endpoint for the transport layer
  * and will provide SOAP support on top of it.
  */
-public class CxfSoapProducer implements Producer, AsyncProcessor {
+public class CxfSoapProducer implements Producer {
 
     private static final Log LOG = LogFactory.getLog(CxfSoapProducer.class);
 
     private final CxfSoapEndpoint endpoint;
     private final Producer producer;
-    private final AsyncProcessor processor;
-    private ClientImpl client;
-
+    private final Processor processor;
+    private final ClientImpl client;
 
     public CxfSoapProducer(CxfSoapEndpoint endpoint) throws Exception {
         this.endpoint = endpoint;
         this.producer = endpoint.getInnerEndpoint().createProducer();
-        this.processor = new AsyncProcessorDecorator(producer,
+        this.processor = new CxfAroundProcessor(producer,
                 new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         processSoapProviderIn(exchange);
@@ -97,7 +92,6 @@
         }
         cfb.setConduitSelector(new NullConduitSelector());
         client = (ClientImpl)((ClientProxy)Proxy.getInvocationHandler(cfb.create())).getClient();
-
     }
 
     public Endpoint getEndpoint() {
@@ -117,11 +111,7 @@
     }
 
     public void process(Exchange exchange) throws Exception {
-        AsyncProcessorHelper.process(this, exchange);
-    }
-
-    public boolean process(Exchange exchange, AsyncCallback callback) {
-        return processor.process(exchange, callback);
+        processor.process(exchange);
     }
 
     public void start() throws Exception {
@@ -133,7 +123,9 @@
     }
 
     protected void processSoapProviderOut(Exchange exchange) throws Exception {
-        LOG.info("processSoapProviderOut: " + exchange);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("processSoapProviderOut: " + exchange);
+        }
 
         org.apache.cxf.message.Message inMessage = CxfSoapBinding.getCxfInMessage(
                 endpoint.getHeaderFilterStrategy(), exchange, true);
@@ -150,7 +142,9 @@
     }
 
     protected void processSoapProviderIn(Exchange exchange) throws Exception {
-        LOG.info("processSoapProviderIn: " + exchange);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("processSoapProviderIn: " + exchange);
+        }
         org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
         org.apache.cxf.message.Exchange cxfExchange = new ExchangeImpl();
         cxfExchange.put(org.apache.cxf.endpoint.Endpoint.class, cxfEndpoint);