camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r771645 - in /camel/trunk/components/camel-jhc/src: main/java/org/apache/camel/component/jhc/JhcConsumer.java main/java/org/apache/camel/component/jhc/JhcProducer.java test/java/org/apache/camel/component/jhc/HttpTest.java
Date Tue, 05 May 2009 09:54:31 GMT
Author: davsclaus
Date: Tue May  5 09:54:31 2009
New Revision: 771645

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

Modified:
    camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
    camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
    camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/HttpTest.java

Modified: camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java?rev=771645&r1=771644&r2=771645&view=diff
==============================================================================
--- camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
(original)
+++ camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
Tue May  5 09:54:31 2009
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 
-import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultConsumer;
@@ -146,25 +145,27 @@
             if (request instanceof HttpEntityEnclosingRequest) {
                 exchange.getIn().setBody(((HttpEntityEnclosingRequest)request).getEntity());
             }
-            getAsyncProcessor().process(exchange, new AsyncCallback() {
-                public void done(boolean doneSynchronously) {
-                    LOG.debug("handleExchange");
-                    // create the default response to this request
-                    ProtocolVersion httpVersion = (HttpVersion)request.getRequestLine().getProtocolVersion();
-
-                    HttpResponse response = responseFactory.newHttpResponse(
-                        httpVersion, HttpStatus.SC_OK, context);
-                    response.setParams(params);
-                    HttpEntity entity = exchange.getOut().getBody(HttpEntity.class);
-                    response.setEntity(entity);
-                    response.setParams(getEndpoint().getParams());
-                    try {
-                        handler.sendResponse(response);
-                    } catch (Exception e) {
-                        LOG.info(e);
-                    }
-                }
-            });
+
+            try {
+                getProcessor().process(exchange);
+            } catch (Exception e) {
+                exchange.setException(e);
+            }
+
+            LOG.debug("handleExchange");
+            // create the default response to this request
+            ProtocolVersion httpVersion = (HttpVersion)request.getRequestLine().getProtocolVersion();
+
+            HttpResponse response = responseFactory.newHttpResponse(httpVersion, HttpStatus.SC_OK,
context);
+            response.setParams(params);
+            HttpEntity entity = exchange.getOut().getBody(HttpEntity.class);
+            response.setEntity(entity);
+            response.setParams(getEndpoint().getParams());
+            try {
+                handler.sendResponse(response);
+            } catch (Exception e) {
+                LOG.info(e);
+            }
         }
 
         public void handle(HttpRequest request, HttpResponse response, HttpContext context)

Modified: camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java?rev=771645&r1=771644&r2=771645&view=diff
==============================================================================
--- camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
(original)
+++ camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
Tue May  5 09:54:31 2009
@@ -20,19 +20,14 @@
 import java.io.InterruptedIOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
-import java.util.Arrays;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Set;
 import java.util.concurrent.ThreadFactory;
 
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
+import org.apache.camel.Processor;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.http.Header;
@@ -63,7 +58,7 @@
 import org.apache.http.protocol.RequestTargetHost;
 import org.apache.http.protocol.RequestUserAgent;
 
-public class JhcProducer extends DefaultProducer implements AsyncProcessor {
+public class JhcProducer extends DefaultProducer implements Processor {
 
     public static final String HTTP_RESPONSE_CODE = "http.responseCode";
     private static final transient Log LOG = LogFactory.getLog(JhcProducer.class);
@@ -127,17 +122,8 @@
         if (LOG.isDebugEnabled()) {
             LOG.debug("process: " + exchange);
         }
-        AsyncProcessorHelper.process(this, exchange);
-    }
-
-    public boolean process(Exchange exchange, AsyncCallback callback) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("processAsync: " + exchange);
-        }
         SocketAddress addr = new InetSocketAddress(getEndpoint().getHost(), getEndpoint().getPort());
-        exchange.setProperty(AsyncCallback.class.getName(), callback);
         ioReactor.connect(addr, null, exchange, new MySessionRequestCallback());
-        return false;
     }
 
     protected HttpRequest createRequest(Exchange exchange) {
@@ -257,8 +243,6 @@
             }
             
             e.getOut().setHeader(HTTP_RESPONSE_CODE, httpResponse.getStatusLine().getStatusCode());
-            AsyncCallback callback = (AsyncCallback) e.removeProperty(AsyncCallback.class.getName());
-            callback.done(false);
         }
 
         public void finalizeContext(HttpContext httpContext) {

Modified: camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/HttpTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/HttpTest.java?rev=771645&r1=771644&r2=771645&view=diff
==============================================================================
--- camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/HttpTest.java
(original)
+++ camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/HttpTest.java
Tue May  5 09:54:31 2009
@@ -55,11 +55,6 @@
         Message in = exchange.getIn();
         assertNotNull("in", in);
 
-        Map<String, Object> headers = in.getHeaders();
-
-        log.debug("Headers: " + headers);
-        assertTrue("Should be more than one header but was: " + headers, headers.size() >
0);
-
         String body = in.getBody(String.class);
 
         log.debug("Body: " + body);



Mime
View raw message