hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1659391 - in /httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main: java-deprecated/org/apache/http/impl/nio/client/ java/org/apache/http/impl/nio/client/
Date Thu, 12 Feb 2015 20:18:47 GMT
Author: olegk
Date: Thu Feb 12 20:18:46 2015
New Revision: 1659391

URL: http://svn.apache.org/r1659391
Log:
HTTPASYNC-87: ability to provide a custom request executor

Added:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java
  (contents, props changed)
      - copied, changed from r1658694, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
Removed:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
Modified:
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClient.java
    httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClientBuilder.java

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java?rev=1659391&r1=1659390&r2=1659391&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java-deprecated/org/apache/http/impl/nio/client/AbstractHttpAsyncClient.java
Thu Feb 12 20:18:46 2015
@@ -85,6 +85,7 @@ import org.apache.http.nio.client.HttpAs
 import org.apache.http.nio.client.methods.HttpAsyncMethods;
 import org.apache.http.nio.conn.ClientAsyncConnectionManager;
 import org.apache.http.nio.protocol.HttpAsyncRequestExecutionHandler;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
 import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
 import org.apache.http.nio.reactor.IOEventDispatch;
@@ -459,7 +460,7 @@ public abstract class AbstractHttpAsyncC
     }
 
     private void doExecute() {
-        final LoggingAsyncRequestExecutor handler = new LoggingAsyncRequestExecutor();
+        final InternalRequestExecutor handler = new InternalRequestExecutor(this.log, new
HttpAsyncRequestExecutor());
         try {
             final IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(handler,
getParams());
             this.connmgr.execute(ioEventDispatch);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java?rev=1659391&r1=1659390&r2=1659391&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/HttpAsyncClientBuilder.java
Thu Feb 12 20:18:46 2015
@@ -98,6 +98,7 @@ import org.apache.http.nio.conn.NHttpCli
 import org.apache.http.nio.conn.NoopIOSessionStrategy;
 import org.apache.http.nio.conn.SchemeIOSessionStrategy;
 import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpProcessorBuilder;
@@ -854,7 +855,7 @@ public class HttpAsyncClientBuilder {
             }
             eventHandler = this.eventHandler;
             if (eventHandler == null) {
-                eventHandler = new LoggingAsyncRequestExecutor();
+                eventHandler = new HttpAsyncRequestExecutor();
             }
         }
         return new InternalHttpAsyncClient(

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java?rev=1659391&r1=1659390&r2=1659391&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalIODispatch.java
Thu Feb 12 20:18:46 2015
@@ -29,6 +29,8 @@ package org.apache.http.impl.nio.client;
 
 import java.io.IOException;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.http.impl.nio.DefaultNHttpClientConnection;
 import org.apache.http.impl.nio.reactor.AbstractIODispatch;
 import org.apache.http.nio.NHttpClientEventHandler;
@@ -36,11 +38,17 @@ import org.apache.http.nio.reactor.IOSes
 
 class InternalIODispatch extends AbstractIODispatch<DefaultNHttpClientConnection> {
 
+    private final Log log = LogFactory.getLog(InternalIODispatch.class);
+
     private final NHttpClientEventHandler handler;
 
     public InternalIODispatch(final NHttpClientEventHandler handler) {
         super();
-        this.handler = handler;
+        if (this.log.isDebugEnabled()) {
+            this.handler = new InternalRequestExecutor(this.log, handler);
+        } else {
+            this.handler = handler;
+        }
     }
 
     @Override

Copied: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java
(from r1658694, httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java?p2=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java&p1=httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java&r1=1658694&r2=1659391&rev=1659391&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/LoggingAsyncRequestExecutor.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java
Thu Feb 12 20:18:46 2015
@@ -30,24 +30,20 @@ package org.apache.http.impl.nio.client;
 import java.io.IOException;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.http.HttpException;
 import org.apache.http.nio.ContentDecoder;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.NHttpClientConnection;
-import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
+import org.apache.http.nio.NHttpClientEventHandler;
 
-class LoggingAsyncRequestExecutor extends HttpAsyncRequestExecutor {
+class InternalRequestExecutor implements NHttpClientEventHandler {
 
-    private final Log log = LogFactory.getLog(HttpAsyncRequestExecutor.class);
+    private final Log log;
+    private final NHttpClientEventHandler handler;
 
-    public LoggingAsyncRequestExecutor() {
-        super();
-    }
-
-    @Override
-    protected void log(final Exception ex) {
-        this.log.debug(ex.getMessage(), ex);
+    public InternalRequestExecutor(final Log log, final NHttpClientEventHandler handler)
{
+        this.log = log;
+        this.handler = handler;
     }
 
     @Override
@@ -57,7 +53,7 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + ": Connected");
         }
-        super.connected(conn, attachment);
+        this.handler.connected(conn, attachment);
     }
 
     @Override
@@ -65,7 +61,7 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + ": Disconnected");
         }
-        super.closed(conn);
+        this.handler.closed(conn);
     }
 
     @Override
@@ -74,7 +70,7 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Request ready");
         }
