You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2018/01/11 16:18:19 UTC

httpcomponents-core git commit: [HTTPCORE-506] Add generics to DefaultHttpClientIODispatch to specify the NHttpClientEventHandler implementation type.

Repository: httpcomponents-core
Updated Branches:
  refs/heads/4.4.x 96a1b9a32 -> 58b05e67e


[HTTPCORE-506] Add generics to DefaultHttpClientIODispatch to specify
the NHttpClientEventHandler implementation type.

Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/58b05e67
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/58b05e67
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/58b05e67

Branch: refs/heads/4.4.x
Commit: 58b05e67e0ba23845c60b1a0fff65a66588b828f
Parents: 96a1b9a
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Jan 11 09:18:16 2018 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Jan 11 09:18:16 2018 -0700

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  3 ++
 .../impl/nio/DefaultHttpClientIODispatch.java   | 33 ++++++++++----------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/58b05e67/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 3d629a5..87a06de 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -30,6 +30,9 @@ Changelog
 * HTTPCORE-505: Make org.apache.http.nio.protocol.HttpAsyncService instance variables available through getters.
   Contributed by Gary Gregory <ggregory at apache.org>
 
+* HTTPCORE-506: Add generics to DefaultHttpClientIODispatch to specify the NHttpClientEventHandler implementation type.
+  Contributed by Gary Gregory <ggregory at apache.org>
+
 
 Release 4.4.8
 -------------------

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/58b05e67/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
index eb6f0e6..9ea0483 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
@@ -46,12 +46,13 @@ import org.apache.http.util.Args;
  * Default {@link org.apache.http.nio.reactor.IOEventDispatch} implementation
  * that supports both plain (non-encrypted) and SSL encrypted client side HTTP
  * connections.
+ * @param <H> an implementation of {@link NHttpClientEventHandler}.
  *
  * @since 4.2
  */
 @SuppressWarnings("deprecation")
 @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-public class DefaultHttpClientIODispatch
+public class DefaultHttpClientIODispatch<H extends NHttpClientEventHandler>
                     extends AbstractIODispatch<DefaultNHttpClientConnection> {
 
     /**
@@ -64,11 +65,11 @@ public class DefaultHttpClientIODispatch
      * @return a new instance
      * @since 4.4.7
      */
-    public static DefaultHttpClientIODispatch create(final NHttpClientEventHandler handler,
+    public static <T extends NHttpClientEventHandler> DefaultHttpClientIODispatch<T> create(final T handler,
             final SSLContext sslContext,
             final ConnectionConfig config) {
-        return sslContext == null ? new DefaultHttpClientIODispatch(handler, config)
-                : new DefaultHttpClientIODispatch(handler, sslContext, config);
+        return sslContext == null ? new DefaultHttpClientIODispatch<T>(handler, config)
+                : new DefaultHttpClientIODispatch<T>(handler, sslContext, config);
     }
 
     /**
@@ -82,15 +83,15 @@ public class DefaultHttpClientIODispatch
      * @return a new instance
      * @since 4.4.7
      */
-    public static DefaultHttpClientIODispatch create(final NHttpClientEventHandler handler,
+    public static <T extends NHttpClientEventHandler> DefaultHttpClientIODispatch<T> create(final T handler,
             final SSLContext sslContext,
             final SSLSetupHandler sslHandler,
             final ConnectionConfig config) {
-        return sslContext == null ? new DefaultHttpClientIODispatch(handler, config)
-                : new DefaultHttpClientIODispatch(handler, sslContext, sslHandler, config);
+        return sslContext == null ? new DefaultHttpClientIODispatch<T>(handler, config)
+                : new DefaultHttpClientIODispatch<T>(handler, sslContext, sslHandler, config);
     }
 
-    private final NHttpClientEventHandler handler;
+    private final H handler;
     private final NHttpConnectionFactory<? extends DefaultNHttpClientConnection> connectionFactory;
 
     /**
@@ -101,7 +102,7 @@ public class DefaultHttpClientIODispatch
      * @param connFactory HTTP client connection factory.
      */
     public DefaultHttpClientIODispatch(
-            final NHttpClientEventHandler handler,
+            final H handler,
             final NHttpConnectionFactory<? extends DefaultNHttpClientConnection> connFactory) {
         super();
         this.handler = Args.notNull(handler, "HTTP client handler");
@@ -114,7 +115,7 @@ public class DefaultHttpClientIODispatch
      */
     @Deprecated
     public DefaultHttpClientIODispatch(
-            final NHttpClientEventHandler handler,
+            final H handler,
             final HttpParams params) {
         this(handler, new DefaultNHttpClientConnectionFactory(params));
     }
@@ -125,7 +126,7 @@ public class DefaultHttpClientIODispatch
      */
     @Deprecated
     public DefaultHttpClientIODispatch(
-            final NHttpClientEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final SSLSetupHandler sslHandler,
             final HttpParams params) {
@@ -138,7 +139,7 @@ public class DefaultHttpClientIODispatch
      */
     @Deprecated
     public DefaultHttpClientIODispatch(
-            final NHttpClientEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final HttpParams params) {
         this(handler, sslContext, null, params);
@@ -147,7 +148,7 @@ public class DefaultHttpClientIODispatch
     /**
      * @since 4.3
      */
-    public DefaultHttpClientIODispatch(final NHttpClientEventHandler handler, final ConnectionConfig config) {
+    public DefaultHttpClientIODispatch(final H handler, final ConnectionConfig config) {
         this(handler, new DefaultNHttpClientConnectionFactory(config));
     }
 
@@ -155,7 +156,7 @@ public class DefaultHttpClientIODispatch
      * @since 4.3
      */
     public DefaultHttpClientIODispatch(
-            final NHttpClientEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final SSLSetupHandler sslHandler,
             final ConnectionConfig config) {
@@ -166,7 +167,7 @@ public class DefaultHttpClientIODispatch
      * @since 4.3
      */
     public DefaultHttpClientIODispatch(
-            final NHttpClientEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final ConnectionConfig config) {
         this(handler, new SSLNHttpClientConnectionFactory(sslContext, null, config));
@@ -193,7 +194,7 @@ public class DefaultHttpClientIODispatch
      * @return the handler used to construct this dispatch.
      * @since 4.4.9
      */
-    public NHttpClientEventHandler getHandler() {
+    public H getHandler() {
         return handler;
     }