Author: kfujino
Date: Thu Oct  7 08:54:51 2010
New Revision: 1005367

URL: http://svn.apache.org/viewvc?rev=1005367&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50054
Correctly handle the setting of minSpareThreads in AJP connector.
Other attributes (acceptorThreadCount etc.) are correctly set by this fix. 

Added:
    tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java   (with 
props)
Modified:
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
    tomcat/trunk/webapps/docs/changelog.xml

Added: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java?rev=1005367&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java (added)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java Thu Oct  7 
08:54:51 2010
@@ -0,0 +1,282 @@
+/*
+ *  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.ajp;
+
+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.juli.logging.Log;
+import org.apache.tomcat.util.modeler.Registry;
+import org.apache.tomcat.util.net.AbstractEndpoint;
+import org.apache.tomcat.util.res.StringManager;
+
+public abstract class AbstractAjpProtocol implements ProtocolHandler, 
MBeanRegistration {
+    /**
+     * The string manager for this package.
+     */
+    protected static final StringManager sm = 
StringManager.getManager(Constants.Package);
+    
+    protected abstract Log getLog();
+    
+    protected ObjectName tpOname = null;
+    protected ObjectName rgOname = null;
+
+    protected AbstractEndpoint endpoint = null;
+    
+    /**
+     * The adapter, used to call the connector.
+     */
+    protected Adapter adapter;
+    
+    protected HashMap<String, Object> attributes = new HashMap<String, 
Object>();
+    
+    /** 
+     * Pass config info
+     */
+    @Override
+    public void setAttribute(String name, Object value) {
+        if (getLog().isTraceEnabled()) {
+            getLog().trace(sm.getString("ajpprotocol.setattribute", name, 
value));
+        }
+        attributes.put(name, value);
+    }
+
+    @Override
+    public Object getAttribute(String key) {
+        if (getLog().isTraceEnabled()) {
+            getLog().trace(sm.getString("ajpprotocol.getattribute", key));
+        }
+        return attributes.get(key);
+    }
+
+
+    @Override
+    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);
+    }
+
+    /**
+     * The adapter, used to call the connector
+     */
+    @Override
+    public void setAdapter(Adapter adapter) {
+        this.adapter = adapter;
+    }
+
+
+    @Override
+    public Adapter getAdapter() {
+        return adapter;
+    }
+
+    @Override
+    public void pause() throws Exception {
+        try {
+            endpoint.pause();
+        } catch (Exception ex) {
+            getLog().error(sm.getString("ajpprotocol.endpoint.pauseerror"), 
ex);
+            throw ex;
+        }
+        if (getLog().isInfoEnabled())
+            getLog().info(sm.getString("ajpprotocol.pause", getName()));
+    }
+
+    @Override
+    public void resume() throws Exception {
+        try {
+            endpoint.resume();
+        } catch (Exception ex) {
+            getLog().error(sm.getString("ajpprotocol.endpoint.resumeerror"), 
ex);
+            throw ex;
+        }
+        if (getLog().isInfoEnabled())
+            getLog().info(sm.getString("ajpprotocol.resume", getName()));
+    }
+
+    @Override
+    public void stop() throws Exception {
+        try {
+            endpoint.stop();
+        } catch (Exception ex) {
+            getLog().error(sm.getString("ajpprotocol.endpoint.stoperror"), ex);
+            throw ex;
+        }
+        if (getLog().isInfoEnabled())
+            getLog().info(sm.getString("ajpprotocol.stop", getName()));
+    }
+
+    @Override
+    public void destroy() throws Exception {
+        if (getLog().isInfoEnabled())
+            getLog().info(sm.getString("ajpprotocol.destroy", 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 ("ajp-" + encodedAddr + endpoint.getPort());
+    }
+
+    /**
+     * Processor cache.
+     */
+    protected int processorCache = -1;
+    public int getProcessorCache() { return this.processorCache; }
+    public void setProcessorCache(int processorCache) { this.processorCache = 
processorCache; }
+
+    @Override
+    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); }
+
+    /**
+     * Should authentication be done in the native webserver layer, 
+     * or in the Servlet container ?
+     */
+    protected boolean tomcatAuthentication = true;
+    public boolean getTomcatAuthentication() { return tomcatAuthentication; }
+    public void setTomcatAuthentication(boolean tomcatAuthentication) { 
this.tomcatAuthentication = tomcatAuthentication; }
+
+    /**
+     * Required secret.
+     */
+    protected String requiredSecret = null;
+    public void setRequiredSecret(String requiredSecret) { this.requiredSecret 
= requiredSecret; }
+    
+    /**
+     * AJP packet size.
+     */
+    protected int packetSize = Constants.MAX_PACKET_SIZE;
+    public int getPacketSize() { return packetSize; }
+    public void setPacketSize(int packetSize) {
+        if(packetSize < Constants.MAX_PACKET_SIZE) {
+            this.packetSize = Constants.MAX_PACKET_SIZE;
+        } else {
+            this.packetSize = packetSize;
+        }
+    }
+
+    
+    /**
+     * The number of seconds Tomcat will wait for a subsequent request
+     * before closing the connection.
+     */
+    protected int keepAliveTimeout = -1;
+    public int getKeepAliveTimeout() { return keepAliveTimeout; }
+    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; 
}
+
+    // -------------------- JMX related methods --------------------
+
+    protected String domain;
+    protected ObjectName oname;
+    protected MBeanServer mserver;
+
+    public ObjectName getObjectName() {
+        return oname;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    @Override
+    public ObjectName preRegister(MBeanServer server,
+                                  ObjectName name) throws Exception {
+        oname=name;
+        mserver=server;
+        domain=name.getDomain();
+        return name;
+    }
+
+    @Override
+    public void postRegister(Boolean registrationDone) {
+        // NOOP
+    }
+
+    @Override
+    public void preDeregister() throws Exception {
+        // NOOP
+    }
+
+    @Override
+    public void postDeregister() {
+        // NOOP
+    }
+}