-        super.requestReady(conn);
+        this.handler.requestReady(conn);
     }
 
     @Override
@@ -84,7 +80,7 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Input ready");
         }
-        super.inputReady(conn, decoder);
+        this.handler.inputReady(conn, decoder);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " " + decoder);
         }
@@ -97,7 +93,7 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Output ready");
         }
-        super.outputReady(conn, encoder);
+        this.handler.outputReady(conn, encoder);
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " " + encoder);
         }
@@ -109,15 +105,23 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Response received");
         }
-        super.responseReceived(conn);
+        this.handler.responseReceived(conn);
     }
 
     @Override
-    public void timeout(final NHttpClientConnection conn) throws IOException {
+    public void timeout(final NHttpClientConnection conn) throws HttpException, IOException
{
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " Timeout");
         }
-        super.timeout(conn);
+        this.handler.timeout(conn);
+    }
+
+    @Override
+    public void exception(final NHttpClientConnection conn, final Exception ex) {
+        if (this.log.isDebugEnabled()) {
+            this.log.debug(conn + " Exception", ex);
+        }
+        this.handler.exception(conn, ex);
     }
 
     @Override
@@ -125,7 +129,7 @@ class LoggingAsyncRequestExecutor extend
         if (this.log.isDebugEnabled()) {
             this.log.debug(conn + " End of input");
         }
-        super.endOfInput(conn);
+        this.handler.endOfInput(conn);
     }
 
 }

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/InternalRequestExecutor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClient.java?rev=1659391&r1=1659390&r2=1659391&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClient.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClient.java
Thu Feb 12 20:18:46 2015
@@ -43,6 +43,7 @@ import org.apache.http.impl.DefaultConne
 import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
 import org.apache.http.nio.NHttpClientEventHandler;
 import org.apache.http.nio.conn.NHttpClientConnectionManager;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
 import org.apache.http.nio.protocol.HttpAsyncRequestProducer;
 import org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
 import org.apache.http.protocol.BasicHttpContext;
@@ -77,7 +78,7 @@ class MinimalHttpAsyncClient extends Clo
             final HttpProcessor httpProcessor) {
         this(connmgr,
                 Executors.defaultThreadFactory(),
-                new LoggingAsyncRequestExecutor(),
+                new HttpAsyncRequestExecutor(),
                 httpProcessor,
                 DefaultConnectionReuseStrategy.INSTANCE,
                 DefaultConnectionKeepAliveStrategy.INSTANCE);

Modified: httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClientBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClientBuilder.java?rev=1659391&r1=1659390&r2=1659391&view=diff
==============================================================================
--- httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClientBuilder.java
(original)
+++ httpcomponents/httpasyncclient/trunk/httpasyncclient/src/main/java/org/apache/http/impl/nio/client/MinimalHttpAsyncClientBuilder.java
Thu Feb 12 20:18:46 2015
@@ -42,6 +42,7 @@ import org.apache.http.impl.nio.conn.Poo
 import org.apache.http.impl.nio.reactor.IOReactorConfig;
 import org.apache.http.nio.NHttpClientEventHandler;
 import org.apache.http.nio.conn.NHttpClientConnectionManager;
+import org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
 import org.apache.http.protocol.HttpProcessor;
 import org.apache.http.protocol.HttpProcessorBuilder;
 import org.apache.http.protocol.RequestContent;
@@ -151,7 +152,7 @@ class MinimalHttpAsyncClientBuilder {
             if (threadFactory == null) {
                 threadFactory = Executors.defaultThreadFactory();
             }
-            eventHandler = new LoggingAsyncRequestExecutor();
+            eventHandler = new HttpAsyncRequestExecutor();
         }
         return new MinimalHttpAsyncClient(
             connManager,



Mime
View raw message