- Refactor using the new java.io endpoint. Hopefully, I did not make any mistake.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 24 Apr 2006 15:32:40 +0000 (15:32 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 24 Apr 2006 15:32:40 +0000 (15:32 +0000)
- I will now test a bit, and will attempt to extract superclasses (most likely BaseEndpoint,
  BaseProtocol, BaseHttpProtocol).

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

java/org/apache/coyote/http11/Http11BaseProtocol.java [deleted file]
java/org/apache/coyote/http11/Http11Processor.java
java/org/apache/coyote/http11/Http11Protocol.java

diff --git a/java/org/apache/coyote/http11/Http11BaseProtocol.java b/java/org/apache/coyote/http11/Http11BaseProtocol.java
deleted file mode 100644 (file)
index 1825ebb..0000000
+++ /dev/null
@@ -1,746 +0,0 @@
-/*\r
- *  Copyright 1999-2004 The Apache Software Foundation\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.apache.coyote.http11;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.net.InetAddress;\r
-import java.net.Socket;\r
-import java.net.URLEncoder;\r
-import java.util.Enumeration;\r
-import java.util.Hashtable;\r
-import java.util.Iterator;\r
-\r
-import org.apache.coyote.ActionCode;\r
-import org.apache.coyote.ActionHook;\r
-import org.apache.coyote.Adapter;\r
-import org.apache.coyote.ProtocolHandler;\r
-import org.apache.coyote.RequestGroupInfo;\r
-import org.apache.tomcat.util.net.PoolTcpEndpoint;\r
-import org.apache.tomcat.util.net.SSLImplementation;\r
-import org.apache.tomcat.util.net.SSLSupport;\r
-import org.apache.tomcat.util.net.ServerSocketFactory;\r
-import org.apache.tomcat.util.net.TcpConnection;\r
-import org.apache.tomcat.util.net.TcpConnectionHandler;\r
-import org.apache.tomcat.util.res.StringManager;\r
-import org.apache.tomcat.util.threads.ThreadPool;\r
-\r
-\r
-/**\r
- * Abstract the protocol implementation, including threading, etc.\r
- * Processor is single threaded and specific to stream-based protocols,\r
- * will not fit Jk protocols like JNI.\r
- *\r
- * @author Remy Maucherat\r
- * @author Costin Manolache\r
- */\r
-public class Http11BaseProtocol implements ProtocolHandler\r
-{\r
-    public Http11BaseProtocol() {\r
-        setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);\r
-        setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);\r
-        setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);\r
-        setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);\r
-    }\r
-\r
-    /**\r
-     * The string manager for this package.\r
-     */\r
-    protected static StringManager sm =\r
-        StringManager.getManager(Constants.Package);\r
-\r
-    /** Pass config info\r
-     */\r
-    public void setAttribute( String name, Object value ) {\r
-        if( log.isTraceEnabled())\r
-            log.trace(sm.getString("http11protocol.setattribute", name, value));\r
-\r
-        attributes.put(name, value);\r
-    }\r
-\r
-    public Object getAttribute( String key ) {\r
-        if( log.isTraceEnabled())\r
-            log.trace(sm.getString("http11protocol.getattribute", key));\r
-        return attributes.get(key);\r
-    }\r
-\r
-    public Iterator getAttributeNames() {\r
-        return attributes.keySet().iterator();\r
-    }\r
-\r
-    /**\r
-     * Set a property.\r
-     */\r
-    public void setProperty(String name, String value) {\r
-        setAttribute(name, value);\r
-    }\r
-\r
-    /**\r
-     * Get a property\r
-     */\r
-    public String getProperty(String name) {\r
-        return (String)getAttribute(name);\r
-    }\r
-\r
-    /** The adapter, used to call the connector\r
-     */\r
-    public void setAdapter(Adapter adapter) {\r
-        this.adapter=adapter;\r
-    }\r
-\r
-    public Adapter getAdapter() {\r
-        return adapter;\r
-    }\r
-    \r
-    protected Http11ConnectionHandler createConnectionHandler() {\r
-        return new Http11ConnectionHandler( this );\r
-    }\r
-\r
-    /** Start the protocol\r
-     */\r
-    public void init() throws Exception {\r
-        cHandler = createConnectionHandler() ;\r
-        ep.setConnectionHandler( cHandler );\r
-        try {\r
-            checkSocketFactory();\r
-        } catch( Exception ex ) {\r
-            log.error(sm.getString("http11protocol.socketfactory.initerror"),\r
-                      ex);\r
-            throw ex;\r
-        }\r
-\r
-        if( socketFactory!=null ) {\r
-            Enumeration attE=attributes.keys();\r
-            while( attE.hasMoreElements() ) {\r
-                String key=(String)attE.nextElement();\r
-                Object v=attributes.get( key );\r
-                socketFactory.setAttribute( key, v );\r
-            }\r
-        }\r
-\r
-        // XXX get domain from registration\r
-        try {\r
-            ep.initEndpoint();\r
-        } catch (Exception ex) {\r
-            log.error(sm.getString("http11protocol.endpoint.initerror"), ex);\r
-            throw ex;\r
-        }\r
-        if(log.isInfoEnabled())\r
-            log.info(sm.getString("http11protocol.init", getName()));\r
-\r
-    }\r
-\r
-    public void start() throws Exception {\r
-        try {\r
-            ep.startEndpoint();\r
-        } catch (Exception ex) {\r
-            log.error(sm.getString("http11protocol.endpoint.starterror"), ex);\r
-            throw ex;\r
-        }\r
-        if(log.isInfoEnabled())\r
-            log.info(sm.getString("http11protocol.start", getName()));\r
-    }\r
-\r
-    public void pause() throws Exception {\r
-        try {\r
-            ep.pauseEndpoint();\r
-        } catch (Exception ex) {\r
-            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);\r
-            throw ex;\r
-        }\r
-        if(log.isInfoEnabled())\r
-            log.info(sm.getString("http11protocol.pause", getName()));\r
-    }\r
-\r
-    public void resume() throws Exception {\r
-        try {\r
-            ep.resumeEndpoint();\r
-        } catch (Exception ex) {\r
-            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);\r
-            throw ex;\r
-        }\r
-        if(log.isInfoEnabled())\r
-            log.info(sm.getString("http11protocol.resume", getName()));\r
-    }\r
-\r
-    public void destroy() throws Exception {\r
-        if(log.isInfoEnabled())\r
-            log.info(sm.getString("http11protocol.stop", getName()));\r
-        ep.stopEndpoint();\r
-    }\r
-\r
-    // -------------------- Properties--------------------\r
-    protected ThreadPool tp=ThreadPool.createThreadPool(true);\r
-    protected PoolTcpEndpoint ep=new PoolTcpEndpoint(tp);\r
-    protected boolean secure;\r
-\r
-    protected ServerSocketFactory socketFactory;\r
-    protected SSLImplementation sslImplementation;\r
-    // socket factory attriubtes ( XXX replace with normal setters )\r
-    protected Hashtable attributes = new Hashtable();\r
-    protected String socketFactoryName=null;\r
-    protected String sslImplementationName=null;\r
-\r
-    private int maxKeepAliveRequests=100; // as in Apache HTTPD server\r
-    private int timeout = 300000;   // 5 minutes as in Apache HTTPD server\r
-    private int maxSavePostSize = 4 * 1024;\r
-    private int maxHttpHeaderSize = 8 * 1024;\r
-    private String reportedname;\r
-    private int socketCloseDelay=-1;\r
-    private boolean disableUploadTimeout = true;\r
-    private int socketBuffer = 9000;\r
-    private Adapter adapter;\r
-    protected Http11ConnectionHandler cHandler;\r
-\r
-    /**\r
-     * Compression value.\r
-     */\r
-    private String compression = "off";\r
-    private String noCompressionUserAgents = null;\r
-    private String restrictedUserAgents = null;\r
-    private String compressableMimeTypes = "text/html,text/xml,text/plain";\r
-    private int compressionMinSize    = 2048;\r
-\r
-    private String server;\r
-\r
-    // -------------------- Pool setup --------------------\r
-\r
-    public int getMaxThreads() {\r
-        return ep.getMaxThreads();\r
-    }\r
-\r
-    public void setMaxThreads( int maxThreads ) {\r
-        ep.setMaxThreads(maxThreads);\r
-        setAttribute("maxThreads", "" + maxThreads);\r
-    }\r
-\r
-    public int getMaxSpareThreads() {\r
-        return ep.getMaxSpareThreads();\r
-    }\r
-\r
-    public void setMaxSpareThreads( int maxThreads ) {\r
-        ep.setMaxSpareThreads(maxThreads);\r
-        setAttribute("maxSpareThreads", "" + maxThreads);\r
-    }\r
-\r
-    public int getMinSpareThreads() {\r
-        return ep.getMinSpareThreads();\r
-    }\r
-\r
-    public void setMinSpareThreads( int minSpareThreads ) {\r
-        ep.setMinSpareThreads(minSpareThreads);\r
-        setAttribute("minSpareThreads", "" + minSpareThreads);\r
-    }\r
-\r
-    public void setThreadPriority(int threadPriority) {\r
-      ep.setThreadPriority(threadPriority);\r
-      setAttribute("threadPriority", "" + threadPriority);\r
-    }\r
-\r
-    public int getThreadPriority() {\r
-      return ep.getThreadPriority();\r
-    }\r
-\r
-    public void setStrategy(String strategy) {\r
-        ep.setStrategy(strategy);\r
-        setAttribute("strategy", strategy);\r
-      }\r
-\r
-      public String getStrategy() {\r
-        return ep.getStrategy();\r
-      }\r
-\r
-    // -------------------- Tcp setup --------------------\r
-\r
-    public int getBacklog() {\r
-        return ep.getBacklog();\r
-    }\r
-\r
-    public void setBacklog( int i ) {\r
-        ep.setBacklog(i);\r
-        setAttribute("backlog", "" + i);\r
-    }\r
-\r
-    public int getPort() {\r
-        return ep.getPort();\r
-    }\r
-\r
-    public void setPort( int port ) {\r
-        ep.setPort(port);\r
-        setAttribute("port", "" + port);\r
-    }\r
-\r
-    public InetAddress getAddress() {\r
-        return ep.getAddress();\r
-    }\r
-\r
-    public void setAddress(InetAddress ia) {\r
-        ep.setAddress( ia );\r
-        setAttribute("address", "" + ia);\r
-    }\r
-\r
-    public String getName() {\r
-        String encodedAddr = "";\r
-        if (getAddress() != null) {\r
-            encodedAddr = "" + getAddress();\r
-            if (encodedAddr.startsWith("/"))\r
-                encodedAddr = encodedAddr.substring(1);\r
-            encodedAddr = URLEncoder.encode(encodedAddr) + "-";\r
-        }\r
-        return ("http-" + encodedAddr + ep.getPort());\r
-    }\r
-\r
-    public String getSocketFactory() {\r
-        return socketFactoryName;\r
-    }\r
-\r
-    public void setSocketFactory( String valueS ) {\r
-        socketFactoryName = valueS;\r
-        setAttribute("socketFactory", valueS);\r
-    }\r
-\r
-    public String getSSLImplementation() {\r
-        return sslImplementationName;\r
-    }\r
-\r
-    public void setSSLImplementation( String valueS) {\r
-        sslImplementationName = valueS;\r
-        setSecure(true);\r
-        setAttribute("sslImplementation", valueS);\r
-    }\r
-\r
-    public boolean getTcpNoDelay() {\r
-        return ep.getTcpNoDelay();\r
-    }\r
-\r
-    public void setTcpNoDelay( boolean b ) {\r
-        ep.setTcpNoDelay( b );\r
-        setAttribute("tcpNoDelay", "" + b);\r
-    }\r
-\r
-    public boolean getDisableUploadTimeout() {\r
-        return disableUploadTimeout;\r
-    }\r
-\r
-    public void setDisableUploadTimeout(boolean isDisabled) {\r
-        disableUploadTimeout = isDisabled;\r
-    }\r
-\r
-    public int getSocketBuffer() {\r
-        return socketBuffer;\r
-    }\r
-\r
-    public void setSocketBuffer(int valueI) {\r
-        socketBuffer = valueI;\r
-    }\r
-\r
-    public String getCompression() {\r
-        return compression;\r
-    }\r
-\r
-    public void setCompression(String valueS) {\r
-        compression = valueS;\r
-        setAttribute("compression", valueS);\r
-    }\r
-\r
-    public int getMaxSavePostSize() {\r
-        return maxSavePostSize;\r
-    }\r
-\r
-    public void setMaxSavePostSize(int valueI) {\r
-        maxSavePostSize = valueI;\r
-        setAttribute("maxSavePostSize", "" + valueI);\r
-    }\r
-\r
-    public int getMaxHttpHeaderSize() {\r
-        return maxHttpHeaderSize;\r
-    }\r
-\r
-    public void setMaxHttpHeaderSize(int valueI) {\r
-        maxHttpHeaderSize = valueI;\r
-        setAttribute("maxHttpHeaderSize", "" + valueI);\r
-    }\r
-\r
-    public String getRestrictedUserAgents() {\r
-        return restrictedUserAgents;\r
-    }\r
-\r
-    public void setRestrictedUserAgents(String valueS) {\r
-        restrictedUserAgents = valueS;\r
-        setAttribute("restrictedUserAgents", valueS);\r
-    }\r
-\r
-    public String getNoCompressionUserAgents() {\r
-        return noCompressionUserAgents;\r
-    }\r
-\r
-    public void setNoCompressionUserAgents(String valueS) {\r
-        noCompressionUserAgents = valueS;\r
-        setAttribute("noCompressionUserAgents", valueS);\r
-    }\r
-\r
-    public String getCompressableMimeType() {\r
-        return compressableMimeTypes;\r
-    }\r
-\r
-    public void setCompressableMimeType(String valueS) {\r
-        compressableMimeTypes = valueS;\r
-        setAttribute("compressableMimeTypes", valueS);\r
-    }\r
-\r
-    public int getCompressionMinSize() {\r
-        return compressionMinSize;\r
-    }\r
-\r
-    public void setCompressionMinSize(int valueI) {\r
-        compressionMinSize = valueI;\r
-        setAttribute("compressionMinSize", "" + valueI);\r
-    }\r
-\r
-    public int getSoLinger() {\r
-        return ep.getSoLinger();\r
-    }\r
-\r
-    public void setSoLinger( int i ) {\r
-        ep.setSoLinger( i );\r
-        setAttribute("soLinger", "" + i);\r
-    }\r
-\r
-    public int getSoTimeout() {\r
-        return ep.getSoTimeout();\r
-    }\r
-\r
-    public void setSoTimeout( int i ) {\r
-        ep.setSoTimeout(i);\r
-        setAttribute("soTimeout", "" + i);\r
-    }\r
-\r
-    public int getServerSoTimeout() {\r
-        return ep.getServerSoTimeout();\r
-    }\r
-\r
-    public void setServerSoTimeout( int i ) {\r
-        ep.setServerSoTimeout(i);\r
-        setAttribute("serverSoTimeout", "" + i);\r
-    }\r
-\r
-    public String getKeystore() {\r
-        return getProperty("keystore");\r
-    }\r
-\r
-    public void setKeystore( String k ) {\r
-        setAttribute("keystore", k);\r
-    }\r
-\r
-    public String getKeypass() {\r
-        return getProperty("keypass");\r
-    }\r
-\r
-    public void setKeypass( String k ) {\r
-        attributes.put("keypass", k);\r
-        //setAttribute("keypass", k);\r
-    }\r
-\r
-    public String getKeytype() {\r
-        return getProperty("keystoreType");\r
-    }\r
-\r
-    public void setKeytype( String k ) {\r
-        setAttribute("keystoreType", k);\r
-    }\r
-\r
-    public String getClientauth() {\r
-        return getProperty("clientauth");\r
-    }\r
-\r
-    public void setClientauth( String k ) {\r
-        setAttribute("clientauth", k);\r
-    }\r
-\r
-    public String getProtocol() {\r
-        return getProperty("protocol");\r
-    }\r
-\r
-    public void setProtocol( String k ) {\r
-        setSecure(true);\r
-        setAttribute("protocol", k);\r
-    }\r
-\r
-    public String getProtocols() {\r
-        return getProperty("protocols");\r
-    }\r
-\r
-    public void setProtocols(String k) {\r
-        setAttribute("protocols", k);\r
-    }\r
-\r
-    public String getAlgorithm() {\r
-        return getProperty("algorithm");\r
-    }\r
-\r
-    public void setAlgorithm( String k ) {\r
-        setAttribute("algorithm", k);\r
-    }\r
-\r
-    public boolean getSecure() {\r
-        return secure;\r
-    }\r
-\r
-    public void setSecure( boolean b ) {\r
-        secure=b;\r
-        setAttribute("secure", "" + b);\r
-    }\r
-\r
-    public String getCiphers() {\r
-        return getProperty("ciphers");\r
-    }\r
-\r
-    public void setCiphers(String ciphers) {\r
-        setAttribute("ciphers", ciphers);\r
-    }\r
-\r
-    public String getKeyAlias() {\r
-        return getProperty("keyAlias");\r
-    }\r
-\r
-    public void setKeyAlias(String keyAlias) {\r
-        setAttribute("keyAlias", keyAlias);\r
-    }\r
-\r
-    public int getMaxKeepAliveRequests() {\r
-        return maxKeepAliveRequests;\r
-    }\r
-\r
-    /** Set the maximum number of Keep-Alive requests that we will honor.\r
-     */\r
-    public void setMaxKeepAliveRequests(int mkar) {\r
-        maxKeepAliveRequests = mkar;\r
-        setAttribute("maxKeepAliveRequests", "" + mkar);\r
-    }\r
-\r
-    /**\r
-     * Return the Keep-Alive policy for the connection.\r
-     */\r
-    public boolean getKeepAlive() {\r
-        return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));\r
-    }\r
-\r
-    /**\r
-     * Set the keep-alive policy for this connection.\r
-     */\r
-    public void setKeepAlive(boolean keepAlive) {\r
-        if (!keepAlive) {\r
-            setMaxKeepAliveRequests(1);\r
-        }\r
-    }\r
-\r
-    public int getSocketCloseDelay() {\r
-        return socketCloseDelay;\r
-    }\r
-\r
-    public void setSocketCloseDelay( int d ) {\r
-        socketCloseDelay=d;\r
-        setAttribute("socketCloseDelay", "" + d);\r
-    }\r
-\r
-    public void setServer( String server ) {\r
-        this.server = server;\r
-    }\r
-\r
-    public String getServer() {\r
-        return server;\r
-    }\r
-\r
-\r
-    private static ServerSocketFactory string2SocketFactory( String val)\r
-    throws ClassNotFoundException, IllegalAccessException,\r
-    InstantiationException\r
-    {\r
-        Class chC=Class.forName( val );\r
-        return (ServerSocketFactory)chC.newInstance();\r
-    }\r
-\r
-    public int getTimeout() {\r
-        return timeout;\r
-    }\r
-\r
-    public void setTimeout( int timeouts ) {\r
-        timeout = timeouts;\r
-        setAttribute("timeout", "" + timeouts);\r
-    }\r
-\r
-    public String getReportedname() {\r
-        return reportedname;\r
-    }\r
-\r
-    public void setReportedname( String reportedName) {\r
-        reportedname = reportedName;\r
-    }\r
-\r
-    // --------------------  Connection handler --------------------\r
-    public static final int THREAD_DATA_PROCESSOR=1;\r
-    public static final int THREAD_DATA_OBJECT_NAME=2;\r
-\r
-    static class Http11ConnectionHandler implements TcpConnectionHandler {\r
-        Http11BaseProtocol proto;\r
-        static int count=0;\r
-        RequestGroupInfo global=new RequestGroupInfo();\r
-\r
-        Http11ConnectionHandler( Http11BaseProtocol proto ) {\r
-            this.proto=proto;\r
-        }\r
-\r
-        public void setAttribute( String name, Object value ) {\r
-        }\r
-\r
-        public void setServer( Object o ) {\r
-        }\r
-\r
-        public Object[] init() {\r
-            Object thData[]=new Object[3];\r
-\r
-            Http11Processor  processor =\r
-                new Http11Processor(proto.maxHttpHeaderSize);\r
-            processor.setAdapter( proto.adapter );\r
-            processor.setThreadPool( proto.tp );\r
-            processor.setEndpoint( proto.ep );\r
-            processor.setMaxKeepAliveRequests( proto.maxKeepAliveRequests );\r
-            processor.setTimeout( proto.timeout );\r
-            processor.setDisableUploadTimeout( proto.disableUploadTimeout );\r
-            processor.setCompression( proto.compression );\r
-            processor.setCompressionMinSize( proto.compressionMinSize);\r
-            processor.setNoCompressionUserAgents( proto.noCompressionUserAgents);\r
-            processor.setCompressableMimeTypes( proto.compressableMimeTypes);\r
-            processor.setRestrictedUserAgents( proto.restrictedUserAgents);\r
-            processor.setSocketBuffer( proto.socketBuffer );\r
-            processor.setMaxSavePostSize( proto.maxSavePostSize );\r
-            processor.setServer( proto.server );\r
-\r
-            thData[Http11BaseProtocol.THREAD_DATA_PROCESSOR]=processor;\r
-\r
-            return  thData;\r
-        }\r
-\r
-        public void processConnection(TcpConnection connection,\r
-                      Object thData[]) {\r
-            Socket socket=null;\r
-            Http11Processor  processor=null;\r
-            try {\r
-                processor=(Http11Processor)thData[Http11BaseProtocol.THREAD_DATA_PROCESSOR];\r
-\r
-                if (processor instanceof ActionHook) {\r
-                    ((ActionHook) processor).action(ActionCode.ACTION_START, null);\r
-                }\r
-                socket=connection.getSocket();\r
-\r
-                InputStream in = socket.getInputStream();\r
-                OutputStream out = socket.getOutputStream();\r
-\r
-                if( proto.secure ) {\r
-                    SSLSupport sslSupport=null;\r
-                    if(proto.sslImplementation != null)\r
-                        sslSupport = proto.sslImplementation.getSSLSupport(socket);\r
-                    processor.setSSLSupport(sslSupport);\r
-                } else {\r
-                    processor.setSSLSupport( null );\r
-                }\r
-                processor.setSocket( socket );\r
-\r
-                processor.process(in, out);\r
-\r
-                // If unread input arrives after the shutdownInput() call\r
-                // below and before or during the socket.close(), an error\r
-                // may be reported to the client.  To help troubleshoot this\r
-                // type of error, provide a configurable delay to give the\r
-                // unread input time to arrive so it can be successfully read\r
-                // and discarded by shutdownInput().\r
-                if( proto.socketCloseDelay >= 0 ) {\r
-                    try {\r
-                        Thread.sleep(proto.socketCloseDelay);\r
-                    } catch (InterruptedException ie) { /* ignore */ }\r
-                }\r
-\r
-                TcpConnection.shutdownInput( socket );\r
-            } catch(java.net.SocketException e) {\r
-                // SocketExceptions are normal\r
-                Http11BaseProtocol.log.debug\r
-                    (sm.getString\r
-                     ("http11protocol.proto.socketexception.debug"), e);\r
-            } catch (IOException e) {\r
-                // IOExceptions are normal\r
-                Http11BaseProtocol.log.debug\r
-                    (sm.getString\r
-                     ("http11protocol.proto.ioexception.debug"), e);\r
-            }\r
-            // Future developers: if you discover any other\r
-            // rare-but-nonfatal exceptions, catch them here, and log as\r
-            // above.\r
-            catch (Throwable e) {\r
-                // any other exception or error is odd. Here we log it\r
-                // with "ERROR" level, so it will show up even on\r
-                // less-than-verbose logs.\r
-                Http11BaseProtocol.log.error\r
-                    (sm.getString("http11protocol.proto.error"), e);\r
-            } finally {\r
-                //       if(proto.adapter != null) proto.adapter.recycle();\r
-                //                processor.recycle();\r
-\r
-                if (processor instanceof ActionHook) {\r
-                    ((ActionHook) processor).action(ActionCode.ACTION_STOP, null);\r
-                }\r
-                // recycle kernel sockets ASAP\r
-                try { if (socket != null) socket.close (); }\r
-                catch (IOException e) { /* ignore */ }\r
-            }\r
-        }\r
-    }\r
-\r
-    protected static org.apache.commons.logging.Log log\r
-        = org.apache.commons.logging.LogFactory.getLog(Http11BaseProtocol.class);\r
-\r
-    // -------------------- Various implementation classes --------------------\r
-\r
-    /** Sanity check and socketFactory setup.\r
-     *  IMHO it is better to stop the show on a broken connector,\r
-     *  then leave Tomcat running and broken.\r
-     *  @exception TomcatException Unable to resolve classes\r
-     */\r
-    private void checkSocketFactory() throws Exception {\r
-        if (secure) {\r
-            try {\r
-                // The SSL setup code has been moved into\r
-                // SSLImplementation since SocketFactory doesn't\r
-                // provide a wide enough interface\r
-                sslImplementation =\r
-                    SSLImplementation.getInstance(sslImplementationName);\r
-                socketFactory = sslImplementation.getServerSocketFactory();\r
-                ep.setServerSocketFactory(socketFactory);\r
-            } catch (ClassNotFoundException e){\r
-                throw e;\r
-            }\r
-        } else if (socketFactoryName != null) {\r
-            try {\r
-                socketFactory = string2SocketFactory(socketFactoryName);\r
-                ep.setServerSocketFactory(socketFactory);\r
-            } catch(Exception sfex) {\r
-                throw sfex;\r
-            }\r
-        }\r
-    }\r
-\r
-}\r
index ac0b8b9..ad52794 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- *  Copyright 1999-2004 The Apache Software Foundation\r
+ *  Copyright 1999-2006 The Apache Software Foundation\r
  *\r
  *  Licensed under the Apache License, Version 2.0 (the "License");\r
  *  you may not use this file except in compliance with the License.\r
