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:25:14 UTC

httpcomponents-core git commit: [HTTPCORE-507] Add generics to DefaultHttpServerIODispatch to specify the NHttpServerEventHandler implementation type.

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


[HTTPCORE-507] Add generics to DefaultHttpServerIODispatch to specify
the NHttpServerEventHandler 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/c7feb540
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/c7feb540
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/c7feb540

Branch: refs/heads/4.4.x
Commit: c7feb5400865c84661eddf16e499af9ec97d70b6
Parents: 58b05e6
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Jan 11 09:25:11 2018 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Jan 11 09:25:11 2018 -0700

----------------------------------------------------------------------
 RELEASE_NOTES.txt                               |  3 ++
 .../impl/nio/DefaultHttpServerIODispatch.java   | 35 ++++++++++----------
 2 files changed, 21 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c7feb540/RELEASE_NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 87a06de..4edfd63 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -33,6 +33,9 @@ Changelog
 * HTTPCORE-506: Add generics to DefaultHttpClientIODispatch to specify the NHttpClientEventHandler implementation type.
   Contributed by Gary Gregory <ggregory at apache.org>
 
+* HTTPCORE-507: Add generics to DefaultHttpServerIODispatch to specify the NHttpServerEventHandler 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/c7feb540/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
----------------------------------------------------------------------
diff --git a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
index d746922..564e827 100644
--- a/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
+++ b/httpcore-nio/src/main/java/org/apache/http/impl/nio/DefaultHttpServerIODispatch.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 server side HTTP
  * connections.
+ * @param <H> an implementation of {@link NHttpServerEventHandler}.
  *
  * @since 4.2
  */
 @SuppressWarnings("deprecation")
 @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-public class DefaultHttpServerIODispatch
+public class DefaultHttpServerIODispatch<H extends NHttpServerEventHandler>
                     extends AbstractIODispatch<DefaultNHttpServerConnection> {
 
     /**
@@ -64,11 +65,11 @@ public class DefaultHttpServerIODispatch
      * @return a new instance
      * @since 4.4.7
      */
-    public static DefaultHttpServerIODispatch create(final NHttpServerEventHandler handler,
+    public static <T extends NHttpServerEventHandler> DefaultHttpServerIODispatch<T> create(final T handler,
             final SSLContext sslContext,
             final ConnectionConfig config) {
-        return sslContext == null ? new DefaultHttpServerIODispatch(handler, config)
-                : new DefaultHttpServerIODispatch(handler, sslContext, config);
+        return sslContext == null ? new DefaultHttpServerIODispatch<T>(handler, config)
+                : new DefaultHttpServerIODispatch<T>(handler, sslContext, config);
     }
 
     /**
@@ -82,22 +83,22 @@ public class DefaultHttpServerIODispatch
      * @return a new instance
      * @since 4.4.7
      */
-    public static DefaultHttpServerIODispatch create(final NHttpServerEventHandler handler,
+    public static <T extends NHttpServerEventHandler> DefaultHttpServerIODispatch<T> create(final T handler,
             final SSLContext sslContext,
             final SSLSetupHandler sslHandler,
             final ConnectionConfig config) {
-        return sslContext == null ? new DefaultHttpServerIODispatch(handler, config)
-                : new DefaultHttpServerIODispatch(handler, sslContext, sslHandler, config);
+        return sslContext == null ? new DefaultHttpServerIODispatch<T>(handler, config)
+                : new DefaultHttpServerIODispatch<T>(handler, sslContext, sslHandler, config);
     }
 
-    private final NHttpServerEventHandler handler;
+    private final H handler;
     private final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connectionFactory;
 
     public DefaultHttpServerIODispatch(
-            final NHttpServerEventHandler handler,
+            final H handler,
             final NHttpConnectionFactory<? extends DefaultNHttpServerConnection> connFactory) {
         super();
-        this.handler = Args.notNull(handler, "HTTP client handler");
+        this.handler = Args.notNull(handler, "HTTP server handler");
         this.connectionFactory = Args.notNull(connFactory, "HTTP server connection factory");
     }
 
@@ -107,7 +108,7 @@ public class DefaultHttpServerIODispatch
      */
     @Deprecated
     public DefaultHttpServerIODispatch(
-            final NHttpServerEventHandler handler,
+            final H handler,
             final HttpParams params) {
         this(handler, new DefaultNHttpServerConnectionFactory(params));
     }
@@ -118,7 +119,7 @@ public class DefaultHttpServerIODispatch
      */
     @Deprecated
     public DefaultHttpServerIODispatch(
-            final NHttpServerEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final SSLSetupHandler sslHandler,
             final HttpParams params) {
@@ -131,7 +132,7 @@ public class DefaultHttpServerIODispatch
      */
     @Deprecated
     public DefaultHttpServerIODispatch(
-            final NHttpServerEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final HttpParams params) {
         this(handler, sslContext, null, params);
@@ -140,7 +141,7 @@ public class DefaultHttpServerIODispatch
     /**
      * @since 4.3
      */
-    public DefaultHttpServerIODispatch(final NHttpServerEventHandler handler, final ConnectionConfig config) {
+    public DefaultHttpServerIODispatch(final H handler, final ConnectionConfig config) {
         this(handler, new DefaultNHttpServerConnectionFactory(config));
     }
 
@@ -148,7 +149,7 @@ public class DefaultHttpServerIODispatch
      * @since 4.3
      */
     public DefaultHttpServerIODispatch(
-            final NHttpServerEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final SSLSetupHandler sslHandler,
             final ConnectionConfig config) {
@@ -159,7 +160,7 @@ public class DefaultHttpServerIODispatch
      * @since 4.3
      */
     public DefaultHttpServerIODispatch(
-            final NHttpServerEventHandler handler,
+            final H handler,
             final SSLContext sslContext,
             final ConnectionConfig config) {
         this(handler, new SSLNHttpServerConnectionFactory(sslContext, null, config));
@@ -186,7 +187,7 @@ public class DefaultHttpServerIODispatch
      * @return the handler used to construct this dispatch.
      * @since 4.4.9
      */
-    public NHttpServerEventHandler getHandler() {
+    public H getHandler() {
         return handler;
     }