You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/02/18 23:51:40 UTC
cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4 CoyoteAdapter.java CoyoteConnector.java
costin 2003/02/18 14:51:40
Modified: coyote/src/java/org/apache/coyote/tomcat4 CoyoteAdapter.java
CoyoteConnector.java
Log:
Merged few changes from 5.0 to enable JMX on thread pools and connector.
This is in the HEAD - jk and http adapters already have the dependency on
JMX and modeler. Note that the code is called only if the connector is registered
with JMX - if not, nothing will happen.
Revision Changes Path
1.14 +4 -34 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java
Index: CoyoteAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- CoyoteAdapter.java 10 Dec 2002 08:43:21 -0000 1.13
+++ CoyoteAdapter.java 18 Feb 2003 22:51:39 -0000 1.14
@@ -64,53 +64,23 @@
package org.apache.coyote.tomcat4;
-import java.io.BufferedInputStream;
-import java.io.EOFException;
-import java.io.InterruptedIOException;
-import java.io.InputStream;
import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.apache.tomcat.util.buf.ByteChunk;
-import org.apache.tomcat.util.buf.HexUtils;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.Cookies;
import org.apache.tomcat.util.http.ServerCookie;
import org.apache.coyote.ActionCode;
-import org.apache.coyote.ActionHook;
import org.apache.coyote.Adapter;
-import org.apache.coyote.InputBuffer;
-import org.apache.coyote.OutputBuffer;
import org.apache.coyote.Request;
import org.apache.coyote.Response;
-import org.apache.catalina.Connector;
-import org.apache.catalina.Container;
import org.apache.catalina.Globals;
-import org.apache.catalina.HttpRequest;
-import org.apache.catalina.HttpResponse;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Logger;
-import org.apache.catalina.util.LifecycleSupport;
-import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.StringManager;
-import org.apache.catalina.util.StringParser;
/**
1.23 +85 -59 jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteConnector.java
Index: CoyoteConnector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteConnector.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- CoyoteConnector.java 10 Feb 2003 09:57:37 -0000 1.22
+++ CoyoteConnector.java 18 Feb 2003 22:51:39 -0000 1.23
@@ -65,36 +65,15 @@
package org.apache.coyote.tomcat4;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.AccessControlException;
-import java.util.Stack;
import java.util.Vector;
-import java.util.Enumeration;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.UnrecoverableKeyException;
-import java.security.KeyManagementException;
-
import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.coyote.ActionCode;
-import org.apache.coyote.ActionHook;
import org.apache.coyote.Adapter;
-import org.apache.coyote.InputBuffer;
-import org.apache.coyote.OutputBuffer;
import org.apache.coyote.ProtocolHandler;
import org.apache.catalina.Connector;
import org.apache.catalina.Container;
-import org.apache.catalina.HttpRequest;
-import org.apache.catalina.HttpResponse;
import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Logger;
@@ -105,6 +84,11 @@
import org.apache.catalina.net.ServerSocketFactory;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
+import org.apache.commons.modeler.Registry;
+
+import javax.management.MBeanRegistration;
+import javax.management.ObjectName;
+import javax.management.MBeanServer;
/**
@@ -115,9 +99,8 @@
* @version $Revision$ $Date$
*/
-
public final class CoyoteConnector
- implements Connector, Lifecycle {
+ implements Connector, Lifecycle, MBeanRegistration {
// ----------------------------------------------------- Instance Variables
@@ -328,7 +311,7 @@
* Coyote Protocol handler class name.
* Defaults to the Coyote HTTP/1.1 protocolHandler.
*/
- private String protocolHandlerClassName =
+ private String protocolHandlerClassName =
"org.apache.coyote.http11.Http11Protocol";
@@ -531,7 +514,7 @@
/**
* Set the value of compression.
- *
+ *
* @param compression The new compression value, which can be "on", "off"
* or "force"
*/
@@ -710,9 +693,9 @@
/**
- * Set the class name of the Coyote protocol handler which will be used
+ * Set the class name of the Coyote protocol handler which will be used
* by the connector.
- *
+ *
* @param protocolHandlerClassName The new class name
*/
public void setProtocolHandlerClassName(String protocolHandlerClassName) {
@@ -803,8 +786,8 @@
/**
* Set the flag to specify upload time-out behavior.
*
- * @param isDisabled If <code>true</code>, then the <code>timeout</code>
- * parameter is ignored. If <code>false</code>, then the
+ * @param isDisabled If <code>true</code>, then the <code>timeout</code>
+ * parameter is ignored. If <code>false</code>, then the
* <code>timeout</code> parameter is used to control uploads.
*/
public void setDisableUploadTimeout( boolean isDisabled ) {
@@ -908,7 +891,7 @@
/**
* Set the value of the Uri validation flag.
- *
+ *
* @param useURIValidationHack The new flag value
*/
public void setUseURIValidationHack(boolean useURIValidationHack) {
@@ -1003,7 +986,7 @@
/**
- * Get the lifecycle listeners associated with this lifecycle. If this
+ * Get the lifecycle listeners associated with this lifecycle. If this
* Lifecycle has no listeners registered, a zero-length array is returned.
*/
public LifecycleListener[] findLifecycleListeners() {
@@ -1032,7 +1015,7 @@
throws LifecycleException {
if (initialized)
- throw new LifecycleException
+ throw new LifecycleException
(sm.getString("coyoteConnector.alreadyInitialized"));
this.initialized = true;
@@ -1052,64 +1035,64 @@
}
protocolHandler.setAdapter(adapter);
- IntrospectionUtils.setProperty(protocolHandler, "jkHome",
+ IntrospectionUtils.setProperty(protocolHandler, "jkHome",
System.getProperty("catalina.base"));
// Set attributes
IntrospectionUtils.setProperty(protocolHandler, "port", "" + port);
- IntrospectionUtils.setProperty(protocolHandler, "maxThreads",
+ IntrospectionUtils.setProperty(protocolHandler, "maxThreads",
"" + maxProcessors);
- IntrospectionUtils.setProperty(protocolHandler, "backlog",
+ IntrospectionUtils.setProperty(protocolHandler, "backlog",
"" + acceptCount);
- IntrospectionUtils.setProperty(protocolHandler, "tcpNoDelay",
+ IntrospectionUtils.setProperty(protocolHandler, "tcpNoDelay",
"" + tcpNoDelay);
IntrospectionUtils.setProperty(protocolHandler, "soLinger",
"" + connectionLinger);
- IntrospectionUtils.setProperty(protocolHandler, "soTimeout",
+ IntrospectionUtils.setProperty(protocolHandler, "soTimeout",
"" + connectionTimeout);
- IntrospectionUtils.setProperty(protocolHandler, "timeout",
+ IntrospectionUtils.setProperty(protocolHandler, "timeout",
"" + connectionTimeout);
- IntrospectionUtils.setProperty(protocolHandler, "disableUploadTimeout",
+ IntrospectionUtils.setProperty(protocolHandler, "disableUploadTimeout",
"" + disableUploadTimeout);
IntrospectionUtils.setProperty(protocolHandler, "maxKeepAliveRequests",
"" + maxKeepAliveRequests);
- IntrospectionUtils.setProperty(protocolHandler, "compression",
+ IntrospectionUtils.setProperty(protocolHandler, "compression",
compression);
if (address != null) {
- IntrospectionUtils.setProperty(protocolHandler, "address",
+ IntrospectionUtils.setProperty(protocolHandler, "address",
address);
}
// Configure secure socket factory
if (factory instanceof CoyoteServerSocketFactory) {
- IntrospectionUtils.setProperty(protocolHandler, "secure",
+ IntrospectionUtils.setProperty(protocolHandler, "secure",
"" + true);
- CoyoteServerSocketFactory ssf =
+ CoyoteServerSocketFactory ssf =
(CoyoteServerSocketFactory) factory;
- IntrospectionUtils.setProperty(protocolHandler, "algorithm",
+ IntrospectionUtils.setProperty(protocolHandler, "algorithm",
ssf.getAlgorithm());
if (ssf.getClientAuth()) {
- IntrospectionUtils.setProperty(protocolHandler, "clientauth",
+ IntrospectionUtils.setProperty(protocolHandler, "clientauth",
"" + ssf.getClientAuth());
}
- IntrospectionUtils.setProperty(protocolHandler, "keystore",
+ IntrospectionUtils.setProperty(protocolHandler, "keystore",
ssf.getKeystoreFile());
- IntrospectionUtils.setProperty(protocolHandler, "randomfile",
+ IntrospectionUtils.setProperty(protocolHandler, "randomfile",
ssf.getRandomFile());
- IntrospectionUtils.setProperty(protocolHandler, "rootfile",
+ IntrospectionUtils.setProperty(protocolHandler, "rootfile",
ssf.getRootFile());
-
- IntrospectionUtils.setProperty(protocolHandler, "keypass",
+
+ IntrospectionUtils.setProperty(protocolHandler, "keypass",
ssf.getKeystorePass());
- IntrospectionUtils.setProperty(protocolHandler, "keytype",
+ IntrospectionUtils.setProperty(protocolHandler, "keytype",
ssf.getKeystoreType());
- IntrospectionUtils.setProperty(protocolHandler, "protocol",
+ IntrospectionUtils.setProperty(protocolHandler, "protocol",
ssf.getProtocol());
- IntrospectionUtils.setProperty(protocolHandler,
- "sSLImplementation",
+ IntrospectionUtils.setProperty(protocolHandler,
+ "sSLImplementation",
ssf.getSSLImplementation());
} else {
- IntrospectionUtils.setProperty(protocolHandler, "secure",
+ IntrospectionUtils.setProperty(protocolHandler, "secure",
"" + false);
}
@@ -1137,6 +1120,21 @@
lifecycle.fireLifecycleEvent(START_EVENT, null);
started = true;
+ // We can't register earlier - the JMX registration of this happens
+ // in Server.start callback
+ if( this.oname != null ) {
+ // We are registred - register the adapter as well.
+ try {
+ Registry.getRegistry().registerComponent(protocolHandler,
+ this.domain, "protocolHandler",
+ "type=protocolHandler,className=" + protocolHandlerClassName);
+ } catch( Exception ex ) {
+ ex.printStackTrace();
+ }
+ } else {
+ log( "Coyote can't register jmx for protocol");
+ }
+
try {
protocolHandler.start();
} catch (Exception e) {
@@ -1172,5 +1170,33 @@
}
+ 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() {
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org