@@ -22,11 +22,11 @@ import java.io.InterruptedIOException;
 import java.io.OutputStream;\r
 import java.net.InetAddress;\r
 import java.net.Socket;\r
+import java.security.AccessController;\r
+import java.security.PrivilegedAction;\r
 import java.util.StringTokenizer;\r
 import java.util.regex.Pattern;\r
 import java.util.regex.PatternSyntaxException;\r
-import java.security.AccessController;\r
-import java.security.PrivilegedAction;\r
 \r
 import org.apache.coyote.ActionCode;\r
 import org.apache.coyote.ActionHook;\r
@@ -35,6 +35,7 @@ import org.apache.coyote.Processor;
 import org.apache.coyote.Request;\r
 import org.apache.coyote.RequestInfo;\r
 import org.apache.coyote.Response;\r
+import org.apache.coyote.http11.filters.BufferedInputFilter;\r
 import org.apache.coyote.http11.filters.ChunkedInputFilter;\r
 import org.apache.coyote.http11.filters.ChunkedOutputFilter;\r
 import org.apache.coyote.http11.filters.GzipOutputFilter;\r
@@ -43,17 +44,15 @@ import org.apache.coyote.http11.filters.IdentityOutputFilter;
 import org.apache.coyote.http11.filters.SavedRequestInputFilter;\r
 import org.apache.coyote.http11.filters.VoidInputFilter;\r
 import org.apache.coyote.http11.filters.VoidOutputFilter;\r
