Consolidation of protocol attributes into a base class
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 17 Nov 2009 21:33:40 +0000 (21:33 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 17 Nov 2009 21:33:40 +0000 (21:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@881541 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/AbstractHttp11Protocol.java [new file with mode: 0644]
java/org/apache/coyote/http11/Http11NioProtocol.java
java/org/apache/coyote/http11/Http11Protocol.java
java/org/apache/tomcat/util/net/AbstractEndpoint.java
java/org/apache/tomcat/util/net/NioEndpoint.java
java/org/apache/tomcat/util/net/SSLImplementation.java

diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
new file mode 100644 (file)
index 0000000..ed1dba9
--- /dev/null
@@ -0,0 +1,405 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.coyote.http11;
+
+import java.net.InetAddress;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.concurrent.Executor;
+
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.coyote.Adapter;
+import org.apache.coyote.ProtocolHandler;
+import org.apache.tomcat.util.modeler.Registry;
+import org.apache.tomcat.util.net.AbstractEndpoint;
+import org.apache.tomcat.util.net.SSLImplementation;
+import org.apache.tomcat.util.res.StringManager;
+
+public abstract class AbstractHttp11Protocol implements ProtocolHandler, MBeanRegistration {
+    /**
+     * The string manager for this package.
+     */
+    protected static final StringManager sm = StringManager.getManager(Constants.Package);
+    
+    protected static org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory.getLog(AbstractHttp11Protocol.class);
+    
+    protected ObjectName tpOname = null;
+    protected ObjectName rgOname = null;
+
+    protected AbstractEndpoint endpoint=null;
+    
+    protected SSLImplementation sslImplementation = null;
+    
+    /**
+     * The adapter, used to call the connector.
+     */
+    protected Adapter adapter;
+    public void setAdapter(Adapter adapter) { this.adapter = adapter; }
+    public Adapter getAdapter() { return adapter; }
+
+    
+    protected HashMap<String, Object> attributes = new HashMap<String, Object>();
+
+    
+    /**
+     * Pass config info
+     */
+    public void setAttribute(String name, Object value) {
+        if (log.isTraceEnabled()) {
+            log.trace(sm.getString("http11protocol.setattribute", name, value));
+        }
+        attributes.put(name, value);
+    }
+
+    public Object getAttribute(String key) {
+        return attributes.get(key);
+    }
+
+    public Iterator<String> getAttributeNames() {
+        return attributes.keySet().iterator();
+    }
+
+    /**
+     * Set a property.
+     */
+    public boolean setProperty(String name, String value) {
+        setAttribute(name, value); //store all settings
+        if ( name!=null && (name.startsWith("socket.") ||name.startsWith("selectorPool.")) ){
+            return endpoint.setProperty(name, value);
+        } else {
+            return endpoint.setProperty(name,value); //make sure we at least try to set all properties
+        }
+        
+    }
+
+    /**
+     * Get a property
+     */
+    public String getProperty(String name) {
+        return (String)getAttribute(name);
+    }
+    
+    public InetAddress getAddress() { return endpoint.getAddress(); }
+    public void setAddress(InetAddress ia) {
+        endpoint.setAddress( ia );
+        setAttribute("address", "" + ia);
+    }
+    
+    public String getName() {
+        String encodedAddr = "";
+        if (getAddress() != null) {
+            encodedAddr = "" + getAddress();
+            if (encodedAddr.startsWith("/"))
+                encodedAddr = encodedAddr.substring(1);
+            encodedAddr = URLEncoder.encode(encodedAddr) + "-";
+        }
+        return ("http-" + encodedAddr + endpoint.getPort());
+    }
+    
+    
+    public void pause() throws Exception {
+        try {
+            endpoint.pause();
+        } catch (Exception ex) {
+            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
+            throw ex;
+        }
+        if(log.isInfoEnabled())
+            log.info(sm.getString("http11protocol.pause", getName()));
+    }
+
+    public void resume() throws Exception {
+        try {
+            endpoint.resume();
+        } catch (Exception ex) {
+            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
+            throw ex;
+        }
+        if(log.isInfoEnabled())
+            log.info(sm.getString("http11protocol.resume", getName()));
+    }
+
+    public void destroy() throws Exception {
+        if(log.isInfoEnabled())
+            log.info(sm.getString("http11protocol.stop", getName()));
+        endpoint.destroy();
+        if( tpOname!=null )
+            Registry.getRegistry(null, null).unregisterComponent(tpOname);
+        if( rgOname != null )
+            Registry.getRegistry(null, null).unregisterComponent(rgOname);
+    }
+    
+    public boolean isSSLEnabled() { return endpoint.isSSLEnabled();}
+    public void setSSLEnabled(boolean SSLEnabled) { endpoint.setSSLEnabled(SSLEnabled);}    
+    
+    private boolean secure;
+    public boolean getSecure() { return secure; }
+    public void setSecure(boolean b) { 
+        secure = b;         
+        setAttribute("secure", "" + b);
+    }
+    
+    /**
+     * Processor cache.
+     */
+    private int processorCache = 200;
+    public int getProcessorCache() { return this.processorCache; }
+    public void setProcessorCache(int processorCache) { this.processorCache = processorCache; }
+
+    private int socketBuffer = 9000;
+    public int getSocketBuffer() { return socketBuffer; }
+    public void setSocketBuffer(int socketBuffer) { this.socketBuffer = socketBuffer; }
+
+    // HTTP
+    /**
+     * Maximum number of requests which can be performed over a keepalive 
+     * connection. The default is the same as for Apache HTTP Server.
+     */
+    public int getMaxKeepAliveRequests() { return endpoint.getMaxKeepAliveRequests(); }
+    public void setMaxKeepAliveRequests(int mkar) {
+        endpoint.setMaxKeepAliveRequests(mkar);
+        setAttribute("maxKeepAliveRequests", "" + mkar);
+    }
+    
+    /**
+     * Return the Keep-Alive policy for the connection.
+     */
+    public boolean getKeepAlive() {
+        return ((endpoint.getMaxKeepAliveRequests() != 0) && (endpoint.getMaxKeepAliveRequests() != 1));
+    }
+
+    /**
+     * Set the keep-alive policy for this connection.
+     */
+    public void setKeepAlive(boolean keepAlive) {
+        if (!keepAlive) {
+            setMaxKeepAliveRequests(1);
+        }
+    }
+    
+    public void setKeepAliveTimeout(int keepAliveTimeout) {
+        endpoint.setKeepAliveTimeout(keepAliveTimeout);
+    }
+    
+    public int getKeepAliveTimeout() {
+        return endpoint.getKeepAliveTimeout();
+    }
+
+    public int getTimeout() {
+        return getSoTimeout();
+    }
+
+    public void setTimeout( int timeout ) {
+        setSoTimeout(timeout);
+    }
+    
+    public int getConnectionTimeout() {
+        return getSoTimeout();
+    }
+
+    public void setConnectionTimeout( int timeout ) {
+        setSoTimeout(timeout);
+    }
+
+    public int getSoTimeout() {
+        return endpoint.getSoTimeout();
+    }
+
+    public void setSoTimeout( int i ) {
+        endpoint.setSoTimeout(i);
+        setAttribute("soTimeout", "" + i);
+        setAttribute("timeout", "" + i);
+        setAttribute("connectionTimeout", "" + i);
+    }
+    
+    // *
+    /**
+     * Maximum size of the post which will be saved when processing certain
+     * requests, such as a POST.
+     */
+    private int maxSavePostSize = 4 * 1024;
+    public int getMaxSavePostSize() { return maxSavePostSize; }
+    public void setMaxSavePostSize(int valueI) { maxSavePostSize = valueI; }
+    
+
+    // HTTP
+    /**
+     * Maximum size of the HTTP message header.
+     */
+    private int maxHttpHeaderSize = 8 * 1024;
+    public int getMaxHttpHeaderSize() { return maxHttpHeaderSize; }
+    public void setMaxHttpHeaderSize(int valueI) { maxHttpHeaderSize = valueI; }
+
+    
+    // HTTP
+    /**
+     * If true, the regular socket timeout will be used for the full duration
+     * of the connection.
+     */
+    private boolean disableUploadTimeout = true;
+    public boolean getDisableUploadTimeout() { return disableUploadTimeout; }
+    public void setDisableUploadTimeout(boolean isDisabled) { disableUploadTimeout = isDisabled; }
+    
+    
+    // HTTP
+    /**
+     * Integrated compression support.
+     */
+    private String compression = "off";
+    public String getCompression() { return compression; }
+    public void setCompression(String valueS) { compression = valueS; }
+        
+
+    // HTTP
+    private String noCompressionUserAgents = null;
+    public String getNoCompressionUserAgents() { return noCompressionUserAgents; }
+    public void setNoCompressionUserAgents(String valueS) { noCompressionUserAgents = valueS; }
+    
+    // HTTP
+    private String compressableMimeTypes = "text/html,text/xml,text/plain";
+    public String getCompressableMimeType() { return compressableMimeTypes; }
+    public void setCompressableMimeType(String valueS) { compressableMimeTypes = valueS; }
+    public String getCompressableMimeTypes() { return getCompressableMimeType(); }
+    public void setCompressableMimeTypes(String valueS) { setCompressableMimeType(valueS); }
+    
+    // HTTP
+    private int compressionMinSize = 2048;
+    public int getCompressionMinSize() { return compressionMinSize; }
+    public void setCompressionMinSize(int valueI) { compressionMinSize = valueI; }
+    // HTTP
+    /**
+     * User agents regular expressions which should be restricted to HTTP/1.0 support.
+     */
+    private String restrictedUserAgents = null;
+    public String getRestrictedUserAgents() { return restrictedUserAgents; }
+    public void setRestrictedUserAgents(String valueS) { restrictedUserAgents = valueS; }
+
+    // HTTP
+    /**
+     * Server header.
+     */
+    private String server;
+    public void setServer( String server ) { this.server = server; }
+    public String getServer() { return server; }
+    
+    public Executor getExecutor() { return endpoint.getExecutor(); }
+    public void setExecutor(Executor executor) { endpoint.setExecutor(executor); }
+    
+    
+    public int getMaxThreads() { return endpoint.getMaxThreads(); }
+    public void setMaxThreads(int maxThreads) { endpoint.setMaxThreads(maxThreads); }
+
+
+    public int getThreadPriority() { return endpoint.getThreadPriority(); }
+    public void setThreadPriority(int threadPriority) { endpoint.setThreadPriority(threadPriority); }
+
+    public int getPort() { return endpoint.getPort(); }
+    public void setPort(int port) { endpoint.setPort(port); }
+
+    public int getBacklog() { return endpoint.getBacklog(); }
+    public void setBacklog(int backlog) { endpoint.setBacklog(backlog); }
+
+
+    public boolean getTcpNoDelay() { return endpoint.getTcpNoDelay(); }
+    public void setTcpNoDelay(boolean tcpNoDelay) { endpoint.setTcpNoDelay(tcpNoDelay); }
+
+    public int getSoLinger() { return endpoint.getSoLinger(); }
+    public void setSoLinger(int soLinger) { endpoint.setSoLinger(soLinger); }
+
+    
+    public String getKeystoreFile() { return endpoint.getKeystoreFile();}
+    public void setKeystoreFile(String s ) { endpoint.setKeystoreFile(s);}
+    public void setKeystore(String s) { setKeystoreFile(s);}
+    public String getKeystore(){ return getKeystoreFile();}
+    public String getKeyAlias() { return (endpoint).getKeyAlias();}
+    public void setKeyAlias(String s ) { (endpoint).setKeyAlias(s);}
+
+    
+    public String getAlgorithm() { return (endpoint).getAlgorithm();}
+    public void setAlgorithm(String s ) { (endpoint).setAlgorithm(s);}
+    
+    public void setClientauth(String s) {setClientAuth(s);}
+    public String getClientauth(){ return getClientAuth();}
+    public String getClientAuth() { return (endpoint).getClientAuth();}
+    public void setClientAuth(String s ) { (endpoint).setClientAuth(s);}
+    
+    public String getKeystorePass() { return (endpoint).getKeystorePass();}
+    public void setKeystorePass(String s ) { (endpoint).setKeystorePass(s);}
+    public void setKeypass(String s) { setKeystorePass(s);}
+    public String getKeypass() { return getKeystorePass();}
+    public String getKeystoreType() { return (endpoint).getKeystoreType();}
+    public void setKeystoreType(String s ) { (endpoint).setKeystoreType(s);}
+    public String getKeytype() { return getKeystoreType();}
+    public void setKeytype(String s ) { setKeystoreType(s);}
+
+    public void setTruststoreFile(String f){(endpoint).setTruststoreFile(f);}
+    public String getTruststoreFile(){return (endpoint).getTruststoreFile();}
+    public void setTruststorePass(String p){(endpoint).setTruststorePass(p);}
+    public String getTruststorePass(){return (endpoint).getTruststorePass();}
+    public void setTruststoreType(String t){(endpoint).setTruststoreType(t);}
+    public String getTruststoreType(){ return (endpoint).getTruststoreType();}
+    
+    
+    public String getSslProtocol() { return (endpoint).getSslProtocol();}
+    public void setSslProtocol(String s) { (endpoint).setSslProtocol(s);}
+    
+    public String getCiphers() { return (endpoint).getCiphers();}
+    public void setCiphers(String s) { (endpoint).setCiphers(s);}
+    
+
+    public abstract void init() throws Exception;
+    public abstract void start() throws Exception;
+    // -------------------- JMX related methods --------------------
+
+    // *
+    protected String domain;
+    protected ObjectName oname;
+    protected MBeanServer mserver;
+
+    public ObjectName getObjectName() {
+        return oname;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    public ObjectName preRegister(MBeanServer server,
+                                  ObjectName name) throws Exception {
+        oname=name;
+        mserver=server;
+        domain=name.getDomain();
+        return name;
+    }
+
+    public void postRegister(Boolean registrationDone) {
+    }
+
+    public void preDeregister() throws Exception {
+    }
+
+    public void postDeregister() {
+    }
+
+
+    
+}
index 4cf736d..55550eb 100644 (file)
 
 package org.apache.coyote.http11;
 
-import java.net.InetAddress;
-import java.net.URLEncoder;
 import java.nio.channels.SocketChannel;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
+
 import javax.management.ObjectName;
 
 import org.apache.coyote.ActionCode;
-import org.apache.coyote.Adapter;
-import org.apache.coyote.ProtocolHandler;
 import org.apache.coyote.RequestGroupInfo;
 import org.apache.coyote.RequestInfo;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.NioChannel;
 import org.apache.tomcat.util.net.NioEndpoint;
-import org.apache.tomcat.util.net.NioEndpoint.Handler;
-import org.apache.tomcat.util.net.jsse.JSSEImplementation;
 import org.apache.tomcat.util.net.SecureNioChannel;
 import org.apache.tomcat.util.net.SocketStatus;
-import org.apache.tomcat.util.res.StringManager;
+import org.apache.tomcat.util.net.NioEndpoint.Handler;
+import org.apache.tomcat.util.net.jsse.JSSEImplementation;
 
 
 /**
@@ -54,86 +46,35 @@ import org.apache.tomcat.util.res.StringManager;
  * @author Costin Manolache
  * @author Filip Hanik
  */
-public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
-{
-    protected JSSEImplementation sslImplementation = null;
+public class Http11NioProtocol extends AbstractHttp11Protocol {
     
     public Http11NioProtocol() {
+        endpoint=new NioEndpoint();
         cHandler = new Http11ConnectionHandler( this );
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
+        
     }
 
-    /**
-     * The string manager for this package.
-     */
-    protected static final StringManager sm =
-        StringManager.getManager(Constants.Package);
-
-    /** Pass config info
-     */
-    public void setAttribute( String name, Object value ) {
-        if( log.isTraceEnabled())
-            log.trace(sm.getString("http11protocol.setattribute", name, value));
 
-        attributes.put(name, value);
-    }
 
     public NioEndpoint getEndpoint() {
-        return ep;
+        return ((NioEndpoint)endpoint);
     }
     
-    public Object getAttribute( String key ) {
-        if( log.isTraceEnabled())
-            log.trace(sm.getString("http11protocol.getattribute", key));
-        return attributes.get(key);
-    }
 
-    public Iterator<String> getAttributeNames() {
-        return attributes.keySet().iterator();
-    }
-
-    /**
-     * Set a property.
-     */
-    public boolean setProperty(String name, String value) {
-        setAttribute(name, value); //store all settings
-        if ( name!=null && (name.startsWith("socket.") ||name.startsWith("selectorPool.")) ){
-            return ep.setProperty(name, value);
-        } else {
-            return ep.setProperty(name,value); //make sure we at least try to set all properties
-        }
-        
-    }
-
-    /**
-     * Get a property
-     */
-    public String getProperty(String name) {
-        return (String)getAttribute(name);
-    }
-
-    /** The adapter, used to call the connector
-     */
-    public void setAdapter(Adapter adapter) {
-        this.adapter=adapter;
-    }
-
-    public Adapter getAdapter() {
-        return adapter;
-    }
 
 
     /** Start the protocol
      */
     public void init() throws Exception {
-        ep.setName(getName());
-        ep.setHandler(cHandler);
+        endpoint.setName(getName());
+        ((NioEndpoint)endpoint).setHandler(cHandler);
         
         try {
-            ep.init();
+            endpoint.init();
             sslImplementation = new JSSEImplementation();
         } catch (Exception ex) {
             log.error(sm.getString("http11protocol.endpoint.initerror"), ex);
@@ -144,16 +85,13 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
 
     }
 
-    ObjectName tpOname;
-    ObjectName rgOname;
-
     public void start() throws Exception {
         if( this.domain != null ) {
             try {
                 tpOname=new ObjectName
                     (domain + ":" + "type=ThreadPool,name=" + getName());
                 Registry.getRegistry(null, null)
-                .registerComponent(ep, tpOname, null );
+                .registerComponent(endpoint, tpOname, null );
             } catch (Exception e) {
                 log.error("Can't register threadpool" );
             }
@@ -164,7 +102,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
         }
 
         try {
-            ep.start();
+            endpoint.start();
         } catch (Exception ex) {
             log.error(sm.getString("http11protocol.endpoint.starterror"), ex);
             throw ex;
@@ -173,293 +111,63 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
             log.info(sm.getString("http11protocol.start", getName()));
     }
 
-    public void pause() throws Exception {
-        try {
-            ep.pause();
-        } catch (Exception ex) {
-            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
-            throw ex;
-        }
-        if(log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.pause", getName()));
-    }
-
-    public void resume() throws Exception {
-        try {
-            ep.resume();
-        } catch (Exception ex) {
-            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
-            throw ex;
-        }
-        if(log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.resume", getName()));
-    }
-
-    public void destroy() throws Exception {
-        if(log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.stop", getName()));
-        ep.destroy();
-        if( tpOname!=null )
-            Registry.getRegistry(null, null).unregisterComponent(tpOname);
-        if( rgOname != null )
-            Registry.getRegistry(null, null).unregisterComponent(rgOname);
-    }
 
     // -------------------- Properties--------------------
-    protected NioEndpoint ep=new NioEndpoint();
-    protected boolean secure = false;
-
-    protected Hashtable<String, Object> attributes =
-        new Hashtable<String, Object>();
+    
 
-    private int timeout = 300000;   // 5 minutes as in Apache HTTPD server
-    private int maxSavePostSize = 4 * 1024;
-    private int maxHttpHeaderSize = 8 * 1024;
-    protected int processorCache = 200; //max number of Http11NioProcessor objects cached
     private int socketCloseDelay=-1;
-    private boolean disableUploadTimeout = true;
-    private int socketBuffer = 9000;
     
-    private Adapter adapter;
     private Http11ConnectionHandler cHandler;
 
-    /**
-     * Compression value.
-     */
-    private String compression = "off";
-    private String noCompressionUserAgents = null;
-    private String restrictedUserAgents = null;
-    private String compressableMimeTypes = "text/html,text/xml,text/plain";
-    private int compressionMinSize    = 2048;
-
-    private String server;
-
     // -------------------- Pool setup --------------------
 
     public void setPollerThreadCount(int count) {
-        ep.setPollerThreadCount(count);
+        ((NioEndpoint)endpoint).setPollerThreadCount(count);
     }
     
     public int getPollerThreadCount() {
-        return ep.getPollerThreadCount();
+        return ((NioEndpoint)endpoint).getPollerThreadCount();
     }
     
     public void setSelectorTimeout(long timeout) {
-        ep.setSelectorTimeout(timeout);
+        ((NioEndpoint)endpoint).setSelectorTimeout(timeout);
     }
     
     public long getSelectorTimeout() {
-        return ep.getSelectorTimeout();
-    }
-    // *
-    public Executor getExecutor() {
-        return ep.getExecutor();
+        return ((NioEndpoint)endpoint).getSelectorTimeout();
     }
-
     // *
-    public void setExecutor(Executor executor) {
-        ep.setExecutor(executor);
-    }
-    
-    public int getMaxThreads() {
-        return ep.getMaxThreads();
-    }
-
-    public void setMaxThreads( int maxThreads ) {
-        ep.setMaxThreads(maxThreads);
-        setAttribute("maxThreads", "" + maxThreads);
-    }
 
-    public void setThreadPriority(int threadPriority) {
-      ep.setThreadPriority(threadPriority);
-      setAttribute("threadPriority", "" + threadPriority);
-    }
     
     public void setAcceptorThreadPriority(int threadPriority) {
-      ep.setAcceptorThreadPriority(threadPriority);
+        ((NioEndpoint)endpoint).setAcceptorThreadPriority(threadPriority);
       setAttribute("acceptorThreadPriority", "" + threadPriority);
     }
 
     public void setPollerThreadPriority(int threadPriority) {
-      ep.setPollerThreadPriority(threadPriority);
+        ((NioEndpoint)endpoint).setPollerThreadPriority(threadPriority);
       setAttribute("pollerThreadPriority", "" + threadPriority);
     }
 
-    public int getThreadPriority() {
-      return ep.getThreadPriority();
-    }
-
     public int getAcceptorThreadPriority() {
-      return ep.getAcceptorThreadPriority();
+      return ((NioEndpoint)endpoint).getAcceptorThreadPriority();
     }
     
     public int getPollerThreadPriority() {
-      return ep.getThreadPriority();
+      return ((NioEndpoint)endpoint).getThreadPriority();
     }
     
     
     public boolean getUseSendfile() {
-        return ep.getUseSendfile();
+        return ((NioEndpoint)endpoint).getUseSendfile();
     }
 
     public void setUseSendfile(boolean useSendfile) {
-        ep.setUseSendfile(useSendfile);
+        ((NioEndpoint)endpoint).setUseSendfile(useSendfile);
     }
     
     // -------------------- Tcp setup --------------------
-
-    public int getBacklog() {
-        return ep.getBacklog();
-    }
-
-    public void setBacklog( int i ) {
-        ep.setBacklog(i);
-        setAttribute("backlog", "" + i);
-    }
-
-    public int getPort() {
-        return ep.getPort();
-    }
-
-    public void setPort( int port ) {
-        ep.setPort(port);
-        setAttribute("port", "" + port);
-    }
-
-    public InetAddress getAddress() {
-        return ep.getAddress();
-    }
-
-    public void setAddress(InetAddress ia) {
-        ep.setAddress( ia );
-        setAttribute("address", "" + ia);
-    }
-
-    public String getName() {
-        String encodedAddr = "";
-        if (getAddress() != null) {
-            encodedAddr = "" + getAddress();
-            if (encodedAddr.startsWith("/"))
-                encodedAddr = encodedAddr.substring(1);
-            encodedAddr = URLEncoder.encode(encodedAddr) + "-";
-        }
-        return ("http-" + encodedAddr + ep.getPort());
-    }
-
-    public boolean getTcpNoDelay() {
-        return ep.getTcpNoDelay();
-    }
-
-    public void setTcpNoDelay( boolean b ) {
-        ep.setTcpNoDelay( b );
-        setAttribute("tcpNoDelay", "" + b);
-    }
-
-    public boolean getDisableUploadTimeout() {
-        return disableUploadTimeout;
-    }
-
-    public void setDisableUploadTimeout(boolean isDisabled) {
-        disableUploadTimeout = isDisabled;
-    }
-
-    public int getSocketBuffer() {
-        return socketBuffer;
-    }
-
-    public void setSocketBuffer(int valueI) {
-        socketBuffer = valueI;
-    }
-
-    public String getCompression() {
-        return compression;
-    }
-
-    public void setCompression(String valueS) {
-        compression = valueS;
-        setAttribute("compression", valueS);
-    }
-
-    public int getMaxSavePostSize() {
-        return maxSavePostSize;
-    }
-
-    public void setMaxSavePostSize(int valueI) {
-        maxSavePostSize = valueI;
-        setAttribute("maxSavePostSize", "" + valueI);
-    }
-
-    public int getMaxHttpHeaderSize() {
-        return maxHttpHeaderSize;
-    }
-
-    public void setMaxHttpHeaderSize(int valueI) {
-        maxHttpHeaderSize = valueI;
-        setAttribute("maxHttpHeaderSize", "" + valueI);
-    }
-
-    public String getRestrictedUserAgents() {
-        return restrictedUserAgents;
-    }
-
-    public void setRestrictedUserAgents(String valueS) {
-        restrictedUserAgents = valueS;
-        setAttribute("restrictedUserAgents", valueS);
-    }
-
-    public String getNoCompressionUserAgents() {
-        return noCompressionUserAgents;
-    }
-
-    public void setNoCompressionUserAgents(String valueS) {
-        noCompressionUserAgents = valueS;
-        setAttribute("noCompressionUserAgents", valueS);
-    }
-
-    public String getCompressableMimeType() {
-        return compressableMimeTypes;
-    }
-
-    public void setCompressableMimeType(String valueS) {
-        compressableMimeTypes = valueS;
-        setAttribute("compressableMimeTypes", valueS);
-    }
-
-    public int getCompressionMinSize() {
-        return compressionMinSize;
-    }
-
-    public void setCompressionMinSize(int valueI) {
-        compressionMinSize = valueI;
-        setAttribute("compressionMinSize", "" + valueI);
-    }
-
-    public int getSoLinger() {
-        return ep.getSoLinger();
-    }
-
-    public void setSoLinger( int i ) {
-        ep.setSoLinger( i );
-        setAttribute("soLinger", "" + i);
-    }
-
-    public int getSoTimeout() {
-        return ep.getSoTimeout();
-    }
-
-    public void setSoTimeout( int i ) {
-        ep.setSoTimeout(i);
-        setAttribute("soTimeout", "" + i);
-    }
-    
-    public void setKeepAliveTimeout(int keepAliveTimeout) {
-        ep.setKeepAliveTimeout(keepAliveTimeout);
-    }
-    
-    public int getKeepAliveTimeout() {
-        return ep.getKeepAliveTimeout();
-    }
-
     public String getProtocol() {
         return getProperty("protocol");
     }
@@ -469,42 +177,6 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
         setAttribute("protocol", k);
     }
 
-    public boolean getSecure() {
-        return secure;
-    }
-
-    public void setSecure( boolean b ) {
-        ep.setSecure(b);
-        secure=b;
-        setAttribute("secure", "" + b);
-    }
-
-    public int getMaxKeepAliveRequests() {
-        return ep.getMaxKeepAliveRequests();
-    }
-
-    /** Set the maximum number of Keep-Alive requests that we will honor.
-     */
-    public void setMaxKeepAliveRequests(int mkar) {
-        ep.setMaxKeepAliveRequests(mkar);
-        setAttribute("maxKeepAliveRequests", "" + mkar);
-    }
-
-    /**
-     * Return the Keep-Alive policy for the connection.
-     */
-    public boolean getKeepAlive() {
-        return ((ep.getMaxKeepAliveRequests() != 0) && (ep.getMaxKeepAliveRequests() != 1));
-    }
-
-    /**
-     * Set the keep-alive policy for this connection.
-     */
-    public void setKeepAlive(boolean keepAlive) {
-        if (!keepAlive) {
-            setMaxKeepAliveRequests(1);
-        }
-    }
 
     public int getSocketCloseDelay() {
         return socketCloseDelay;
@@ -515,79 +187,14 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
         setAttribute("socketCloseDelay", "" + d);
     }
 
-    public void setServer( String server ) {
-        this.server = server;
-    }
-
-    public String getServer() {
-        return server;
-    }
-
-    public int getTimeout() {
-        return timeout;
-    }
-
-    public void setTimeout( int timeouts ) {
-        timeout = timeouts;
-        setAttribute("timeout", "" + timeouts);
-    }
-
-    public void setProcessorCache(int processorCache) {
-        this.processorCache = processorCache;
-    }
-
     public void setOomParachute(int oomParachute) {
-        ep.setOomParachute(oomParachute);
+        ((NioEndpoint)endpoint).setOomParachute(oomParachute);
         setAttribute("oomParachute", Integer.valueOf(oomParachute));
     }
 
     // --------------------  SSL related properties --------------------
 
-    public String getKeystoreFile() { return ep.getKeystoreFile();}
-    public void setKeystoreFile(String s ) { ep.setKeystoreFile(s);}
-    public void setKeystore(String s) { setKeystoreFile(s);}
-    public String getKeystore(){ return getKeystoreFile();}
-    
-    public String getKeyAlias() { return ep.getKeyAlias();}
-    public void setKeyAlias(String s ) { ep.setKeyAlias(s);}
-
-    
-    public String getAlgorithm() { return ep.getAlgorithm();}
-    public void setAlgorithm(String s ) { ep.setAlgorithm(s);}
-    
-    public void setClientauth(String s) {setClientAuth(s);}
-    public String getClientauth(){ return getClientAuth();}
-    public String getClientAuth() { return ep.getClientAuth();}
-    public void setClientAuth(String s ) { ep.setClientAuth(s);}
-    
-    public String getKeystorePass() { return ep.getKeystorePass();}
-    public void setKeystorePass(String s ) { ep.setKeystorePass(s);}
-    public void setKeypass(String s) { setKeystorePass(s);}
-    public String getKeypass() { return getKeystorePass();}
-    public String getKeystoreType() { return ep.getKeystoreType();}
-    public void setKeystoreType(String s ) { ep.setKeystoreType(s);}
-    public String getKeytype() { return getKeystoreType();}
-    public void setKeytype(String s ) { setKeystoreType(s);}
-
-    public void setTruststoreFile(String f){ep.setTruststoreFile(f);}
-    public String getTruststoreFile(){return ep.getTruststoreFile();}
-    public void setTruststorePass(String p){ep.setTruststorePass(p);}
-    public String getTruststorePass(){return ep.getTruststorePass();}
-    public void setTruststoreType(String t){ep.setTruststoreType(t);}
-    public String getTruststoreType(){ return ep.getTruststoreType();}
-    
     
-    public String getSslProtocol() { return ep.getSslProtocol();}
-    public void setSslProtocol(String s) { ep.setSslProtocol(s);}
-    
-    public String getCiphers() { return ep.getCiphers();}
-    public void setCiphers(String s) { ep.setCiphers(s);}
-    
-    public boolean getSSLEnabled() { return ep.isSSLEnabled(); }
-    public void setSSLEnabled(boolean SSLEnabled) { ep.setSSLEnabled(SSLEnabled); }
-    
-    
-
     // --------------------  Connection handler --------------------
 
     static class Http11ConnectionHandler implements Handler {
@@ -602,7 +209,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
             protected AtomicInteger size = new AtomicInteger(0);
             @Override
             public boolean offer(Http11NioProcessor processor) {
-                boolean offer = proto.processorCache==-1?true:size.get() < proto.processorCache;
+                boolean offer = proto.getProcessorCache()==-1?true:size.get() < proto.getProcessorCache();
                 //avoid over growing our cache or add after we have stopped
                 boolean result = false;
                 if ( offer ) {
@@ -737,7 +344,7 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
 
                 processor.action(ActionCode.ACTION_START, null);
                 
-                if (proto.ep.isSSLEnabled() && (proto.sslImplementation != null)) {
+                if (proto.endpoint.isSSLEnabled() && (proto.sslImplementation != null)) {
                     if (socket instanceof SecureNioChannel) {
                         SecureNioChannel ch = (SecureNioChannel)socket;
                         processor.setSslSupport(proto.sslImplementation.getSSLSupport(ch.getSslEngine().getSession()));
@@ -798,20 +405,20 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
 
         public Http11NioProcessor createProcessor() {
             Http11NioProcessor processor = new Http11NioProcessor(
-              proto.maxHttpHeaderSize,
-              proto.ep);
+              proto.getMaxHttpHeaderSize(),
+              (NioEndpoint)proto.endpoint);
             processor.setAdapter(proto.adapter);
             processor.setMaxKeepAliveRequests(proto.getMaxKeepAliveRequests());
-            processor.setTimeout(proto.timeout);
-            processor.setDisableUploadTimeout(proto.disableUploadTimeout);
-            processor.setCompressionMinSize(proto.compressionMinSize);
-            processor.setCompression(proto.compression);
-            processor.setNoCompressionUserAgents(proto.noCompressionUserAgents);
-            processor.setCompressableMimeTypes(proto.compressableMimeTypes);
-            processor.setRestrictedUserAgents(proto.restrictedUserAgents);
-            processor.setSocketBuffer(proto.socketBuffer);
-            processor.setMaxSavePostSize(proto.maxSavePostSize);
-            processor.setServer(proto.server);
+            processor.setTimeout(proto.getTimeout());
+            processor.setDisableUploadTimeout(proto.getDisableUploadTimeout());
+            processor.setCompressionMinSize(proto.getCompressionMinSize());
+            processor.setCompression(proto.getCompression());
+            processor.setNoCompressionUserAgents(proto.getNoCompressionUserAgents());
+            processor.setCompressableMimeTypes(proto.getCompressableMimeTypes());
+            processor.setRestrictedUserAgents(proto.getRestrictedUserAgents());
+            processor.setSocketBuffer(proto.getSocketBuffer());
+            processor.setMaxSavePostSize(proto.getMaxSavePostSize());
+            processor.setServer(proto.getServer());
             register(processor);
             return processor;
         }
@@ -861,42 +468,4 @@ public class Http11NioProtocol implements ProtocolHandler, MBeanRegistration
     protected static org.apache.juli.logging.Log log
         = org.apache.juli.logging.LogFactory.getLog(Http11NioProtocol.class);
 
-    // -------------------- Various implementation classes --------------------
-
-    protected String domain;
-    protected ObjectName oname;
-    protected MBeanServer mserver;
-
-    public ObjectName getObjectName() {
-        return oname;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public int getProcessorCache() {
-        return processorCache;
-    }
-
-    public int getOomParachute() {
-        return ep.getOomParachute();
-    }
-
-    public ObjectName preRegister(MBeanServer server,
-                                  ObjectName name) throws Exception {
-        oname=name;
-        mserver=server;
-        domain=name.getDomain();
-        return name;
-    }
-
-    public void postRegister(Boolean registrationDone) {
-    }
-
-    public void preDeregister() throws Exception {
-    }
-
-    public void postDeregister() {
-    }
 }
index 2813a61..ac54e30 100644 (file)
 
 package org.apache.coyote.http11;
 
-import java.net.InetAddress;
 import java.net.Socket;
-import java.net.URLEncoder;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
 import org.apache.coyote.ActionCode;
-import org.apache.coyote.Adapter;
-import org.apache.coyote.ProtocolHandler;
 import org.apache.coyote.RequestGroupInfo;
 import org.apache.coyote.RequestInfo;
 import org.apache.tomcat.util.modeler.Registry;
@@ -42,7 +34,6 @@ import org.apache.tomcat.util.net.SSLImplementation;
 import org.apache.tomcat.util.net.ServerSocketFactory;
 import org.apache.tomcat.util.net.SocketWrapper;
 import org.apache.tomcat.util.net.JIoEndpoint.Handler;
-import org.apache.tomcat.util.res.StringManager;
 
 
 /**
@@ -53,28 +44,23 @@ import org.apache.tomcat.util.res.StringManager;
  * @author Remy Maucherat
  * @author Costin Manolache
  */
-public class Http11Protocol 
-    implements ProtocolHandler, MBeanRegistration {
+public class Http11Protocol extends AbstractHttp11Protocol {
 
 
     protected static org.apache.juli.logging.Log log
         = org.apache.juli.logging.LogFactory.getLog(Http11Protocol.class);
 
-    /**
-     * The string manager for this package.
-     */
-    protected static final StringManager sm =
-        StringManager.getManager(Constants.Package);
-
 
     // ------------------------------------------------------------ Constructor
 
 
     public Http11Protocol() {
+        endpoint = new JIoEndpoint();
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
         //setServerSoTimeout(Constants.DEFAULT_SERVER_SOCKET_TIMEOUT);
         setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
+        
     }
 
     
@@ -82,73 +68,24 @@ public class Http11Protocol
 
 
     protected Http11ConnectionHandler cHandler = new Http11ConnectionHandler(this);
-    protected JIoEndpoint endpoint = new JIoEndpoint();
-
-
-    // *
-    protected ObjectName tpOname = null;
-    // *
-    protected ObjectName rgOname = null;
 
 
     protected ServerSocketFactory socketFactory = null;
-    protected SSLImplementation sslImplementation = null;
+   
 
 
     // ----------------------------------------- ProtocolHandler Implementation
     // *
 
 
-    protected HashMap<String, Object> attributes = new HashMap<String, Object>();
-
-    
-    /**
-     * Pass config info
-     */
-    public void setAttribute(String name, Object value) {
-        if (log.isTraceEnabled()) {
-            log.trace(sm.getString("http11protocol.setattribute", name, value));
-        }
-        attributes.put(name, value);
-    }
-
-    public Object getAttribute(String key) {
-        return attributes.get(key);
-    }
-
-    public Iterator<String> getAttributeNames() {
-        return attributes.keySet().iterator();
-    }
 
-    /**
-     * Set a property.
-     */
-    public boolean setProperty(String name, String value) {
-        setAttribute(name, value);
-        if (name.startsWith("socket.")) {
-            return endpoint.setProperty(name, value);
-        }
-        return true;
-    }
 
-    /**
-     * Get a property
-     */
-    public String getProperty(String name) {
-        return (String)getAttribute(name);
-    }
 
-    /**
-     * The adapter, used to call the connector.
-     */
-    protected Adapter adapter;
-    public void setAdapter(Adapter adapter) { this.adapter = adapter; }
-    public Adapter getAdapter() { return adapter; }
 
 
     public void init() throws Exception {
-        endpoint.setName(getName());
-        endpoint.setHandler(cHandler);
+        ((JIoEndpoint)endpoint).setName(getName());
+        ((JIoEndpoint)endpoint).setHandler(cHandler);
 
         // Verify the validity of the configured socket factory
         try {
@@ -156,10 +93,10 @@ public class Http11Protocol
                 sslImplementation =
                     SSLImplementation.getInstance(sslImplementationName);
                 socketFactory = sslImplementation.getServerSocketFactory();
-                endpoint.setServerSocketFactory(socketFactory);
+                ((JIoEndpoint)endpoint).setServerSocketFactory(socketFactory);
             } else if (socketFactoryName != null) {
                 socketFactory = (ServerSocketFactory) Class.forName(socketFactoryName).newInstance();
-                endpoint.setServerSocketFactory(socketFactory);
+                ((JIoEndpoint)endpoint).setServerSocketFactory(socketFactory);
             }
         } catch (Exception ex) {
             log.error(sm.getString("http11protocol.socketfactory.initerror"),
@@ -213,75 +150,12 @@ public class Http11Protocol
             log.info(sm.getString("http11protocol.start", getName()));
     }
 
-    public void pause() throws Exception {
-        try {
-            endpoint.pause();
-        } catch (Exception ex) {
-            log.error(sm.getString("http11protocol.endpoint.pauseerror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.pause", getName()));
-    }
-
-    public void resume() throws Exception {
-        try {
-            endpoint.resume();
-        } catch (Exception ex) {
-            log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.resume", getName()));
-    }
-
-    public void destroy() throws Exception {
-        if (log.isInfoEnabled())
-            log.info(sm.getString("http11protocol.stop", getName()));
-        endpoint.destroy();
-        if (tpOname!=null)
-            Registry.getRegistry(null, null).unregisterComponent(tpOname);
-        if (rgOname != null)
-            Registry.getRegistry(null, null).unregisterComponent(rgOname);
-    }
-
-    public String getName() {
-        String encodedAddr = "";
-        if (getAddress() != null) {
-            encodedAddr = "" + getAddress();
-            if (encodedAddr.startsWith("/"))
-                encodedAddr = encodedAddr.substring(1);
-            encodedAddr = URLEncoder.encode(encodedAddr) + "-";
-        }
-        return ("http-" + encodedAddr + endpoint.getPort());
-    }
 
     // ------------------------------------------------------------- Properties
 
     
-    /**
-     * Processor cache.
-     */
-    protected int processorCache = -1;
-    public int getProcessorCache() { return this.processorCache; }
-    public void setProcessorCache(int processorCache) { this.processorCache = processorCache; }
-
-    protected int socketBuffer = 9000;
-    public int getSocketBuffer() { return socketBuffer; }
-    public void setSocketBuffer(int socketBuffer) { this.socketBuffer = socketBuffer; }
-
-    /**
-     * This field indicates if the protocol is secure from the perspective of
-     * the client (= https is used).
-     */
-    protected boolean secure;
-    public boolean getSecure() { return secure; }
-    public void setSecure(boolean b) { secure = b; }
 
-    protected boolean SSLEnabled = false;
-    public boolean isSSLEnabled() { return SSLEnabled;}
-    public void setSSLEnabled(boolean SSLEnabled) {this.SSLEnabled = SSLEnabled;}    
-    
     /**
      * Name of the socket factory.
      */
@@ -299,227 +173,6 @@ public class Http11Protocol
         setSecure(true);
     }
     
-    
-    // HTTP
-    /**
-     * Maximum number of requests which can be performed over a keepalive 
-     * connection. The default is the same as for Apache HTTP Server.
-     */
-    protected int maxKeepAliveRequests = 100;
-    public int getMaxKeepAliveRequests() { return maxKeepAliveRequests; }
-    public void setMaxKeepAliveRequests(int mkar) { 
-        maxKeepAliveRequests = mkar;
-        endpoint.setMaxKeepAliveRequests(mkar);
-    }
-
-    // HTTP
-    /**
-     * The number of seconds Tomcat will wait for a subsequent request
-     * before closing the connection. The default is the same as for
-     * Apache HTTP Server (15 000 milliseconds).
-     */
-    protected int keepAliveTimeout = -1;
-    public int getKeepAliveTimeout() { return keepAliveTimeout; }
-    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; }
-
-    // HTTP
-    /**
-     * This timeout represents the socket timeout which will be used while
-     * the adapter execution is in progress, unless disableUploadTimeout
-     * is set to true. The default is the same as for Apache HTTP Server
-     * (300 000 milliseconds).
-     */
-    protected int timeout = 300000;
-    public int getTimeout() { return timeout; }
-    public void setTimeout(int timeout) { this.timeout = timeout; }
-
-
-    // *
-    /**
-     * Maximum size of the post which will be saved when processing certain
-     * requests, such as a POST.
-     */
-    protected int maxSavePostSize = 4 * 1024;
-    public int getMaxSavePostSize() { return maxSavePostSize; }
-    public void setMaxSavePostSize(int valueI) { maxSavePostSize = valueI; }
-
-
-    // HTTP
-    /**
-     * Maximum size of the HTTP message header.
-     */
-    protected int maxHttpHeaderSize = 8 * 1024;
-    public int getMaxHttpHeaderSize() { return maxHttpHeaderSize; }
-    public void setMaxHttpHeaderSize(int valueI) { maxHttpHeaderSize = valueI; }
-
-
-    // HTTP
-    /**
-     * If true, the regular socket timeout will be used for the full duration
-     * of the connection.
-     */
-    protected boolean disableUploadTimeout = true;
-    public boolean getDisableUploadTimeout() { return disableUploadTimeout; }
-    public void setDisableUploadTimeout(boolean isDisabled) { disableUploadTimeout = isDisabled; }
-
-
-    // HTTP
-    /**
-     * Integrated compression support.
-     */
-    protected String compression = "off";
-    public String getCompression() { return compression; }
-    public void setCompression(String valueS) { compression = valueS; }
-    
-    
-    // HTTP
-    protected String noCompressionUserAgents = null;
-    public String getNoCompressionUserAgents() { return noCompressionUserAgents; }
-    public void setNoCompressionUserAgents(String valueS) { noCompressionUserAgents = valueS; }
-
-    
-    // HTTP
-    protected String compressableMimeTypes = "text/html,text/xml,text/plain";
-    public String getCompressableMimeType() { return compressableMimeTypes; }
-    public void setCompressableMimeType(String valueS) { compressableMimeTypes = valueS; }
-    
-    
-    // HTTP
-    protected int compressionMinSize = 2048;
-    public int getCompressionMinSize() { return compressionMinSize; }
-    public void setCompressionMinSize(int valueI) { compressionMinSize = valueI; }
-
-
-    // HTTP
-    /**
-     * User agents regular expressions which should be restricted to HTTP/1.0 support.
-     */
-    protected String restrictedUserAgents = null;
-    public String getRestrictedUserAgents() { return restrictedUserAgents; }
-    public void setRestrictedUserAgents(String valueS) { restrictedUserAgents = valueS; }
-    
-    // HTTP
-    /**
-     * Server header.
-     */
-    protected String server;
-    public void setServer( String server ) { this.server = server; }
-    public String getServer() { return server; }
-
-    public Executor getExecutor() { return endpoint.getExecutor(); }
-    public void setExecutor(Executor executor) { endpoint.setExecutor(executor); }
-    
-    public int getMaxThreads() { return endpoint.getMaxThreads(); }
-    public void setMaxThreads(int maxThreads) { endpoint.setMaxThreads(maxThreads); }
-
-    public int getThreadPriority() { return endpoint.getThreadPriority(); }
-    public void setThreadPriority(int threadPriority) { endpoint.setThreadPriority(threadPriority); }
-
-    public int getBacklog() { return endpoint.getBacklog(); }
-    public void setBacklog(int backlog) { endpoint.setBacklog(backlog); }
-
-    public int getPort() { return endpoint.getPort(); }
-    public void setPort(int port) { endpoint.setPort(port); }
-
-    public InetAddress getAddress() { return endpoint.getAddress(); }
-    public void setAddress(InetAddress ia) { endpoint.setAddress(ia); }
-
-    public boolean getTcpNoDelay() { return endpoint.getTcpNoDelay(); }
-    public void setTcpNoDelay(boolean tcpNoDelay) { endpoint.setTcpNoDelay(tcpNoDelay); }
-
-    public int getSoLinger() { return endpoint.getSoLinger(); }
-    public void setSoLinger(int soLinger) { endpoint.setSoLinger(soLinger); }
-
-    public int getSoTimeout() { return endpoint.getSoTimeout(); }
-    public void setSoTimeout(int soTimeout) { endpoint.setSoTimeout(soTimeout); }
-
-    // HTTP
-    /**
-     * Return the Keep-Alive policy for the connection.
-     */
-    public boolean getKeepAlive() {
-        return ((maxKeepAliveRequests != 0) && (maxKeepAliveRequests != 1));
-    }
-
-    // HTTP
-    /**
-     * Set the keep-alive policy for this connection.
-     */
-    public void setKeepAlive(boolean keepAlive) {
-        if (!keepAlive) {
-            setMaxKeepAliveRequests(1);
-        }
-    }
-
-    /*
-     * Note: All the following are JSSE/java.io specific attributes.
-     */
-    
-    public String getKeystore() {
-        return (String) getAttribute("keystore");
-    }
-
-    public void setKeystore( String k ) {
-        setAttribute("keystore", k);
-    }
-
-    public String getKeypass() {
-        return (String) getAttribute("keypass");
-    }
-
-    public void setKeypass( String k ) {
-        attributes.put("keypass", k);
-        //setAttribute("keypass", k);
-    }
-
-    public String getKeytype() {
-        return (String) getAttribute("keystoreType");
-    }
-
-    public void setKeytype( String k ) {
-        setAttribute("keystoreType", k);
-    }
-
-    public String getClientauth() {
-        return (String) getAttribute("clientauth");
-    }
-
-    public void setClientauth( String k ) {
-        setAttribute("clientauth", k);
-    }
-
-    public String getProtocols() {
-        return (String) getAttribute("protocols");
-    }
-
-    public void setProtocols(String k) {
-        setAttribute("protocols", k);
-    }
-
-    public String getAlgorithm() {
-        return (String) getAttribute("algorithm");
-    }
-
-    public void setAlgorithm( String k ) {
-        setAttribute("algorithm", k);
-    }
-
-    public String getCiphers() {
-        return (String) getAttribute("ciphers");
-    }
-
-    public void setCiphers(String ciphers) {
-        setAttribute("ciphers", ciphers);
-    }
-
-    public String getKeyAlias() {
-        return (String) getAttribute("keyAlias");
-    }
-
-    public void setKeyAlias(String keyAlias) {
-        setAttribute("keyAlias", keyAlias);
-    }
-
     // -----------------------------------  Http11ConnectionHandler Inner Class
 
     protected static class Http11ConnectionHandler implements Handler {
@@ -533,7 +186,7 @@ public class Http11Protocol
             protected AtomicInteger size = new AtomicInteger(0);
             @Override
             public boolean offer(Http11Processor processor) {
-                boolean offer = (proto.processorCache == -1) ? true : (size.get() < proto.processorCache);
+                boolean offer = (proto.getProcessorCache() == -1) ? true : (size.get() < proto.getProcessorCache());
                 //avoid over growing our cache or add after we have stopped
                 boolean result = false;
                 if ( offer ) {
@@ -623,20 +276,20 @@ public class Http11Protocol
         
         protected Http11Processor createProcessor() {
             Http11Processor processor =
-                new Http11Processor(proto.maxHttpHeaderSize, proto.endpoint);
+                new Http11Processor(proto.getMaxHttpHeaderSize(), (JIoEndpoint)proto.endpoint);
             processor.setAdapter(proto.adapter);
-            processor.setMaxKeepAliveRequests(proto.maxKeepAliveRequests);
-            processor.setKeepAliveTimeout(proto.keepAliveTimeout);
-            processor.setTimeout(proto.timeout);
-            processor.setDisableUploadTimeout(proto.disableUploadTimeout);
-            processor.setCompressionMinSize(proto.compressionMinSize);
-            processor.setCompression(proto.compression);
-            processor.setNoCompressionUserAgents(proto.noCompressionUserAgents);
-            processor.setCompressableMimeTypes(proto.compressableMimeTypes);
-            processor.setRestrictedUserAgents(proto.restrictedUserAgents);
-            processor.setSocketBuffer(proto.socketBuffer);
-            processor.setMaxSavePostSize(proto.maxSavePostSize);
-            processor.setServer(proto.server);
+            processor.setMaxKeepAliveRequests(proto.getMaxKeepAliveRequests());
+            processor.setKeepAliveTimeout(proto.getKeepAliveTimeout());
+            processor.setTimeout(proto.getTimeout());
+            processor.setDisableUploadTimeout(proto.getDisableUploadTimeout());
+            processor.setCompressionMinSize(proto.getCompressionMinSize());
+            processor.setCompression(proto.getCompression());
+            processor.setNoCompressionUserAgents(proto.getNoCompressionUserAgents());
+            processor.setCompressableMimeTypes(proto.getCompressableMimeTypes());
+            processor.setRestrictedUserAgents(proto.getRestrictedUserAgents());
+            processor.setSocketBuffer(proto.getSocketBuffer());
+            processor.setMaxSavePostSize(proto.getMaxSavePostSize());
+            processor.setServer(proto.getServer());
             register(processor);
             return processor;
         }
@@ -685,35 +338,4 @@ public class Http11Protocol
     }
 
 
-    // -------------------- JMX related methods --------------------
-
-    // *
-    protected String domain;
-    protected ObjectName oname;
-    protected MBeanServer mserver;
-
-    public ObjectName getObjectName() {
-        return oname;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    public ObjectName preRegister(MBeanServer server,
-                                  ObjectName name) throws Exception {
-        oname=name;
-        mserver=server;
-        domain=name.getDomain();
-        return name;
-    }
-
-    public void postRegister(Boolean registrationDone) {
-    }
-
-    public void preDeregister() throws Exception {
-    }
-
-    public void postDeregister() {
-    }
 }
index 2c2d5fb..2e3b3ae 100644 (file)
  */
 package org.apache.tomcat.util.net;
 
+import java.io.File;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.util.StringTokenizer;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 
@@ -392,5 +394,109 @@ public abstract class AbstractEndpoint {
         }
     }    
     
+    public abstract void pause();
+    public abstract void resume();
+    public abstract void start() throws Exception;
+    public abstract void destroy() throws Exception;
+    public abstract void init() throws Exception;
+    
+    public String adjustRelativePath(String path, String relativeTo) {
+        File f = new File(path);
+        if ( !f.isAbsolute()) {
+            path = relativeTo + File.separator + path;
+            f = new File(path);
+        }
+        if (!f.exists()) {
+            log.warn("configured file:["+path+"] does not exist.");
+        }
+        return path;
+    }
+    
+    public String defaultIfNull(String val, String defaultValue) {
+        if (val==null) return defaultValue;
+        else return val;
+    }
+    // --------------------  SSL related properties --------------------
+    private String truststoreFile = System.getProperty("javax.net.ssl.trustStore");
+    public void setTruststoreFile(String s) {
+        s = adjustRelativePath(s,System.getProperty("catalina.base"));
+        this.truststoreFile = s;
+    }
+    public String getTruststoreFile() {return truststoreFile;}
+    private String truststorePass = System.getProperty("javax.net.ssl.trustStorePassword");
+    public void setTruststorePass(String truststorePass) {this.truststorePass = truststorePass;}
+    public String getTruststorePass() {return truststorePass;}
+    private String truststoreType = System.getProperty("javax.net.ssl.trustStoreType");
+    public void setTruststoreType(String truststoreType) {this.truststoreType = truststoreType;}
+    public String getTruststoreType() {return truststoreType;}
+
+    private String keystoreFile = System.getProperty("user.home")+"/.keystore";
+    public String getKeystoreFile() { return keystoreFile;}
+    public void setKeystoreFile(String s ) { 
+        s = adjustRelativePath(s,System.getProperty("catalina.base"));
+        this.keystoreFile = s; 
+    }
+    public void setKeystore(String s ) { setKeystoreFile(s);}
+    public String getKeystore() { return getKeystoreFile();}
+
+    private String keyAlias = null;
+    public String getKeyAlias() { return keyAlias;}
+    public void setKeyAlias(String s ) { keyAlias = s;}
+    
+    
+    private String algorithm = "SunX509";
+    public String getAlgorithm() { return algorithm;}
+    public void setAlgorithm(String s ) { this.algorithm = s;}
+
+    private String clientAuth = "false";
+    public String getClientAuth() { return clientAuth;}
+    public void setClientAuth(String s ) { this.clientAuth = s;}
+    
+    private String keystorePass = "changeit";
+    public String getKeystorePass() { return keystorePass;}
+    public void setKeystorePass(String s ) { this.keystorePass = s;}
+    
+    private String keystoreType = "JKS";
+    public String getKeystoreType() { return keystoreType;}
+    public void setKeystoreType(String s ) { this.keystoreType = s;}
+
+    private String sslProtocol = "TLS"; 
+    public String getSslProtocol() { return sslProtocol;}
+    public void setSslProtocol(String s) { sslProtocol = s;}
+    
+    private String sslEnabledProtocols=null; //"TLSv1,SSLv3,SSLv2Hello"
+    private String[] sslEnabledProtocolsarr =  new String[0];
+    public String[] getSslEnabledProtocolsArray() { return this.sslEnabledProtocolsarr;}
+    public void setSslEnabledProtocols(String s) {
+        this.sslEnabledProtocols = s;
+        StringTokenizer t = new StringTokenizer(s,",");
+        sslEnabledProtocolsarr = new String[t.countTokens()];
+        for (int i=0; i<sslEnabledProtocolsarr.length; i++ ) sslEnabledProtocolsarr[i] = t.nextToken();
+    }
+    
+    private String ciphers = null;
+    private String[] ciphersarr = new String[0];
+    public String[] getCiphersArray() { return this.ciphersarr;}
+    public String getCiphers() { return ciphers;}
+    public void setCiphers(String s) { 
+        ciphers = s;
+        if ( s == null ) ciphersarr = new String[0];
+        else {
+            StringTokenizer t = new StringTokenizer(s,",");
+            ciphersarr = new String[t.countTokens()];
+            for (int i=0; i<ciphersarr.length; i++ ) ciphersarr[i] = t.nextToken();
+        }
+    }
+
+    private int sessionCacheSize = 0;
+    public int getSessionCacheSize() { return sessionCacheSize;}
+    public void setSessionCacheSize(int i) { sessionCacheSize = i;}
+
+    private int sessionCacheTimeout = 86400;
+    public int getSessionCacheTimeout() { return sessionCacheTimeout;}
+    public void setSessionCacheTimeout(int i) { sessionCacheTimeout = i;}
+
+
+    
 }
 
index 7a9f22f..205813f 100644 (file)
@@ -376,112 +376,6 @@ public class NioEndpoint extends AbstractEndpoint {
 
 
 
-    public String adjustRelativePath(String path, String relativeTo) {
-        File f = new File(path);
-        if ( !f.isAbsolute()) {
-            path = relativeTo + File.separator + path;
-            f = new File(path);
-        }
-        if (!f.exists()) {
-            log.warn("configured file:["+path+"] does not exist.");
-        }
-        return path;
-    }
-    
-    public String defaultIfNull(String val, String defaultValue) {
-        if (val==null) return defaultValue;
-        else return val;
-    }
-    // --------------------  SSL related properties --------------------
-    protected String truststoreFile = System.getProperty("javax.net.ssl.trustStore");
-    public void setTruststoreFile(String s) {
-        s = adjustRelativePath(s,System.getProperty("catalina.base"));
-        this.truststoreFile = s;
-    }
-    public String getTruststoreFile() {return truststoreFile;}
-    protected String truststorePass = System.getProperty("javax.net.ssl.trustStorePassword");
-    public void setTruststorePass(String truststorePass) {this.truststorePass = truststorePass;}
-    public String getTruststorePass() {return truststorePass;}
-    protected String truststoreType = System.getProperty("javax.net.ssl.trustStoreType");
-    public void setTruststoreType(String truststoreType) {this.truststoreType = truststoreType;}
-    public String getTruststoreType() {return truststoreType;}
-
-    protected String keystoreFile = System.getProperty("user.home")+"/.keystore";
-    public String getKeystoreFile() { return keystoreFile;}
-    public void setKeystoreFile(String s ) { 
-        s = adjustRelativePath(s,System.getProperty("catalina.base"));
-        this.keystoreFile = s; 
-    }
-    public void setKeystore(String s ) { setKeystoreFile(s);}
-    public String getKeystore() { return getKeystoreFile();}
-
-    String keyAlias = null;
-    public String getKeyAlias() { return keyAlias;}
-    public void setKeyAlias(String s ) { keyAlias = s;}
-    
-    
-    protected String algorithm = "SunX509";
-    public String getAlgorithm() { return algorithm;}
-    public void setAlgorithm(String s ) { this.algorithm = s;}
-
-    protected String clientAuth = "false";
-    public String getClientAuth() { return clientAuth;}
-    public void setClientAuth(String s ) { this.clientAuth = s;}
-    
-    protected String keystorePass = "changeit";
-    public String getKeystorePass() { return keystorePass;}
-    public void setKeystorePass(String s ) { this.keystorePass = s;}
-    
-    protected String keystoreType = "JKS";
-    public String getKeystoreType() { return keystoreType;}
-    public void setKeystoreType(String s ) { this.keystoreType = s;}
-
-    protected String sslProtocol = "TLS"; 
-    public String getSslProtocol() { return sslProtocol;}
-    public void setSslProtocol(String s) { sslProtocol = s;}
-    
-    protected String sslEnabledProtocols=null; //"TLSv1,SSLv3,SSLv2Hello"
-    protected String[] sslEnabledProtocolsarr =  new String[0];
-    public void setSslEnabledProtocols(String s) {
-        this.sslEnabledProtocols = s;
-        StringTokenizer t = new StringTokenizer(s,",");
-        sslEnabledProtocolsarr = new String[t.countTokens()];
-        for (int i=0; i<sslEnabledProtocolsarr.length; i++ ) sslEnabledProtocolsarr[i] = t.nextToken();
-    }
-    
-    protected String ciphers = null;
-    protected String[] ciphersarr = new String[0];
-    public String getCiphers() { return ciphers;}
-    public void setCiphers(String s) { 
-        ciphers = s;
-        if ( s == null ) ciphersarr = new String[0];
-        else {
-            StringTokenizer t = new StringTokenizer(s,",");
-            ciphersarr = new String[t.countTokens()];
-            for (int i=0; i<ciphersarr.length; i++ ) ciphersarr[i] = t.nextToken();
-        }
-    }
-
-    protected int sessionCacheSize = 0;
-    public int getSessionCacheSize() { return sessionCacheSize;}
-    public void setSessionCacheSize(int i) { sessionCacheSize = i;}
-
-    protected int sessionCacheTimeout = 86400;
-    public int getSessionCacheTimeout() { return sessionCacheTimeout;}
-    public void setSessionCacheTimeout(int i) { sessionCacheTimeout = i;}
-
-    /**
-     * SSL engine.
-     */
-    protected boolean SSLEnabled = false;
-    @Override
-    public boolean isSSLEnabled() { return SSLEnabled;}
-    @Override
-    public void setSSLEnabled(boolean SSLEnabled) {this.SSLEnabled = SSLEnabled;}
-
-    protected boolean secure = false;
-    public boolean getSecure() { return secure;}
-    public void setSecure(boolean b) { secure = b;}
 
     public void setSelectorPool(NioSelectorPool selectorPool) {
         this.selectorPool = selectorPool;
@@ -637,8 +531,8 @@ public class NioEndpoint extends AbstractEndpoint {
             SSLSessionContext sessionContext =
                 sslContext.getServerSessionContext();
             if (sessionContext != null) {
-                sessionContext.setSessionCacheSize(sessionCacheSize);
-                sessionContext.setSessionTimeout(sessionCacheTimeout);
+                sessionContext.setSessionCacheSize(getSessionCacheSize());
+                sessionContext.setSessionTimeout(getSessionCacheTimeout());
             }
         }
         
@@ -861,8 +755,8 @@ public class NioEndpoint extends AbstractEndpoint {
             engine.setWantClientAuth(true);
         }
         engine.setUseClientMode(false);
-        if ( ciphersarr.length > 0 ) engine.setEnabledCipherSuites(ciphersarr);
-        if ( sslEnabledProtocolsarr.length > 0 ) engine.setEnabledProtocols(sslEnabledProtocolsarr);
+        if ( getCiphersArray().length > 0 ) engine.setEnabledCipherSuites(getCiphersArray());
+        if ( getSslEnabledProtocolsArray().length > 0 ) engine.setEnabledProtocols(getSslEnabledProtocolsArray());
         
         return engine;
     }
index 6cc6fa6..8df514f 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.tomcat.util.net;
 
 import java.net.Socket;
 
+import javax.net.ssl.SSLSession;
+
 /* SSLImplementation:
 
    Abstract factory and base class for all SSL implementations.
@@ -81,4 +83,5 @@ abstract public class SSLImplementation {
     abstract public String getImplementationName();
     abstract public ServerSocketFactory getServerSocketFactory();
     abstract public SSLSupport getSSLSupport(Socket sock);
+    abstract public SSLSupport getSSLSupport(SSLSession session);
 }