You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/12/06 16:01:34 UTC
svn commit: r1042670 - in /tomcat/trunk/java/org/apache/coyote: ./ ajp/
http11/
Author: markt
Date: Mon Dec 6 15:01:34 2010
New Revision: 1042670
URL: http://svn.apache.org/viewvc?rev=1042670&view=rev
Log:
Re-factoring in support of https://issues.apache.org/bugzilla/show_bug.cgi?id=50360
Start to pull more getters/setters and the generic attribute handling. Note that the comments around generic attribute handling are aspirational in some cases but subsequent commits should align the behaviour to the comments.
Modified:
tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java
tomcat/trunk/java/org/apache/coyote/LocalStrings.properties
tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java
tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties
tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings_es.properties
tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties
tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_es.properties
tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_fr.properties
tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_ja.properties
Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java Mon Dec 6 15:01:34 2010
@@ -16,16 +16,28 @@
*/
package org.apache.coyote;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.concurrent.Executor;
+
import javax.management.MBeanRegistration;
import javax.management.ObjectName;
import org.apache.juli.logging.Log;
import org.apache.tomcat.util.net.AbstractEndpoint;
+import org.apache.tomcat.util.res.StringManager;
public abstract class AbstractProtocolHandler implements ProtocolHandler,
MBeanRegistration {
/**
+ * The string manager for this package.
+ */
+ protected static final StringManager sm =
+ StringManager.getManager(Constants.Package);
+
+
+ /**
* Name of MBean for the Global Request Processor.
*/
protected ObjectName rgOname = null;
@@ -45,6 +57,83 @@ public abstract class AbstractProtocolHa
protected AbstractEndpoint endpoint = null;
+ // ----------------------------------------------- Generic property handling
+
+ /**
+ * Attributes provide a way for configuration to be passed to sub-components
+ * without the {@link ProtocolHandler} being aware of the properties
+ * available on those sub-components. One example of such a sub-component is
+ * the {@link org.apache.tomcat.util.net.ServerSocketFactory}.
+ */
+ protected HashMap<String, Object> attributes =
+ new HashMap<String, Object>();
+
+
+ /**
+ * Generic property setter called when a property for which a specific
+ * setter already exists within the {@link ProtocolHandler} needs to be
+ * made available to sub-components. The specific setter will call this
+ * method to populate the attributes.
+ */
+ @Override
+ public void setAttribute(String name, Object value) {
+ if (getLog().isTraceEnabled()) {
+ getLog().trace(sm.getString("abstractProtocolHandler.setAttribute",
+ name, value));
+ }
+ attributes.put(name, value);
+ }
+
+
+ /**
+ * Used by sub-components to retrieve configuration information.
+ */
+ @Override
+ public Object getAttribute(String key) {
+ Object value = attributes.get(key);
+ if (getLog().isTraceEnabled()) {
+ getLog().trace(sm.getString("abstractProtocolHandler.getAttribute",
+ key, value));
+ }
+ return value;
+ }
+
+
+ /**
+ * Used by sub-components to retrieve configuration information.
+ */
+ @Override
+ public Iterator<String> getAttributeNames() {
+ return attributes.keySet().iterator();
+ }
+
+
+ /**
+ * Generic property setter used by the digester. Other code should not need
+ * to use this. The digester will only use this method if it can't find a
+ * more specific setter. That means the property belongs to the Endpoint,
+ * the ServerSocketFactory or some other lower level component. This method
+ * ensures that it is visible to both.
+ */
+ public boolean setProperty(String name, String value) {
+ setAttribute(name, value);
+ return endpoint.setProperty(name, value);
+ }
+
+
+ /**
+ * Generic property getter used by the digester. Other code should not need
+ * to use this.
+ */
+ public String getProperty(String name) {
+ // Since all calls to setProperty() will place the property in the
+ // attributes list, just retrieve it from there.
+ return (String)getAttribute(name);
+ }
+
+
+ // ------------------------------- Properties managed by the ProtocolHandler
+
/**
* The adapter provides the link between the ProtocolHandler and the
* connector.
@@ -56,6 +145,57 @@ public abstract class AbstractProtocolHa
public Adapter getAdapter() { return adapter; }
+ // ---------------------- Properties that are passed through to the EndPoint
+
+ @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 getMinSpareThreads() { return endpoint.getMinSpareThreads(); }
+ public void setMinSpareThreads(int minSpareThreads) {
+ endpoint.setMinSpareThreads(minSpareThreads);
+ }
+
+
+ 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); }
+
+
+ // ------------------------ Properties that are made available as attributes
+ // -------------------------------------(and passed through to the EndPoint)
+
+
+
+ // -------------------------------------------------------- Abstract methods
/**
* Concrete implementations need to provide access to their logger to be
* used by the abstract classes.
Modified: tomcat/trunk/java/org/apache/coyote/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/LocalStrings.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/LocalStrings.properties Mon Dec 6 15:01:34 2010
@@ -13,4 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+abstractProtocolHandler.getAttribute=Get attribute [{0}] with value [{1}]
+abstractProtocolHandler.setAttribute=Set attribute [{0}] with value [{1}]
+
asyncStateMachine.invalidAsyncState=Calling [{0}] is not valid for a request with Async state [{1}]
Modified: 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=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AbstractAjpProtocol.java Mon Dec 6 15:01:34 2010
@@ -18,9 +18,6 @@ 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.MBeanServer;
import javax.management.ObjectName;
@@ -35,48 +32,6 @@ public abstract class AbstractAjpProtoco
*/
protected static final StringManager sm = StringManager.getManager(Constants.Package);
- 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
- return endpoint.setProperty(name, value);
- }
-
- /**
- * Get a property
- */
- public String getProperty(String name) {
- return (String)getAttribute(name);
- }
-
@Override
public void pause() throws Exception {
try {
@@ -143,35 +98,10 @@ public abstract class AbstractAjpProtoco
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 getMinSpareThreads() { return endpoint.getMinSpareThreads(); }
- public void setMinSpareThreads(int minSpareThreads) { endpoint.setMinSpareThreads(minSpareThreads); }
-
-
- 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); }
Modified: tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties Mon Dec 6 15:01:34 2010
@@ -29,8 +29,6 @@ ajpprotocol.endpoint.starterror=Error st
ajpprotocol.endpoint.stoperror=Error stopping endpoint
ajpprotocol.init=Initializing Coyote AJP/1.3 on {0}
ajpprotocol.proto.error=Error reading request, ignored
-ajpprotocol.getattribute=Attribute {0}
-ajpprotocol.setattribute=Attribute {0}: {1}
ajpprotocol.start=Starting Coyote AJP/1.3 on {0}
ajpprotocol.stop=Stopping Coyote AJP/1.3 on {0}
ajpprotocol.pause=Pausing Coyote AJP/1.3 on {0}
Modified: tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings_es.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings_es.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings_es.properties Mon Dec 6 15:01:34 2010
@@ -17,8 +17,6 @@ ajpprotocol.endpoint.initerror = Error i
ajpprotocol.endpoint.starterror = Error arrancando punto final
ajpprotocol.init = Inicializando Coyote AJP/1.3 en {0}
ajpprotocol.proto.error = Error leyendo requerimiento, ignorado
-ajpprotocol.getattribute = Atributo {0}
-ajpprotocol.setattribute = Atributo {0}\: {1}
ajpprotocol.start = Arrancando Coyote AJP/1.3 en {0}
ajpprotocol.stop = Parando Coyote AJP/1.3 en {0}
ajpprotocol.pause = Pausando Coyote AJP/1.3 en {0}
Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Protocol.java Mon Dec 6 15:01:34 2010
@@ -18,9 +18,6 @@ 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.MBeanServer;
import javax.management.ObjectName;
@@ -39,47 +36,6 @@ public abstract class AbstractHttp11Prot
protected SSLImplementation sslImplementation = null;
- 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("http11protocol.setattribute", name, value));
- }
- attributes.put(name, value);
- }
-
- @Override
- public Object getAttribute(String key) {
- if (getLog().isTraceEnabled())
- getLog().trace(sm.getString("http11protocol.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
- return endpoint.setProperty(name, value);
- }
-
- /**
- * 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 );
@@ -318,33 +274,6 @@ public abstract class AbstractHttp11Prot
}
@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 getMinSpareThreads() { return endpoint.getMinSpareThreads(); }
- public void setMinSpareThreads(int minSpareThreads) { endpoint.setMinSpareThreads(minSpareThreads); }
-
- 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); }
-
- @Override
public abstract void init() throws Exception;
// -------------------- JMX related methods --------------------
Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties Mon Dec 6 15:01:34 2010
@@ -23,8 +23,6 @@ http11protocol.proto.ioexception.debug=I
http11protocol.proto.ioexception.info=IOException reading request, ignored
http11protocol.proto.socketexception.debug=SocketException reading request
http11protocol.proto.socketexception.info=SocketException reading request, ignored
-http11protocol.getattribute=Attribute {0}
-http11protocol.setattribute=Attribute {0}: {1}
http11protocol.socketfactory.initerror=Error initializing socket factory
http11protocol.start=Starting Coyote HTTP/1.1 on {0}
http11protocol.stop=Stopping Coyote HTTP/1.1 on {0}
Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_es.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_es.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_es.properties Mon Dec 6 15:01:34 2010
@@ -21,8 +21,6 @@ http11protocol.proto.ioexception.debug =
http11protocol.proto.ioexception.info = IOException leyendo requerimiento, ignorada
http11protocol.proto.socketexception.debug = SocketException leyendo requerimiento
http11protocol.proto.socketexception.info = SocketException leyendo requerimiento, ignorada
-http11protocol.getattribute = Atributo {0}
-http11protocol.setattribute = Atributo {0}\: {1}
http11protocol.socketfactory.initerror = Error inicializando f\u00E1brica de enchufes (sockets)
http11protocol.start = Arrancando Coyote HTTP/1.1 en puerto {0}
http11protocol.stop = Parando Coyote HTTP/1.1 en puerto {0}
Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_fr.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_fr.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_fr.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_fr.properties Mon Dec 6 15:01:34 2010
@@ -21,7 +21,6 @@ http11protocol.proto.ioexception.debug=E
http11protocol.proto.ioexception.info=Exception d'entr\u00e9e/sortie \u00e0 la lecture de la requ\u00eate, ignor\u00e9
http11protocol.proto.socketexception.debug=Exception "Socket" (SocketException) \u00e0 la lecture de la requ\u00eate
http11protocol.proto.socketexception.info=Exception "Socket" (SocketException) \u00e0 la lecture de la requ\u00eate, ignor\u00e9
-http11protocol.setattribute=Attribut {0}: {1}
http11protocol.socketfactory.initerror=Erreur \u00e0 l'initialisation du cr\u00e9ateur de socket (socket factory)
http11protocol.start=D\u00e9marrage de Coyote HTTP/1.1 sur {0}
http11protocol.stop=Arr\u00eat de Coyote HTTP/1.1 sur {0}
Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_ja.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_ja.properties?rev=1042670&r1=1042669&r2=1042670&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_ja.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings_ja.properties Mon Dec 6 15:01:34 2010
@@ -21,7 +21,6 @@ http11protocol.proto.ioexception.debug=\
http11protocol.proto.ioexception.info=\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8aad\u307f\u8fbc\u307f\u4e2d\u306eIOException\u3067\u3059\u304c\u3001\u7121\u8996\u3055\u308c\u307e\u3057\u305f
http11protocol.proto.socketexception.debug=\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8aad\u307f\u8fbc\u307f\u4e2d\u306eSocketException\u3067\u3059
http11protocol.proto.socketexception.info=\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8aad\u307f\u8fbc\u307f\u4e2d\u306eSocketException\u3067\u3059\u304c\u3001\u7121\u8996\u3055\u308c\u307e\u3057\u305f
-http11protocol.setattribute=\u5c5e\u6027 {0}: {1}
http11protocol.socketfactory.initerror=\u30bd\u30b1\u30c3\u30c8\u30d5\u30a1\u30af\u30c8\u30ea\u3092\u521d\u671f\u5316\u4e2d\u306e\u30a8\u30e9\u30fc\u3067\u3059
http11protocol.start=Coyote HTTP/1.1\u3092 {0} \u3067\u8d77\u52d5\u3057\u307e\u3059
http11protocol.stop=Coyote HTTP/1.1\u3092 {0} \u3067\u505c\u6b62\u3057\u307e\u3059
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org