Connector refactoring.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 22 Jun 2011 23:13:37 +0000 (23:13 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 22 Jun 2011 23:13:37 +0000 (23:13 +0000)
Start moving the NIO connectors towards using SocketWrapper<NioChannel> rather than NioChannel to align them with BIO/APR and permit further refactoring.
Do this in small steps since when I tried to do it in one hit, everything broke.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1138677 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpNioProtocol.java
java/org/apache/coyote/http11/Http11NioProtocol.java
java/org/apache/tomcat/util/net/NioEndpoint.java

index cef916c..7396517 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.tomcat.util.net.NioEndpoint;
 import org.apache.tomcat.util.net.NioEndpoint.Handler;
 import org.apache.tomcat.util.net.SSLImplementation;
 import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
 
 
 /**
@@ -166,7 +167,9 @@ public class AjpNioProtocol extends AbstractAjpProtocol {
         }
 
         @Override
-        public SocketState process(NioChannel socket, SocketStatus status) {
+        public SocketState process(SocketWrapper<NioChannel> socketWrapper,
+                SocketStatus status) {
+            NioChannel socket = socketWrapper.getSocket();
             AjpNioProcessor processor = connections.remove(socket);
 
             NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
index a6351b9..79dbf87 100644 (file)
@@ -33,6 +33,7 @@ import org.apache.tomcat.util.net.NioEndpoint.Handler;
 import org.apache.tomcat.util.net.SSLImplementation;
 import org.apache.tomcat.util.net.SecureNioChannel;
 import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
 
 
 /**
@@ -228,7 +229,9 @@ public class Http11NioProtocol extends AbstractHttp11JsseProtocol {
 
 
         @Override
-        public SocketState process(NioChannel socket, SocketStatus status) {
+        public SocketState process(SocketWrapper<NioChannel> socketWrapper,
+                SocketStatus status) {
+            NioChannel socket = socketWrapper.getSocket();
             Http11NioProcessor processor = connections.remove(socket);
 
             NioEndpoint.KeyAttachment att = (NioEndpoint.KeyAttachment)socket.getAttachment(false);
index bcf9139..5288f9f 100644 (file)
@@ -1485,7 +1485,8 @@ public class NioEndpoint extends AbstractEndpoint {
      * thread local fields.
      */
     public interface Handler extends AbstractEndpoint.Handler {
-        public SocketState process(NioChannel socket, SocketStatus status);
+        public SocketState process(SocketWrapper<NioChannel> socket,
+                SocketStatus status);
         public void release(NioChannel socket);
         public void release(SocketChannel socket);
         public SSLImplementation getSslImplementation();
@@ -1532,9 +1533,13 @@ public class NioEndpoint extends AbstractEndpoint {
                         SocketState state = SocketState.OPEN;
                         // Process the request from this socket
                         if (status == null) {
-                            state = handler.process(socket, SocketStatus.OPEN);
+                            state = handler.process(
+                                    (KeyAttachment) key.attachment(),
+                                    SocketStatus.OPEN);
                         } else {
-                            state = handler.process(socket, status);
+                            state = handler.process(
+                                    (KeyAttachment) key.attachment(),
+                                    status);
                         }
     
                         if (state == SocketState.CLOSED) {