-import org.apache.coyote.http11.filters.BufferedInputFilter;\r
 import org.apache.tomcat.util.buf.Ascii;\r
 import org.apache.tomcat.util.buf.ByteChunk;\r
 import org.apache.tomcat.util.buf.HexUtils;\r
 import org.apache.tomcat.util.buf.MessageBytes;\r
 import org.apache.tomcat.util.http.FastHttpDateFormat;\r
 import org.apache.tomcat.util.http.MimeHeaders;\r
-import org.apache.tomcat.util.net.PoolTcpEndpoint;\r
+import org.apache.tomcat.util.net.JIoEndpoint;\r
 import org.apache.tomcat.util.net.SSLSupport;\r
 import org.apache.tomcat.util.res.StringManager;\r
-import org.apache.tomcat.util.threads.ThreadPool;\r
 import org.apache.tomcat.util.threads.ThreadWithAttributes;\r
 \r
 \r
@@ -78,19 +77,13 @@ public class Http11Processor implements Processor, ActionHook {
         StringManager.getManager(Constants.Package);\r
 \r
 \r
-    // ----------------------------------------------------------- Constructors\r
+    // ------------------------------------------------------------ Constructor\r
 \r
 \r
-    /**\r
-     * Default constructor.\r
-     */\r
-    public Http11Processor() {\r
-        this(Constants.DEFAULT_HTTP_HEADER_BUFFER_SIZE);\r
-    }\r
-\r
-\r
-    public Http11Processor(int headerBufferSize) {\r
+    public Http11Processor(int headerBufferSize, JIoEndpoint endpoint) {\r
 \r
+        this.endpoint = endpoint;\r
+        \r
         request = new Request();\r
         inputBuffer = new InternalInputBuffer(request, headerBufferSize);\r
         request.setInputBuffer(inputBuffer);\r
@@ -301,15 +294,9 @@ public class Http11Processor implements Processor, ActionHook {
 \r
 \r
     /**\r
-     * Associated thread pool.\r
-     */\r
-    protected ThreadPool threadPool;\r
-\r
-\r
-    /**\r
      * Associated endpoint.\r
      */\r
-    protected PoolTcpEndpoint endpoint;\r
+    protected JIoEndpoint endpoint;\r
 \r
 \r
     /**\r
@@ -367,16 +354,6 @@ public class Http11Processor implements Processor, ActionHook {
     }\r
 \r
 \r
-    public void setThreadPool(ThreadPool threadPool) {\r
-        this.threadPool = threadPool;\r
-    }\r
-\r
-    \r
-    public void setEndpoint(PoolTcpEndpoint endpoint) {\r
-        this.endpoint = endpoint;\r
-    }\r
-\r
-\r
     /**\r
      * Add user-agent for which gzip compression didn't works\r
      * The user agent String given will be exactly matched\r
@@ -765,7 +742,7 @@ public class Http11Processor implements Processor, ActionHook {
         ThreadWithAttributes thrA=\r
                 (ThreadWithAttributes)Thread.currentThread();\r
         RequestInfo rp = request.getRequestProcessor();\r
-        thrA.setCurrentStage(threadPool, "parsing http request");\r
+        thrA.setCurrentStage(endpoint, "parsing http request");\r
         rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);\r
 \r
         // Set the remote address\r
@@ -788,14 +765,8 @@ public class Http11Processor implements Processor, ActionHook {
         int soTimeout = socket.getSoTimeout();\r
         int oldSoTimeout = soTimeout;\r
 \r
-        int threadRatio = 0;\r
-        if (threadPool.getCurrentThreadsBusy() > 0) {\r
-            threadRatio = (threadPool.getCurrentThreadsBusy() * 100)\r
-                / threadPool.getMaxThreads();\r
-        } else {\r
-            threadRatio = (endpoint.getCurrentThreadsBusy() * 100)\r
+        int threadRatio = (endpoint.getCurrentThreadsBusy() * 100)\r
                 / endpoint.getMaxThreads();\r
-        }\r
         if ((threadRatio > 33) && (threadRatio <= 66)) {\r
             soTimeout = soTimeout / 2;\r
         } else if ((threadRatio > 66) && (threadRatio <= 90)) {\r
@@ -826,7 +797,7 @@ public class Http11Processor implements Processor, ActionHook {
                 }\r
                 inputBuffer.parseRequestLine();\r
                 request.setStartTime(System.currentTimeMillis());\r
-                thrA.setParam( threadPool, request.requestURI() );\r
+                thrA.setParam( endpoint, request.requestURI() );\r
                 keptAlive = true;\r
                 if (!disableUploadTimeout) {\r
                     socket.setSoTimeout(timeout);\r
@@ -845,7 +816,7 @@ public class Http11Processor implements Processor, ActionHook {
             }\r
 \r
             // Setting up filters, and parse some request headers\r
-            thrA.setCurrentStage(threadPool, "prepareRequest");\r
+            thrA.setCurrentStage(endpoint, "prepareRequest");\r
             rp.setStage(org.apache.coyote.Constants.STAGE_PREPARE);\r
             try {\r
                 prepareRequest();\r
@@ -864,7 +835,7 @@ public class Http11Processor implements Processor, ActionHook {
             // Process the request in the adapter\r
             if (!error) {\r
                 try {\r
-                    thrA.setCurrentStage(threadPool, "service");\r
+                    thrA.setCurrentStage(endpoint, "service");\r
                     rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);\r
                     adapter.service(request, response);\r
                     // Handle when the response was committed before a serious\r
@@ -889,7 +860,7 @@ public class Http11Processor implements Processor, ActionHook {
 \r
             // Finish the handling of the request\r
             try {\r
-                thrA.setCurrentStage(threadPool, "endRequestIB");\r
+                thrA.setCurrentStage(endpoint, "endRequestIB");\r
                 rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);\r
                 inputBuffer.endRequest();\r
             } catch (IOException e) {\r
@@ -901,7 +872,7 @@ public class Http11Processor implements Processor, ActionHook {
                 error = true;\r
             }\r
             try {\r
-                thrA.setCurrentStage(threadPool, "endRequestOB");\r
+                thrA.setCurrentStage(endpoint, "endRequestOB");\r
                 rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);\r
                 outputBuffer.endRequest();\r
             } catch (IOException e) {\r
@@ -918,7 +889,7 @@ public class Http11Processor implements Processor, ActionHook {
             }\r
             request.updateCounters();\r
 \r
-            thrA.setCurrentStage(threadPool, "ended");\r
+            thrA.setCurrentStage(endpoint, "ended");\r
             rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);\r
 \r
             // Don't reset the param - we'll see it as ended. Next request\r
index 95cd8d8..a4c8373 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- *  Copyright 1999-2004 The Apache Software Foundation\r
+ *  Copyright 1999-2006 The Apache Software Foundation\r
  *\r
  *  Licensed under the Apache License, Version 2.0 (the "License");\r
  *  you may not use this file except in compliance with the License.\r
 \r
 package org.apache.coyote.http11;\r
 \r
+import java.net.InetAddress;\r
+import java.net.Socket;\r
+import java.net.URLEncoder;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.concurrent.Executor;\r
+\r
 import javax.management.MBeanRegistration;\r
 import javax.management.MBeanServer;\r
 import javax.management.ObjectName;\r
 \r
+import org.apache.coyote.ActionCode;\r
+import org.apache.coyote.ActionHook;\r
+import org.apache.coyote.Adapter;\r
+import org.apache.coyote.ProtocolHandler;\r
+import org.apache.coyote.RequestGroupInfo;\r
 import org.apache.coyote.RequestInfo;\r
 import org.apache.tomcat.util.modeler.Registry;\r
-import org.apache.tomcat.util.threads.ThreadPool;\r
-import org.apache.tomcat.util.threads.ThreadWithAttributes;\r
+import org.apache.tomcat.util.net.JIoEndpoint;\r
+import org.apache.tomcat.util.net.SSLImplementation;\r
+import org.apache.tomcat.util.net.SSLSupport;\r
+import org.apache.tomcat.util.net.ServerSocketFactory;\r
+import org.apache.tomcat.util.net.JIoEndpoint.Handler;\r
+import org.apache.tomcat.util.res.StringManager;\r
 \r
 \r
 /**\r
@@ -33,38 +49,134 @@ import org.apache.tomcat.util.threads.ThreadWithAttributes;
  *\r
  * @author Remy Maucherat\r
  * @author Costin Manolache\r
+ * @deprecated\r
  */\r
-public class Http11Protocol extends Http11BaseProtocol implements MBeanRegistration\r
-{\r
+public class Http11Protocol \r
+    implements ProtocolHandler, MBeanRegistration {\r
+\r
+\r
+    protected static org.apache.commons.logging.Log log\r
+        = org.apache.commons.logging.LogFactory.getLog(Http11Protocol.class);\r
+\r
+    /**\r
+     * The string manager for this package.\r
+     */\r
+    protected static StringManager sm =\r
+        StringManager.getManager(Constants.Package);\r
+\r
+\r
+    // ------------------------------------------------------------ Constructor\r
+\r
+\r
     public Http11Protocol() {\r
+        setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);\r
+        setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);\r
+        //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);\r
+        setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);\r
     }\r
+\r
     \r
-    protected Http11ConnectionHandler createConnectionHandler() {\r
-        return new JmxHttp11ConnectionHandler( this ) ;\r
+    // ----------------------------------------------------------------- Fields\r
+\r
+\r
+    protected Http11ConnectionHandler cHandler = new Http11ConnectionHandler(this);\r
+    protected JIoEndpoint endpoint = new JIoEndpoint();\r
+\r
+\r
+    // *\r
+    protected ObjectName tpOname = null;\r
+    // *\r
+    protected ObjectName rgOname = null;\r
+\r
+\r
+    protected ServerSocketFactory socketFactory = null;\r
+    protected SSLImplementation sslImplementation = null;\r
+\r
+\r
+    // ----------------------------------------- ProtocolHandler Implementation\r
+    // *\r
+\r
+\r
+    protected HashMap<String, Object> attributes = new HashMap<String, Object>();\r
+\r
+    \r
+    /**\r
+     * Pass config info\r
+     */\r
+    public void setAttribute(String name, Object value) {\r
+        if (log.isTraceEnabled()) {\r
+            log.trace(sm.getString("http11protocol.setattribute", name, value));\r
+        }\r
+        attributes.put(name, value);\r
+    }\r
+\r
+    public Object getAttribute(String key) {\r
+        return attributes.get(key);\r
     }\r
 \r
-    ObjectName tpOname;\r
-    ObjectName rgOname;\r
+    public Iterator getAttributeNames() {\r
+        return attributes.keySet().iterator();\r
+    }\r
+\r
+\r
+    /**\r
+     * The adapter, used to call the connector.\r
+     */\r
+    protected Adapter adapter;\r
+    public void setAdapter(Adapter adapter) { this.adapter = adapter; }\r
+    public Adapter getAdapter() { return adapter; }\r
+\r
+\r
+    public void init() throws Exception {\r
+        endpoint.setName(getName());\r
+        endpoint.setHandler(cHandler);\r
+\r
+        // Verify the validity of the configured socket factory\r
+        try {\r
+            if (secure) {\r
+                sslImplementation =\r
+                    SSLImplementation.getInstance(sslImplementationName);\r
+                socketFactory = sslImplementation.getServerSocketFactory();\r
+                endpoint.setServerSocketFactory(socketFactory);\r
+            } else if (socketFactoryName != null) {\r
+                socketFactory = (ServerSocketFactory) Class.forName(socketFactoryName).newInstance();\r
+                endpoint.setServerSocketFactory(socketFactory);\r
+            }\r
+        } catch (Exception ex) {\r
+            log.error(sm.getString("http11protocol.socketfactory.initerror"),\r
+                      ex);\r
+            throw ex;\r
+        }\r
+\r
+        if (socketFactory!=null) {\r
+            Iterator<String> attE = attributes.keySet().iterator();\r
+            while( attE.hasNext() ) {\r
+                String key = attE.next();\r
+                Object v=attributes.get(key);\r
+                socketFactory.setAttribute(key, v);\r
+            }\r
+        }\r
+        \r
+        try {\r
+            endpoint.init();\r
+        } catch (Exception ex) {\r
+            log.error(sm.getString("http11protocol.endpoint.initerror"), ex);\r
+            throw ex;\r
+        }\r
+        if (log.isInfoEnabled())\r
+            log.info(sm.getString("http11protocol.init", getName()));\r
+\r
+    }\r
 \r
     public void start() throws Exception {\r
-        if( this.domain != null ) {\r
+        if (this.domain != null) {\r
             try {\r
-                // XXX We should be able to configure it separately\r
-                // XXX It should be possible to use a single TP\r
-                tpOname=new ObjectName\r
+                tpOname = new ObjectName\r
                     (domain + ":" + "type=ThreadPool,name=" + getName());\r
-                if ("ms".equals(getStrategy())) {\r
-                    Registry.getRegistry(null, null)\r
-                        .registerComponent(ep, tpOname, null );\r
-                } else {\r
-                    Registry.getRegistry(null, null)\r
-                        .registerComponent(tp, tpOname, null );\r
-                }\r
-                tp.setName(getName());\r
-                tp.setDaemon(false);\r
-                tp.addThreadPoolListener(new MXPoolListener(this, tp));\r
+                Registry.getRegistry(null, null)\r
+                    .registerComponent(endpoint, tpOname, null );\r
             } catch (Exception e) {\r
-                log.error("Can't register threadpool" );\r
+                log.error("Can't register endpoint");\r
             }\r
             rgOname=new ObjectName\r
                 (domain + ":type=GlobalRequestProcessor,name=" + getName());\r
@@ -72,92 +184,466 @@ public class Http11Protocol extends Http11BaseProtocol implements MBeanRegistrat
                 ( cHandler.global, rgOname, null );\r
         }\r
 \r
-        super.start();\r
+        try {\r
+            endpoint.start();\r
+        } catch (Exception ex) {\r
+            log.error(sm.getString("http11protocol.endpoint.starterror"), ex);\r
+            throw ex;\r
+        }\r
+        if (log.isInfoEnabled())\r
+            log.info(sm.getString("http11protocol.start", getName()));\r
+    }\r
+\r
+    public void pause() throws Exception {\r
+        try {\r
+            endpoint.pause();\r
+        } catch (Exception ex) {\r
+            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);\r
+            throw ex;\r
+        }\r
+        if (log.isInfoEnabled())\r
+            log.info(sm.getString("http11protocol.pause", getName()));\r
+    }\r
+\r
+    public void resume() throws Exception {\r
+        try {\r
+            endpoint.resume();\r
+        } catch (Exception ex) {\r
+            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);\r
+            throw ex;\r
+        }\r
+        if (log.isInfoEnabled())\r
+            log.info(sm.getString("http11protocol.resume", getName()));\r
     }\r
 \r
     public void destroy() throws Exception {\r
-        super.destroy();\r
-        if( tpOname!=null )\r
+        if (log.isInfoEnabled())\r
+            log.info(sm.getString("http11protocol.stop", getName()));\r
+        endpoint.destroy();\r
+        if (tpOname!=null)\r
             Registry.getRegistry(null, null).unregisterComponent(tpOname);\r
-        if( rgOname != null )\r
+        if (rgOname != null)\r
             Registry.getRegistry(null, null).unregisterComponent(rgOname);\r
     }\r
 \r
-    // --------------------  Connection handler --------------------\r
+    \r
+    // ------------------------------------------------------------- Properties\r
 \r
-    static class MXPoolListener implements ThreadPool.ThreadPoolListener {\r
-        MXPoolListener( Http11Protocol proto, ThreadPool control ) {\r
+    \r
+    // *\r
+    /**\r
+     * This field indicates if the protocol is secure from the perspective of\r
+     * the client (= https is used).\r
+     */\r
+    protected boolean secure;\r
+    public boolean getSecure() { return secure; }\r
+    public void setSecure(boolean b) { secure = b; }\r
+    \r
+    \r
+    /**\r
+     * Name of the socket factory.\r
+     */\r
+    protected String socketFactoryName = null;\r
+    public String getSocketFactory() { return socketFactoryName; }\r
+    public void setSocketFactory(String valueS) { socketFactoryName = valueS; }\r
+    \r
+    \r
+    /**\r
+     * Name of the SSL implementation.\r
+     */\r
+    protected String sslImplementationName=null;\r
+    public String getSSLImplementation() { return sslImplementationName; }\r
+    public void setSSLImplementation( String valueS) {\r
+        sslImplementationName = valueS;\r
+        setSecure(true);\r
+    }\r
+    \r
+    \r
+    // HTTP\r
+    /**\r
+     * Maximum number of requests which can be performed over a keepalive \r
+     * connection. The default is the same as for Apache HTTP Server.\r
+     */\r
+    protected int maxKeepAliveRequests = 100;\r
+    public int getMaxKeepAliveRequests() { return maxKeepAliveRequests; }\r
+    public void setMaxKeepAliveRequests(int mkar) { maxKeepAliveRequests = mkar; }\r
+\r
+\r
+    // HTTP\r
+    /**\r
+     * This timeout represents the socket timeout which will be used while\r
+     * the adapter execution is in progress, unless disableUploadTimeout\r
+     * is set to true. The default is the same as for Apache HTTP Server\r
+     * (300 000 milliseconds).\r
+     */\r
+    protected int timeout = 300000;\r
+    public int getTimeout() { return timeout; }\r
+    public void setTimeout(int timeout) { this.timeout = timeout; }\r
+\r
+\r
+    // *\r
+    /**\r
+     * Maximum size of the post which will be saved when processing certain\r
+     * requests, such as a POST.\r
+     */\r
+    protected int maxSavePostSize = 4 * 1024;\r
+    public int getMaxSavePostSize() { return maxSavePostSize; }\r
+    public void setMaxSavePostSize(int valueI) { maxSavePostSize = valueI; }\r
+\r
+\r
+    // HTTP\r
+    /**\r
+     * Maximum size of the HTTP message header.\r
+     */\r
+    protected int maxHttpHeaderSize = 8 * 1024;\r
+    public int getMaxHttpHeaderSize() { return maxHttpHeaderSize; }\r
+    public void setMaxHttpHeaderSize(int valueI) { maxHttpHeaderSize = valueI; }\r
+\r
+\r
+    // HTTP\r
+    /**\r
+     * If true, the regular socket timeout will be used for the full duration\r
+     * of the connection.\r
+     */\r
+    protected boolean disableUploadTimeout = true;\r
+    public boolean getDisableUploadTimeout() { return disableUploadTimeout; }\r
+    public void setDisableUploadTimeout(boolean isDisabled) { disableUploadTimeout = isDisabled; }\r
+\r
+\r
+    // HTTP\r
+    /**\r
+     * Integrated compression support.\r
+     */\r
+    protected String compression = "off";\r
+    public String getCompression() { return compression; }\r
+    public void setCompression(String valueS) { compression = valueS; }\r
+    \r
+    \r
+    // HTTP\r
+    protected String noCompressionUserAgents = null;\r
+    public String getNoCompressionUserAgents() { return noCompressionUserAgents; }\r
+    public void setNoCompressionUserAgents(String valueS) { noCompressionUserAgents = valueS; }\r
 \r
-        }\r
+    \r
+    // HTTP\r
+    protected String compressableMimeTypes = "text/html,text/xml,text/plain";\r
+    public String getCompressableMimeType() { return compressableMimeTypes; }\r
+    public void setCompressableMimeType(String valueS) { compressableMimeTypes = valueS; }\r
+    \r
+    \r
+    // HTTP\r
+    protected int compressionMinSize = 2048;\r
+    public int getCompressionMinSize() { return compressionMinSize; }\r
+    public void setCompressionMinSize(int valueI) { compressionMinSize = valueI; }\r
+\r
+\r
+    // HTTP\r
+    /**\r
+     * User agents regular expressions which should be restricted to HTTP/1.0 support.\r
+     */\r
+    protected String restrictedUserAgents = null;\r
+    public String getRestrictedUserAgents() { return restrictedUserAgents; }\r
+    public void setRestrictedUserAgents(String valueS) { restrictedUserAgents = valueS; }\r
+    \r
+    \r
+    // HTTP\r
+    /**\r
+     * Server header.\r
+     */\r
+    protected String server;\r
+    public void setServer( String server ) { this.server = server; }\r
+    public String getServer() { return server; }\r
 \r
-        public void threadStart(ThreadPool tp, Thread t) {\r
-        }\r
 \r
-        public void threadEnd(ThreadPool tp, Thread t) {\r
-            // Register our associated processor\r
-            // TP uses only TWA\r
-            ThreadWithAttributes ta=(ThreadWithAttributes)t;\r
-            Object tpData[]=ta.getThreadData(tp);\r
-            if( tpData==null ) return;\r
-            // Weird artifact - it should be cleaned up, but that may break something\r
-            // and it won't gain us too much\r
-            if( tpData[1] instanceof Object[] ) {\r
-                tpData=(Object [])tpData[1];\r
-            }\r
-            ObjectName oname=(ObjectName)tpData[Http11BaseProtocol.THREAD_DATA_OBJECT_NAME];\r
-            if( oname==null ) return;\r
-            Registry.getRegistry(null, null).unregisterComponent(oname);\r
-            Http11Processor processor =\r
-                (Http11Processor) tpData[Http11Protocol.THREAD_DATA_PROCESSOR];\r
-            RequestInfo rp=processor.getRequest().getRequestProcessor();\r
-            rp.setGlobalProcessor(null);\r
-        }\r
+    // --------------------------------------------------------- Public methods\r
+\r
+    // *\r
+    public Executor getExecutor() {\r
+        return endpoint.getExecutor();\r
+    }\r
+    \r
+    // *\r
+    public void setExecutor(Executor executor) {\r
+        endpoint.setExecutor(executor);\r
+    }\r
+    \r
+    // *\r
+    public int getMaxThreads() {\r
+        return endpoint.getMaxThreads();\r
     }\r
 \r
-    static class JmxHttp11ConnectionHandler extends Http11ConnectionHandler  {\r
-        Http11Protocol proto;\r
-        static int count=0;\r
+    // *\r
+    public void setMaxThreads( int maxThreads ) {\r
+        endpoint.setMaxThreads(maxThreads);\r
+    }\r
+\r
+    // *\r
+    public void setThreadPriority(int threadPriority) {\r
+        endpoint.setThreadPriority(threadPriority);\r
+    }\r
+\r
+    // *\r
+    public int getThreadPriority() {\r
+        return endpoint.getThreadPriority();\r
+    }\r
 \r
-        JmxHttp11ConnectionHandler( Http11Protocol proto ) {\r
-            super(proto);\r
-            this.proto = proto ;\r
+    // *\r
+    public int getBacklog() {\r
+        return endpoint.getBacklog();\r
+    }\r
+\r
+    // *\r
+    public void setBacklog( int i ) {\r
+        endpoint.setBacklog(i);\r
+    }\r
+\r
+    // *\r
+    public int getPort() {\r
+        return endpoint.getPort();\r
+    }\r
+\r
+    // *\r
+    public void setPort( int port ) {\r
+        endpoint.setPort(port);\r
+    }\r
+\r
+    // *\r
+    public InetAddress getAddress() {\r
+        return endpoint.getAddress();\r
+    }\r
+\r
+    // *\r
+    public void setAddress(InetAddress ia) {\r
+        endpoint.setAddress( ia );\r
+    }\r
+\r
+    // *\r
+    public String getName() {\r
+        String encodedAddr = "";\r
+        if (getAddress() != null) {\r
+            encodedAddr = "" + getAddress();\r
+            if (encodedAddr.startsWith("/"))\r
+                encodedAddr = encodedAddr.substring(1);\r
+            encodedAddr = URLEncoder.encode(encodedAddr) + "-";\r
         }\r
+        return ("http-" + encodedAddr + endpoint.getPort());\r
+    }\r
+\r
+    // *\r
+    public boolean getTcpNoDelay() {\r
+        return endpoint.getTcpNoDelay();\r
+    }\r
+\r
+    // *\r
+    public void setTcpNoDelay( boolean b ) {\r
+        endpoint.setTcpNoDelay( b );\r
+    }\r
+\r
+    // *\r
+    public int getSoLinger() {\r
+        return endpoint.getSoLinger();\r
+    }\r
 \r
-        public void setAttribute( String name, Object value ) {\r
+    // *\r
+    public void setSoLinger( int i ) {\r
+        endpoint.setSoLinger( i );\r
+    }\r
+\r
+    // *\r
+    public int getSoTimeout() {\r
+        return endpoint.getSoTimeout();\r
+    }\r
+\r
+    // *\r
+    public void setSoTimeout( int i ) {\r
+        endpoint.setSoTimeout(i);\r
+    }\r
+\r
+    // HTTP\r
+    /**\r
+     * Return the Keep-Alive policy for the connection.\r
+     */\r
+    public boolean getKeepAlive() {\r
+        return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));\r
+    }\r
+\r
+    // HTTP\r
+    /**\r
+     * Set the keep-alive policy for this connection.\r
+     */\r
+    public void setKeepAlive(boolean keepAlive) {\r
+        if (!keepAlive) {\r
+            setMaxKeepAliveRequests(1);\r
         }\r
+    }\r
+\r
+    /*\r
+     * Note: All the following are JSSE/java.io specific attributes.\r
+     */\r
+    \r
+    public String getKeystore() {\r
+        return (String) getAttribute("keystore");\r
+    }\r
+\r
+    public void setKeystore( String k ) {\r
+        setAttribute("keystore", k);\r
+    }\r
+\r
+    public String getKeypass() {\r
+        return (String) getAttribute("keypass");\r
+    }\r
+\r
+    public void setKeypass( String k ) {\r
+        attributes.put("keypass", k);\r
+        //setAttribute("keypass", k);\r
+    }\r
 \r
-        public void setServer( Object o ) {\r
+    public String getKeytype() {\r
+        return (String) getAttribute("keystoreType");\r
+    }\r
+\r
+    public void setKeytype( String k ) {\r
+        setAttribute("keystoreType", k);\r
+    }\r
+\r
+    public String getClientauth() {\r
+        return (String) getAttribute("clientauth");\r
+    }\r
+\r
+    public void setClientauth( String k ) {\r
+        setAttribute("clientauth", k);\r
+    }\r
+\r
+    public String getProtocols() {\r
+        return (String) getAttribute("protocols");\r
+    }\r
+\r
+    public void setProtocols(String k) {\r
+        setAttribute("protocols", k);\r
+    }\r
+\r
+    public String getAlgorithm() {\r
+        return (String) getAttribute("algorithm");\r
+    }\r
+\r
+    public void setAlgorithm( String k ) {\r
+        setAttribute("algorithm", k);\r
+    }\r
+\r
+    public String getCiphers() {\r
+        return (String) getAttribute("ciphers");\r
+    }\r
+\r
+    public void setCiphers(String ciphers) {\r
+        setAttribute("ciphers", ciphers);\r
+    }\r
+\r
+    public String getKeyAlias() {\r
+        return (String) getAttribute("keyAlias");\r
+    }\r
+\r
+    public void setKeyAlias(String keyAlias) {\r
+        setAttribute("keyAlias", keyAlias);\r
+    }\r
+\r
+    // -----------------------------------  Http11ConnectionHandler Inner Class\r
+\r
+    protected static class Http11ConnectionHandler implements Handler {\r
+        protected Http11Protocol protocol;\r
+        protected static int count = 0;\r
+        protected RequestGroupInfo global = new RequestGroupInfo();\r
+        protected ThreadLocal<Http11Processor> localProcessor = new ThreadLocal<Http11Processor>();\r
+\r
+        Http11ConnectionHandler(Http11Protocol proto) {\r
+            this.protocol = proto;\r
         }\r
 \r
-        public Object[] init() {\r
-\r
-            Object thData[]=super.init();\r
-\r
-            // was set up by supper\r
-            Http11Processor  processor = (Http11Processor)\r
-                    thData[ Http11BaseProtocol.THREAD_DATA_PROCESSOR];\r
-\r
-            if( proto.getDomain() != null ) {\r
-                try {\r
-                    RequestInfo rp=processor.getRequest().getRequestProcessor();\r
-                    rp.setGlobalProcessor(global);\r
-                    ObjectName rpName=new ObjectName\r
-                        (proto.getDomain() + ":type=RequestProcessor,worker="\r
-                         + proto.getName() +",name=HttpRequest" + count++ );\r
-                    Registry.getRegistry(null, null).registerComponent( rp, rpName, null);\r
-                    thData[Http11BaseProtocol.THREAD_DATA_OBJECT_NAME]=rpName;\r
-                } catch( Exception ex ) {\r
-                    log.warn("Error registering request");\r
+        public boolean process(Socket socket) {\r
+            Http11Processor processor = null;\r
+            try {\r
+                processor = localProcessor.get();\r
+                if (processor == null) {\r
+                    processor =\r
+                        new Http11Processor(protocol.maxHttpHeaderSize, protocol.endpoint);\r
+                    processor.setAdapter(protocol.adapter);\r
+                    processor.setMaxKeepAliveRequests(protocol.maxKeepAliveRequests);\r
+                    processor.setTimeout(protocol.timeout);\r
+                    processor.setDisableUploadTimeout(protocol.disableUploadTimeout);\r
+                    processor.setCompression(protocol.compression);\r
+                    processor.setCompressionMinSize(protocol.compressionMinSize);\r
+                    processor.setNoCompressionUserAgents(protocol.noCompressionUserAgents);\r
+                    processor.setCompressableMimeTypes(protocol.compressableMimeTypes);\r
+                    processor.setRestrictedUserAgents(protocol.restrictedUserAgents);\r
+                    processor.setMaxSavePostSize(protocol.maxSavePostSize);\r
+                    processor.setServer(protocol.server);\r
+                    localProcessor.set(processor);\r
+                    if (protocol.getDomain() != null) {\r
+                        synchronized (this) {\r
+                            try {\r
+                                RequestInfo rp = processor.getRequest().getRequestProcessor();\r
+                                rp.setGlobalProcessor(global);\r
+                                ObjectName rpName = new ObjectName\r
+                                (protocol.getDomain() + ":type=RequestProcessor,worker="\r
+                                        + protocol.getName() + ",name=HttpRequest" + count++);\r
+                                Registry.getRegistry(null, null).registerComponent(rp, rpName, null);\r
+                            } catch (Exception e) {\r
+                                log.warn("Error registering request");\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+\r
+                if (processor instanceof ActionHook) {\r
+                    ((ActionHook) processor).action(ActionCode.ACTION_START, null);\r
                 }\r
-            }\r
 \r
-            return  thData;\r
+                if (protocol.secure && (protocol.sslImplementation != null)) {\r
+                    processor.setSSLSupport\r
+                        (protocol.sslImplementation.getSSLSupport(socket));\r
+                } else {\r
+                    processor.setSSLSupport(null);\r
+                }\r
+                \r
+                processor.setSocket(socket);\r
+                processor.process(socket.getInputStream(), socket.getOutputStream());\r
+                return false;\r
+\r
+            } catch(java.net.SocketException e) {\r
+                // SocketExceptions are normal\r
+                Http11Protocol.log.debug\r
+                    (sm.getString\r
+                     ("http11protocol.proto.socketexception.debug"), e);\r
+            } catch (java.io.IOException e) {\r
+                // IOExceptions are normal\r
+                Http11Protocol.log.debug\r
+                    (sm.getString\r
+                     ("http11protocol.proto.ioexception.debug"), e);\r
+            }\r
+            // Future developers: if you discover any other\r
+            // rare-but-nonfatal exceptions, catch them here, and log as\r
+            // above.\r
+            catch (Throwable e) {\r
+                // any other exception or error is odd. Here we log it\r
+                // with "ERROR" level, so it will show up even on\r
+                // less-than-verbose logs.\r
+                Http11Protocol.log.error\r
+                    (sm.getString("http11protocol.proto.error"), e);\r
+            } finally {\r
+                //       if(proto.adapter != null) proto.adapter.recycle();\r
+                //                processor.recycle();\r
+\r
+                if (processor instanceof ActionHook) {\r
+                    ((ActionHook) processor).action(ActionCode.ACTION_STOP, null);\r
+                }\r
+            }\r
+            return false;\r
         }\r
     }\r
 \r
-    // -------------------- Various implementation classes --------------------\r
 \r
+    // -------------------- JMX related methods --------------------\r
 \r
+    // *\r
     protected String domain;\r
     protected ObjectName oname;\r
     protected MBeanServer mserver;\r
@@ -186,5 +672,4 @@ public class Http11Protocol extends Http11BaseProtocol implements MBeanRegistrat
 \r
     public void postDeregister() {\r
     }\r
-\r
 }\r