Propchange: tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=1005367&r1=1005366&r2=1005367&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Thu Oct  7 
08:54:51 2010
@@ -17,22 +17,13 @@
 
 package org.apache.coyote.ajp;
 
-import java.net.InetAddress;
-import java.net.URLEncoder;
-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 java.util.concurrent.atomic.AtomicLong;
 
-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.coyote.RequestGroupInfo;
 import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
@@ -40,10 +31,9 @@ import org.apache.juli.logging.LogFactor
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.tomcat.util.net.AprEndpoint;
-import org.apache.tomcat.util.net.AprEndpoint.Handler;
 import org.apache.tomcat.util.net.SocketStatus;
 import org.apache.tomcat.util.net.SocketWrapper;
-import org.apache.tomcat.util.res.StringManager;
+import org.apache.tomcat.util.net.AprEndpoint.Handler;
 
 
 /**
@@ -54,23 +44,19 @@ import org.apache.tomcat.util.res.String
  * @author Remy Maucherat
  * @author Costin Manolache
  */
-public class AjpAprProtocol 
-    implements ProtocolHandler, MBeanRegistration {
+public class AjpAprProtocol extends AbstractAjpProtocol {
     
     
     private static final Log log = LogFactory.getLog(AjpAprProtocol.class);
 
-    /**
-     * The string manager for this package.
-     */
-    protected static final StringManager sm =
-        StringManager.getManager(Constants.Package);
-
+    @Override
+    protected Log getLog() { return log; }
 
     // ------------------------------------------------------------ Constructor
 
 
     public AjpAprProtocol() {
+        endpoint = new AprEndpoint();
         cHandler = new AjpConnectionHandler(this);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
@@ -82,31 +68,6 @@ public class AjpAprProtocol 
     // ----------------------------------------------------- Instance Variables
 
 
-    protected ObjectName tpOname;
-    
-    
-    protected ObjectName rgOname;
-
-
-    /**
-     * Associated APR endpoint.
-     */
-    protected AprEndpoint endpoint = new AprEndpoint();
-
-
-    /**
-     * Configuration attributes.
-     */
-    protected Hashtable<String,Object> attributes =
-        new Hashtable<String,Object>();
-
-
-    /**
-     * Adapter which will process the requests received by this endpoint.
-     */
-    private Adapter adapter;
-    
-    
     /**
      * Connection handler for AJP.
      */
@@ -116,54 +77,13 @@ public class AjpAprProtocol 
     // --------------------------------------------------------- Public Methods
 
 
-    /** 
-     * Pass config info
-     */
-    @Override
-    public void setAttribute(String name, Object value) {
-        if (log.isTraceEnabled()) {
-            log.trace(sm.getString("ajpprotocol.setattribute", name, value));
-        }
-        attributes.put(name, value);
-    }
-
-    @Override
-    public Object getAttribute(String key) {
-        if (log.isTraceEnabled()) {
-            log.trace(sm.getString("ajpprotocol.getattribute", key));
-        }
-        return attributes.get(key);
-    }
-
-
-    @Override
-    public Iterator<String> getAttributeNames() {
-        return attributes.keySet().iterator();
-    }
-
-
-    /**
-     * The adapter, used to call the connector
-     */
-    @Override
-    public void setAdapter(Adapter adapter) {
-        this.adapter = adapter;
-    }
-
-
-    @Override
-    public Adapter getAdapter() {
-        return adapter;
-    }
-
-
     /** Start the protocol
      */
     @Override
     public void init() throws Exception {
         endpoint.setName(getName());
-        endpoint.setHandler(cHandler);
-        endpoint.setUseSendfile(false);
+        ((AprEndpoint)endpoint).setHandler(cHandler);
+        ((AprEndpoint)endpoint).setUseSendfile(false);
 
         try {
             endpoint.init();
@@ -204,144 +124,17 @@ public class AjpAprProtocol 
             log.info(sm.getString("ajpprotocol.start", getName()));
     }
 
-    @Override
-    public void pause() throws Exception {
-        try {
-            endpoint.pause();
-        } catch (Exception ex) {
-            log.error(sm.getString("ajpprotocol.endpoint.pauseerror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.pause", getName()));
-    }
-
-    @Override
-    public void resume() throws Exception {
-        try {
-            endpoint.resume();
-        } catch (Exception ex) {
-            log.error(sm.getString("ajpprotocol.endpoint.resumeerror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.resume", getName()));
-    }
-
-    @Override
-    public void stop() throws Exception {
-        try {
-            endpoint.stop();
-        } catch (Exception ex) {
-            log.error(sm.getString("ajpprotocol.endpoint.stoperror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.stop", getName()));
-    }
-
-    @Override
-    public void destroy() throws Exception {
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.destroy", 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 ("ajp-" + encodedAddr + endpoint.getPort());
-    }
-
-    /**
-     * Processor cache.
-     */
-    protected int processorCache = -1;
-    public int getProcessorCache() { return this.processorCache; }
-    public void setProcessorCache(int processorCache) { this.processorCache = 
processorCache; }
-
-    @Override
-    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); }
-
-    /**
-     * Should authentication be done in the native webserver layer, 
-     * or in the Servlet container ?
-     */
-    protected boolean tomcatAuthentication = true;
-    public boolean getTomcatAuthentication() { return tomcatAuthentication; }
-    public void setTomcatAuthentication(boolean tomcatAuthentication) { 
this.tomcatAuthentication = tomcatAuthentication; }
-
-    /**
-     * Required secret.
-     */
-    protected String requiredSecret = null;
-    public void setRequiredSecret(String requiredSecret) { this.requiredSecret 
= requiredSecret; }
-    
-    /**
-     * AJP packet size.
-     */
-    protected int packetSize = Constants.MAX_PACKET_SIZE;
-    public int getPacketSize() { return packetSize; }
-    public void setPacketSize(int packetSize) {
-        if(packetSize < Constants.MAX_PACKET_SIZE) {
-            this.packetSize = Constants.MAX_PACKET_SIZE;
-        } else {
-            this.packetSize = packetSize;
-        }
-    }
-
-    /**
-     * The number of seconds Tomcat will wait for a subsequent request
-     * before closing the connection.
-     */
-    public int getKeepAliveTimeout() { return endpoint.getKeepAliveTimeout(); }
-    public void setKeepAliveTimeout(int timeout) { 
endpoint.setKeepAliveTimeout(timeout); }
 
     public boolean getUseSendfile() { return endpoint.getUseSendfile(); }
     public void setUseSendfile(@SuppressWarnings("unused") boolean 
useSendfile) {
         /* No sendfile for AJP */
     }
 
-    public int getPollTime() { return endpoint.getPollTime(); }
-    public void setPollTime(int pollTime) { endpoint.setPollTime(pollTime); }
+    public int getPollTime() { return ((AprEndpoint)endpoint).getPollTime(); }
+    public void setPollTime(int pollTime) { 
((AprEndpoint)endpoint).setPollTime(pollTime); }
 
-    public void setPollerSize(int pollerSize) { 
endpoint.setPollerSize(pollerSize); }
-    public int getPollerSize() { return endpoint.getPollerSize(); }
+    public void setPollerSize(int pollerSize) { 
((AprEndpoint)endpoint).setPollerSize(pollerSize); }
+    public int getPollerSize() { return 
((AprEndpoint)endpoint).getPollerSize(); }
 
     // --------------------------------------  AjpConnectionHandler Inner Class
 
@@ -482,7 +275,7 @@ public class AjpAprProtocol 
                         connections.remove(socket);
                         recycledProcessors.offer(result);
                         if (state == SocketState.OPEN) {
-                            
proto.endpoint.getPoller().add(socket.getSocket().longValue());
+                            
((AprEndpoint)proto.endpoint).getPoller().add(socket.getSocket().longValue());
                         }
                     }
                 }
@@ -491,7 +284,7 @@ public class AjpAprProtocol 
         }
         
         protected AjpAprProcessor createProcessor() {
-            AjpAprProcessor processor = new AjpAprProcessor(proto.packetSize, 
proto.endpoint);
+            AjpAprProcessor processor = new AjpAprProcessor(proto.packetSize, 
(AprEndpoint)proto.endpoint);
             processor.setAdapter(proto.adapter);
             processor.setTomcatAuthentication(proto.tomcatAuthentication);
             processor.setRequiredSecret(proto.requiredSecret);
@@ -542,43 +335,4 @@ public class AjpAprProtocol 
 
     }
 
-
-    // -------------------- Various implementation classes --------------------
-
-
-    protected String domain;
-    protected ObjectName oname;
-    protected MBeanServer mserver;
-
-    public ObjectName getObjectName() {
-        return oname;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    @Override
-    public ObjectName preRegister(MBeanServer server,
-                                  ObjectName name) throws Exception {
-        oname=name;
-        mserver=server;
-        domain=name.getDomain();
-        return name;
-    }
-
-    @Override
-    public void postRegister(Boolean registrationDone) {
-        // NOOP
-    }
-
-    @Override
-    public void preDeregister() throws Exception {
-        // NOOP
-    }
-
-    @Override
-    public void postDeregister() {
-        // NOOP
-    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java?rev=1005367&r1=1005366&r2=1005367&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java Thu Oct  7 
08:54:51 2010
@@ -17,35 +17,25 @@
 
 package org.apache.coyote.ajp;
 
-import java.net.InetAddress;
 import java.net.Socket;
-import java.net.URLEncoder;
-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 java.util.concurrent.atomic.AtomicLong;
 
-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.coyote.RequestGroupInfo;
 import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.modeler.Registry;
-import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.net.JIoEndpoint;
-import org.apache.tomcat.util.net.JIoEndpoint.Handler;
 import org.apache.tomcat.util.net.SocketStatus;
 import org.apache.tomcat.util.net.SocketWrapper;
-import org.apache.tomcat.util.res.StringManager;
+import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
+import org.apache.tomcat.util.net.JIoEndpoint.Handler;
 
 
 /**
@@ -56,23 +46,19 @@ import org.apache.tomcat.util.res.String
  * @author Remy Maucherat
  * @author Costin Manolache
  */
-public class AjpProtocol 
-    implements ProtocolHandler, MBeanRegistration {
+public class AjpProtocol extends AbstractAjpProtocol {
     
     
     private static final Log log = LogFactory.getLog(AjpProtocol.class);
 
-    /**
-     * The string manager for this package.
-     */
-    protected static final StringManager sm =
-        StringManager.getManager(Constants.Package);
-
+    @Override
+    protected Log getLog() { return log; }
 
     // ------------------------------------------------------------ Constructor
 
 
     public AjpProtocol() {
+        endpoint = new JIoEndpoint();
         cHandler = new AjpConnectionHandler(this);
         setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
         setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
@@ -83,31 +69,6 @@ public class AjpProtocol 
     
     // ----------------------------------------------------- Instance Variables
 
-
-    protected ObjectName tpOname;
-    
-    
-    protected ObjectName rgOname;
-
-
-    /**
-     * Associated java.io endpoint.
-     */
-    protected JIoEndpoint endpoint = new JIoEndpoint();
-
-
-    /**
-     * Configuration attributes.
-     */
-    protected Hashtable<String,Object> attributes =
-        new Hashtable<String,Object>();
-
-
-    /**
-     * Adapter which will process the requests received by this endpoint.
-     */
-    private Adapter adapter;
-    
     
     /**
      * Connection handler for AJP.
@@ -118,53 +79,12 @@ public class AjpProtocol 
     // --------------------------------------------------------- Public Methods
 
 
-    /** 
-     * Pass config info
-     */
-    @Override
-    public void setAttribute(String name, Object value) {
-        if (log.isTraceEnabled()) {
-            log.trace(sm.getString("ajpprotocol.setattribute", name, value));
-        }
-        attributes.put(name, value);
-    }
-
-    @Override
-    public Object getAttribute(String key) {
-        if (log.isTraceEnabled()) {
-            log.trace(sm.getString("ajpprotocol.getattribute", key));
-        }
-        return attributes.get(key);
-    }
-
-
-    @Override
-    public Iterator<String> getAttributeNames() {
-        return attributes.keySet().iterator();
-    }
-
-
-    /**
-     * The adapter, used to call the connector
-     */
-    @Override
-    public void setAdapter(Adapter adapter) {
-        this.adapter = adapter;
-    }
-
-
-    @Override
-    public Adapter getAdapter() {
-        return adapter;
-    }
-
-
     /** Start the protocol
      */
     @Override
     public void init() throws Exception {
         endpoint.setName(getName());
-        endpoint.setHandler(cHandler);
+        ((JIoEndpoint)endpoint).setHandler(cHandler);
 
         try {
             endpoint.init();
@@ -205,136 +125,6 @@ public class AjpProtocol 
             log.info(sm.getString("ajpprotocol.start", getName()));
     }
 
-    @Override
-    public void pause() throws Exception {
-        try {
-            endpoint.pause();
-        } catch (Exception ex) {
-            log.error(sm.getString("ajpprotocol.endpoint.pauseerror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.pause", getName()));
-    }
-
-    @Override
-    public void resume() throws Exception {
-        try {
-            endpoint.resume();
-        } catch (Exception ex) {
-            log.error(sm.getString("ajpprotocol.endpoint.resumeerror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.resume", getName()));
-    }
-
-    @Override
-    public void stop() throws Exception {
-        try {
-            endpoint.stop();
-        } catch (Exception ex) {
-            log.error(sm.getString("ajpprotocol.endpoint.stoperror"), ex);
-            throw ex;
-        }
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.stop", getName()));
-    }
-
-    @Override
-    public void destroy() throws Exception {
-        if (log.isInfoEnabled())
-            log.info(sm.getString("ajpprotocol.destroy", 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 ("ajp-" + encodedAddr + endpoint.getPort());
-    }
-
-    /**
-     * Processor cache.
-     */
-    protected int processorCache = -1;
-    public int getProcessorCache() { return this.processorCache; }
-    public void setProcessorCache(int processorCache) { this.processorCache = 
processorCache; }
-
-    @Override
-    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); }
-
-    /**
-     * Should authentication be done in the native webserver layer, 
-     * or in the Servlet container ?
-     */
-    protected boolean tomcatAuthentication = true;
-    public boolean getTomcatAuthentication() { return tomcatAuthentication; }
-    public void setTomcatAuthentication(boolean tomcatAuthentication) { 
this.tomcatAuthentication = tomcatAuthentication; }
-
-    /**
-     * Required secret.
-     */
-    protected String requiredSecret = null;
-    public void setRequiredSecret(String requiredSecret) { this.requiredSecret 
= requiredSecret; }
-    
-    /**
-     * AJP packet size.
-     */
-    protected int packetSize = Constants.MAX_PACKET_SIZE;
-    public int getPacketSize() { return packetSize; }
-    public void setPacketSize(int packetSize) {
-        if(packetSize < Constants.MAX_PACKET_SIZE) {
-            this.packetSize = Constants.MAX_PACKET_SIZE;
-        } else {
-            this.packetSize = packetSize;
-        }
-    }
-
-    
-    /**
-     * The number of seconds Tomcat will wait for a subsequent request
-     * before closing the connection.
-     */
-    protected int keepAliveTimeout = -1;
-    public int getKeepAliveTimeout() { return keepAliveTimeout; }
-    public void setKeepAliveTimeout(int timeout) { keepAliveTimeout = timeout; 
}
-
 
     // --------------------------------------  AjpConnectionHandler Inner Class
 
@@ -444,7 +234,7 @@ public class AjpProtocol 
         }
 
         protected AjpProcessor createProcessor() {
-            AjpProcessor processor = new AjpProcessor(proto.packetSize, 
proto.endpoint);
+            AjpProcessor processor = new AjpProcessor(proto.packetSize, 
(JIoEndpoint)proto.endpoint);
             processor.setAdapter(proto.adapter);
             processor.setTomcatAuthentication(proto.tomcatAuthentication);
             processor.setRequiredSecret(proto.requiredSecret);
@@ -496,43 +286,4 @@ public class AjpProtocol 
 
     }
 
-
-    // -------------------- Various implementation classes --------------------
-
-
-    protected String domain;
-    protected ObjectName oname;
-    protected MBeanServer mserver;
-
-    public ObjectName getObjectName() {
-        return oname;
-    }
-
-    public String getDomain() {
-        return domain;
-    }
-
-    @Override
-    public ObjectName preRegister(MBeanServer server,
-                                  ObjectName name) throws Exception {
-        oname=name;
-        mserver=server;
-        domain=name.getDomain();
-        return name;
-    }
-
-    @Override
-    public void postRegister(Boolean registrationDone) {
-        // NOOP
-    }
-
-    @Override
-    public void preDeregister() throws Exception {
-        // NOOP
-    }
-
-    @Override
-    public void postDeregister() {
-        // NOOP
-    }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1005367&r1=1005366&r2=1005367&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Oct  7 08:54:51 2010
@@ -83,6 +83,10 @@
         <bug>49923</bug>: Avoid using negative timeouts during acceptor unlock
         to ensure APR connector shuts down properly. (mturk) 
       </fix>
+      <fix>
+        <bug>50054</bug>: Correctly handle the setting of minSpareThreads in 
+        AJP connector. (kfujino) 
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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

Reply via email to