tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1144391 - /tomcat/trunk/java/org/apache/coyote/http11/
Date Fri, 08 Jul 2011 17:19:38 GMT
Author: markt
Date: Fri Jul  8 17:19:38 2011
New Revision: 1144391

URL: http://svn.apache.org/viewvc?rev=1144391&view=rev
Log:
Pull up Handler.process for the Http11 connectors.
Note that this is an intermediate step. The aim is to pull this up to AbstractProtocol

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Fri Jul  8 17:19:38
2011
@@ -47,9 +47,10 @@ import org.apache.tomcat.util.http.MimeH
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
 import org.apache.tomcat.util.res.StringManager;
 
-public abstract class AbstractHttp11Processor extends AbstractProcessor {
+public abstract class AbstractHttp11Processor<S> extends AbstractProcessor {
 
     protected abstract Log getLog();
 
@@ -1211,6 +1212,9 @@ public abstract class AbstractHttp11Proc
     }
 
     
+    public abstract SocketState process(SocketWrapper<S> socket)
+            throws IOException;
+    
     public SocketState asyncDispatch(SocketStatus status) {
 
         RequestInfo rp = request.getRequestProcessor();

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java Fri Jul  8 17:19:38
2011
@@ -16,7 +16,12 @@
  */
 package org.apache.coyote.http11;
 
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.apache.coyote.AbstractProtocol;
+import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.net.SocketStatus;
+import org.apache.tomcat.util.net.SocketWrapper;
 import org.apache.tomcat.util.res.StringManager;
 
 public abstract class AbstractHttp11Protocol extends AbstractProtocol {
@@ -182,4 +187,94 @@ public abstract class AbstractHttp11Prot
     public void setMaxKeepAliveRequests(int mkar) {
         endpoint.setMaxKeepAliveRequests(mkar);
     }
+
+
+    protected abstract static class AbstractHttp11ConnectionHandler<S,P extends AbstractHttp11Processor<S>>
+            extends AbstractConnectionHandler {
+        
+        protected ConcurrentHashMap<SocketWrapper<S>,P> connections =
+            new ConcurrentHashMap<SocketWrapper<S>,P>();
+
+        protected RecycledProcessors<P> recycledProcessors =
+            new RecycledProcessors<P>(this);
+        
+        @Override
+        public void recycle() {
+            recycledProcessors.clear();
+        }
+        
+        public SocketState process(SocketWrapper<S> socket,
+                SocketStatus status) {
+            P processor = connections.remove(socket);
+
+            socket.setAsync(false); //no longer check for timeout
+
+            try {
+                if (processor == null) {
+                    processor = recycledProcessors.poll();
+                }
+                if (processor == null) {
+                    processor = createProcessor();
+                }
+
+                initSsl(socket, processor);
+                
+                SocketState state = SocketState.CLOSED;
+                do {
+                    if (processor.isAsync() || state == SocketState.ASYNC_END) {
+                        state = processor.asyncDispatch(status);
+                    } else if (processor.comet) {
+                        state = processor.event(status);
+                    } else {
+                        state = processor.process(socket);
+                    }
+    
+                    if (state != SocketState.CLOSED && processor.isAsync()) {
+                        state = processor.asyncPostProcess();
+                    }
+                } while (state == SocketState.ASYNC_END);
+
+                if (state == SocketState.LONG) {
+                    // In the middle of processing a request/response. Keep the
+                    // socket associated with the processor. Exact requirements
+                    // depend on type of long poll
+                    longPoll(socket, processor);
+                } else if (state == SocketState.OPEN){
+                    // In keep-alive but between requests. OK to recycle
+                    // processor. Continue to poll for the next request.
+                    release(socket, processor, false, true);
+                } else {
+                    // Connection closed. OK to recycle the processor.
+                    release(socket, processor, true, false);
+                }
+                return state;
+            } catch(java.net.SocketException e) {
+                // SocketExceptions are normal
+                getLog().debug(sm.getString(
+                        "http11protocol.proto.socketexception.debug"), e);
+            } catch (java.io.IOException e) {
+                // IOExceptions are normal
+                getLog().debug(sm.getString(
+                        "http11protocol.proto.ioexception.debug"), e);
+            }
+            // Future developers: if you discover any other
+            // rare-but-nonfatal exceptions, catch them here, and log as
+            // above.
+            catch (Throwable e) {
+                ExceptionUtils.handleThrowable(e);
+                // any other exception or error is odd. Here we log it
+                // with "ERROR" level, so it will show up even on
+                // less-than-verbose logs.
+                getLog().error(sm.getString("http11protocol.proto.error"), e);
+            }
+            release(socket, processor, true, false);
+            return SocketState.CLOSED;
+        }
+        
+        protected abstract P createProcessor();
+        protected abstract void initSsl(SocketWrapper<S> socket, P processor);
+        protected abstract void longPoll(SocketWrapper<S> socket, P processor);
+        protected abstract void release(SocketWrapper<S> socket, P processor,
+                boolean socketClosing, boolean addToPoller);        
+    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Fri Jul  8 17:19:38
2011
@@ -45,7 +45,7 @@ import org.apache.tomcat.util.net.Socket
  *
  * @author Remy Maucherat
  */
-public class Http11AprProcessor extends AbstractHttp11Processor {
+public class Http11AprProcessor extends AbstractHttp11Processor<Long> {
 
 
     private static final Log log = LogFactory.getLog(Http11AprProcessor.class);
@@ -163,6 +163,7 @@ public class Http11AprProcessor extends 
      *
      * @throws IOException error during an I/O operation
      */
+    @Override
     public SocketState process(SocketWrapper<Long> socket)
         throws IOException {
         RequestInfo rp = request.getRequestProcessor();

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Fri Jul  8 17:19:38
2011
@@ -14,19 +14,14 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.coyote.http11;
 
-import java.util.concurrent.ConcurrentHashMap;
-
 import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.AprEndpoint;
 import org.apache.tomcat.util.net.AprEndpoint.Handler;
-import org.apache.tomcat.util.net.SocketStatus;
 import org.apache.tomcat.util.net.SocketWrapper;
 
 
@@ -182,16 +177,10 @@ public class Http11AprProtocol extends A
     // --------------------  Connection handler --------------------
 
     protected static class Http11ConnectionHandler
-            extends AbstractConnectionHandler implements Handler {
+            extends AbstractHttp11ConnectionHandler<Long,Http11AprProcessor> implements
Handler {
         
         protected Http11AprProtocol proto;
         
-        protected ConcurrentHashMap<Long, Http11AprProcessor> connections =
-            new ConcurrentHashMap<Long, Http11AprProcessor>();
-
-        protected RecycledProcessors<Http11AprProcessor> recycledProcessors =
-            new RecycledProcessors<Http11AprProcessor>(this);
-
         Http11ConnectionHandler(Http11AprProtocol proto) {
             this.proto = proto;
         }
@@ -220,6 +209,7 @@ public class Http11AprProtocol extends A
          * @param isSocketClosing   Not used in HTTP
          * @param addToPoller
          */
+        @Override
         public void release(SocketWrapper<Long> socket,
                 Http11AprProcessor processor, boolean isSocketClosing,
                 boolean addToPoller) {
@@ -232,83 +222,15 @@ public class Http11AprProtocol extends A
         }
 
         @Override
-        public SocketState process(SocketWrapper<Long> socket,
-                SocketStatus status) {
-            Http11AprProcessor processor = connections.remove(socket.getSocket());
-            
-            socket.setAsync(false);
-
-            try {
-                if (processor == null) {
-                    processor = recycledProcessors.poll();
-                }
-                if (processor == null) {
-                    processor = createProcessor();
-                }
-
-                initSsl(socket, processor);
-
-                SocketState state = SocketState.CLOSED;
-                do {
-                    if (processor.isAsync() || state == SocketState.ASYNC_END) {
-                        state = processor.asyncDispatch(status);
-                    } else if (processor.comet) {
-                        state = processor.event(status);
-                    } else {
-                        state = processor.process(socket);
-                    }
-
-                    if (state != SocketState.CLOSED && processor.isAsync()) {
-                        state = processor.asyncPostProcess();
-                    }
-                } while (state == SocketState.ASYNC_END);
-
-                if (state == SocketState.LONG) {
-                    // In the middle of processing a request/response. Keep the
-                    // socket associated with the processor. Exact requirements
-                    // depend on type of long poll
-                    longPoll(socket, processor);
-                } else if (state == SocketState.OPEN){
-                    // In keep-alive but between requests. OK to recycle
-                    // processor. Continue to poll for the next request.
-                    release(socket, processor, false, true);
-                } else {
-                    // Connection closed. OK to recycle the processor.
-                    release(socket, processor, true, false);
-                }
-                return state;
-            } catch (java.net.SocketException e) {
-                // SocketExceptions are normal
-                log.debug(sm.getString(
-                        "http11protocol.proto.socketexception.debug"), e);
-            } catch (java.io.IOException e) {
-                // IOExceptions are normal
-                log.debug(sm.getString(
-                        "http11protocol.proto.ioexception.debug"), e);
-            }
-            // Future developers: if you discover any other
-            // rare-but-nonfatal exceptions, catch them here, and log as
-            // above.
-            catch (Throwable e) {
-                ExceptionUtils.handleThrowable(e);
-                // any other exception or error is odd. Here we log it
-                // with "ERROR" level, so it will show up even on
-                // less-than-verbose logs.
-                log.error(sm.getString("http11protocol.proto.error"), e);
-            }
-            release(socket, processor, true, false);
-            return SocketState.CLOSED;
-        }
-
-        @SuppressWarnings("unused")
-        private void initSsl(SocketWrapper<Long> socket,
+        protected void initSsl(SocketWrapper<Long> socket,
                 Http11AprProcessor processor) {
             // NOOP for APR
         }
 
-        private void longPoll(SocketWrapper<Long> socket,
+        @Override
+        protected void longPoll(SocketWrapper<Long> socket,
                 Http11AprProcessor processor) {
-            connections.put(socket.getSocket(), processor);
+            connections.put(socket, processor);
 
             if (processor.isAsync()) {
                 socket.setAsync(true);
@@ -318,6 +240,7 @@ public class Http11AprProtocol extends A
             }
         }
 
+        @Override
         protected Http11AprProcessor createProcessor() {
             Http11AprProcessor processor = new Http11AprProcessor(
                     proto.getMaxHttpHeaderSize(), (AprEndpoint)proto.endpoint,

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Fri Jul  8 17:19:38
2011
@@ -45,7 +45,7 @@ import org.apache.tomcat.util.net.Socket
  * @author Remy Maucherat
  * @author Filip Hanik
  */
-public class Http11NioProcessor extends AbstractHttp11Processor {
+public class Http11NioProcessor extends AbstractHttp11Processor<NioChannel> {
 
     private static final Log log = LogFactory.getLog(Http11NioProcessor.class);
     @Override
@@ -194,6 +194,7 @@ public class Http11NioProcessor extends 
      *
      * @throws IOException error during an I/O operation
      */
+    @Override
     public SocketState process(SocketWrapper<NioChannel> socket)
         throws IOException {
         RequestInfo rp = request.getRequestProcessor();

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Fri Jul  8 17:19:38
2011
@@ -14,18 +14,15 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.coyote.http11;
 
 import java.nio.channels.SelectionKey;
 import java.nio.channels.SocketChannel;
 import java.util.Iterator;
-import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.NioChannel;
 import org.apache.tomcat.util.net.NioEndpoint;
@@ -33,7 +30,6 @@ import org.apache.tomcat.util.net.NioEnd
 import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment;
 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;
 
 
@@ -152,16 +148,11 @@ public class Http11NioProtocol extends A
     // --------------------  Connection handler --------------------
 
     protected static class Http11ConnectionHandler
-            extends AbstractConnectionHandler implements Handler {
+            extends AbstractHttp11ConnectionHandler<NioChannel,Http11NioProcessor>
+            implements Handler {
 
         protected Http11NioProtocol proto;
 
-        protected ConcurrentHashMap<SocketWrapper<NioChannel>, Http11NioProcessor>
connections =
-            new ConcurrentHashMap<SocketWrapper<NioChannel>, Http11NioProcessor>();
-
-        protected RecycledProcessors<Http11NioProcessor> recycledProcessors =
-            new RecycledProcessors<Http11NioProcessor>(this);
-
         Http11ConnectionHandler(Http11NioProtocol proto) {
             this.proto = proto;
         }
@@ -182,11 +173,6 @@ public class Http11NioProtocol extends A
             return proto.sslImplementation;
         }
 
-        @Override
-        public void recycle() {
-            recycledProcessors.clear();
-        }
-        
         /**
          * Expected to be used by the Poller to release resources on socket
          * close, errors etc.
@@ -235,6 +221,7 @@ public class Http11NioProtocol extends A
          * @param isSocketClosing   Not used in HTTP
          * @param addToPoller
          */
+        @Override
         public void release(SocketWrapper<NioChannel> socket,
                 Http11NioProcessor processor, boolean isSocketClosing,
                 boolean addToPoller) {
@@ -247,75 +234,7 @@ public class Http11NioProtocol extends A
 
 
         @Override
-        public SocketState process(SocketWrapper<NioChannel> socket,
-                SocketStatus status) {
-            Http11NioProcessor processor = connections.remove(socket);
-
-            socket.setAsync(false); //no longer check for timeout
-
-            try {
-                if (processor == null) {
-                    processor = recycledProcessors.poll();
-                }
-                if (processor == null) {
-                    processor = createProcessor();
-                }
-
-                initSsl(socket, processor);
-
-                SocketState state = SocketState.CLOSED;
-                do {
-                    if (processor.isAsync() || state == SocketState.ASYNC_END) {
-                        state = processor.asyncDispatch(status);
-                    } else if (processor.comet) {
-                        state = processor.event(status);
-                    } else {
-                        state = processor.process(socket);
-                    }
-
-                    if (state != SocketState.CLOSED && processor.isAsync()) {
-                        state = processor.asyncPostProcess();
-                    }
-                } while (state == SocketState.ASYNC_END);
-
-                if (state == SocketState.LONG) {
-                    // In the middle of processing a request/response. Keep the
-                    // socket associated with the processor. Exact requirements
-                    // depend on type of long poll
-                    longPoll(socket, processor);
-                } else if (state == SocketState.OPEN){
-                    // In keep-alive but between requests. OK to recycle
-                    // processor. Continue to poll for the next request.
-                    release(socket, processor, false, true);
-                } else {
-                    // Connection closed. OK to recycle the processor.
-                    release(socket, processor, true, false);
-                }
-                return state;
-            } catch (java.net.SocketException e) {
-                // SocketExceptions are normal
-                log.debug(sm.getString(
-                        "http11protocol.proto.socketexception.debug"), e);
-            } catch (java.io.IOException e) {
-                // IOExceptions are normal
-                log.debug(sm.getString(
-                        "http11protocol.proto.ioexception.debug"), e);
-            }
-            // Future developers: if you discover any other
-            // rare-but-nonfatal exceptions, catch them here, and log as
-            // above.
-            catch (Throwable e) {
-                ExceptionUtils.handleThrowable(e);
-                // any other exception or error is odd. Here we log it
-                // with "ERROR" level, so it will show up even on
-                // less-than-verbose logs.
-                log.error(sm.getString("http11protocol.proto.error"), e);
-            }
-            release(socket, processor, true, false);
-            return SocketState.CLOSED;
-        }
-
-        private void initSsl(SocketWrapper<NioChannel> socket,
+        protected void initSsl(SocketWrapper<NioChannel> socket,
                 Http11NioProcessor processor) {
             if (proto.isSSLEnabled() &&
                     (proto.sslImplementation != null)
@@ -330,7 +249,8 @@ public class Http11NioProtocol extends A
 
         }
 
-        private void longPoll(SocketWrapper<NioChannel> socket,
+        @Override
+        protected void longPoll(SocketWrapper<NioChannel> socket,
                 Http11NioProcessor processor) {
             connections.put(socket, processor);
             
@@ -349,6 +269,7 @@ public class Http11NioProtocol extends A
             }
         }
 
+        @Override
         public Http11NioProcessor createProcessor() {
             Http11NioProcessor processor = new Http11NioProcessor(
                     proto.getMaxHttpHeaderSize(), (NioEndpoint)proto.endpoint,

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Fri Jul  8 17:19:38 2011
@@ -41,7 +41,7 @@ import org.apache.tomcat.util.net.Socket
  * @author Remy Maucherat
  * @author fhanik
  */
-public class Http11Processor extends AbstractHttp11Processor {
+public class Http11Processor extends AbstractHttp11Processor<Socket> {
 
     private static final Log log = LogFactory.getLog(Http11Processor.class);
     @Override
@@ -129,6 +129,7 @@ public class Http11Processor extends Abs
      *  
      * @throws IOException error during an I/O operation
      */
+    @Override
     public SocketState process(SocketWrapper<Socket> socketWrapper)
         throws IOException {
         RequestInfo rp = request.getRequestProcessor();

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1144391&r1=1144390&r2=1144391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Fri Jul  8 17:19:38 2011
@@ -14,20 +14,16 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-
 package org.apache.coyote.http11;
 
 import java.net.Socket;
-import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.coyote.AbstractProtocol;
 import org.apache.juli.logging.Log;
-import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.net.AbstractEndpoint;
 import org.apache.tomcat.util.net.JIoEndpoint;
 import org.apache.tomcat.util.net.JIoEndpoint.Handler;
 import org.apache.tomcat.util.net.SSLImplementation;
-import org.apache.tomcat.util.net.SocketStatus;
 import org.apache.tomcat.util.net.SocketWrapper;
 
 
@@ -101,16 +97,10 @@ public class Http11Protocol extends Abst
     // -----------------------------------  Http11ConnectionHandler Inner Class
 
     protected static class Http11ConnectionHandler
-            extends AbstractConnectionHandler implements Handler {
+            extends AbstractHttp11ConnectionHandler<Socket, Http11Processor> implements
Handler {
 
         protected Http11Protocol proto;
             
-        protected ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor> connections
=
-            new ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor>();
-
-        protected RecycledProcessors<Http11Processor> recycledProcessors =
-            new RecycledProcessors<Http11Processor>(this);
-
         Http11ConnectionHandler(Http11Protocol proto) {
             this.proto = proto;
         }
@@ -130,11 +120,6 @@ public class Http11Protocol extends Abst
             return proto.sslImplementation;
         }
 
-        @Override
-        public void recycle() {
-            recycledProcessors.clear();
-        }
-
         /**
          * Expected to be used by the handler once the processor is no longer
          * required.
@@ -144,6 +129,7 @@ public class Http11Protocol extends Abst
          * @param isSocketClosing   Not used in HTTP
          * @param addToPoller       Not used in BIO
          */
+        @Override
         public void release(SocketWrapper<Socket> socket,
                 Http11Processor processor, boolean isSocketClosing,
                 boolean addToPoller) {
@@ -152,75 +138,7 @@ public class Http11Protocol extends Abst
         }
 
         @Override
-        public SocketState process(SocketWrapper<Socket> socket,
-                SocketStatus status) {
-            Http11Processor processor = connections.remove(socket);
-
-            socket.setAsync(false); //no longer check for timeout
-
-            try {
-                if (processor == null) {
-                    processor = recycledProcessors.poll();
-                }
-                if (processor == null) {
-                    processor = createProcessor();
-                }
-
-                initSsl(socket, processor);
-                
-                SocketState state = SocketState.CLOSED;
-                do {
-                    if (processor.isAsync() || state == SocketState.ASYNC_END) {
-                        state = processor.asyncDispatch(status);
-                    } else if (processor.comet) {
-                        state = processor.event(status);
-                    } else {
-                        state = processor.process(socket);
-                    }
-    
-                    if (state != SocketState.CLOSED && processor.isAsync()) {
-                        state = processor.asyncPostProcess();
-                    }
-                } while (state == SocketState.ASYNC_END);
-
-                if (state == SocketState.LONG) {
-                    // In the middle of processing a request/response. Keep the
-                    // socket associated with the processor. Exact requirements
-                    // depend on type of long poll
-                    longPoll(socket, processor);
-                } else if (state == SocketState.OPEN){
-                    // In keep-alive but between requests. OK to recycle
-                    // processor. Continue to poll for the next request.
-                    release(socket, processor, false, true);
-                } else {
-                    // Connection closed. OK to recycle the processor.
-                    release(socket, processor, true, false);
-                }
-                return state;
-            } catch(java.net.SocketException e) {
-                // SocketExceptions are normal
-                log.debug(sm.getString(
-                        "http11protocol.proto.socketexception.debug"), e);
-            } catch (java.io.IOException e) {
-                // IOExceptions are normal
-                log.debug(sm.getString(
-                        "http11protocol.proto.ioexception.debug"), e);
-            }
-            // Future developers: if you discover any other
-            // rare-but-nonfatal exceptions, catch them here, and log as
-            // above.
-            catch (Throwable e) {
-                ExceptionUtils.handleThrowable(e);
-                // any other exception or error is odd. Here we log it
-                // with "ERROR" level, so it will show up even on
-                // less-than-verbose logs.
-                log.error(sm.getString("http11protocol.proto.error"), e);
-            }
-            release(socket, processor, true, false);
-            return SocketState.CLOSED;
-        }
-        
-        private void initSsl(SocketWrapper<Socket> socket,
+        protected void initSsl(SocketWrapper<Socket> socket,
                 Http11Processor processor) {
             if (proto.isSSLEnabled() && (proto.sslImplementation != null)) {
                 processor.setSSLSupport(
@@ -232,11 +150,13 @@ public class Http11Protocol extends Abst
 
         }
 
-        private void longPoll(SocketWrapper<Socket> socket,
+        @Override
+        protected void longPoll(SocketWrapper<Socket> socket,
                 Http11Processor processor) {
             connections.put(socket, processor);
         }
 
+        @Override
         protected Http11Processor createProcessor() {
             Http11Processor processor = new Http11Processor(
                     proto.getMaxHttpHeaderSize(), (JIoEndpoint)proto.endpoint,



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message