? 0
? tomcat3/CoyoteInterceptor2.java.1
Index: ActionCode.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/ActionCode.java,v
retrieving revision 1.12
diff -u -r1.12 ActionCode.java
--- ActionCode.java	10 Jan 2003 10:21:34 -0000	1.12
+++ ActionCode.java	20 Jan 2003 23:45:15 -0000
@@ -138,7 +138,8 @@
 
 
     // ----------------------------------------------------------- Constructors
-    int code;
+    private int code;
+    private String notificationType;
 
     /**
      * Private constructor.
@@ -149,7 +150,7 @@
 
     /** Action id, useable in switches and table indexes
      */
-    public int getCode() {
+    public final int getCode() {
         return code;
     }
 
Index: Adapter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/Adapter.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Adapter.java
--- Adapter.java	14 Jun 2001 01:07:56 -0000	1.1.1.1
+++ Adapter.java	20 Jan 2003 23:45:15 -0000
@@ -60,7 +60,17 @@
 
 
 /**
- * Adapter.
+ * Adapter. Makes the connection to the high-level request processor.
+ * ( catalina, tomcat3.3, etc ).
+ *
+ * Any coyote implementation must expose a setAdapter( Adapter ) method,
+ * that will be invoked by the servlet container to register itself.
+ *
+ * XXX Names of coyote implementations should be:
+ *   DOMAIN:type=Connector,name=NAME
+ * XXX Adapters ( containers ) need to listen for runtime registration of
+ * connectors.
+ *
  *
  * @author Remy Maucherat
  */
Index: tomcat3/Tomcat3Adapter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Adapter.java,v
retrieving revision 1.4
diff -u -r1.4 Tomcat3Adapter.java
--- tomcat3/Tomcat3Adapter.java	8 Nov 2002 06:20:59 -0000	1.4
+++ tomcat3/Tomcat3Adapter.java	20 Jan 2003 23:45:15 -0000
@@ -60,19 +60,8 @@
 
 package org.apache.coyote.tomcat3;
 
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.text.*;
 import org.apache.tomcat.core.*;
-import org.apache.tomcat.util.res.StringManager;
-import org.apache.tomcat.util.buf.*;
-import org.apache.tomcat.util.http.*;
-import org.apache.tomcat.util.net.*;
-import org.apache.tomcat.util.net.ServerSocketFactory;
-import org.apache.tomcat.util.log.*;
 import org.apache.coyote.Adapter;
-import org.apache.coyote.Processor;
 
 /** Adapter between Coyote and Tomcat.
  *
Index: tomcat3/Tomcat3Request.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Request.java,v
retrieving revision 1.12
diff -u -r1.12 Tomcat3Request.java
--- tomcat3/Tomcat3Request.java	24 Nov 2002 11:56:14 -0000	1.12
+++ tomcat3/Tomcat3Request.java	20 Jan 2003 23:45:15 -0000
@@ -61,19 +61,9 @@
 package org.apache.coyote.tomcat3;
 
 import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.text.*;
 import org.apache.tomcat.core.*;
-import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.buf.*;
-import org.apache.tomcat.util.http.*;
-import org.apache.tomcat.util.net.*;
-import org.apache.tomcat.util.net.ServerSocketFactory;
-import org.apache.tomcat.util.log.*;
-import org.apache.coyote.Adapter;
 import org.apache.coyote.ActionCode;
-import org.apache.coyote.Processor;
 
 /** The Request to connect with Coyote.
  *  This class handles the I/O requirements and transferring the request
Index: tomcat4/CoyoteAdapter.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteAdapter.java,v
retrieving revision 1.13
diff -u -r1.13 CoyoteAdapter.java
--- tomcat4/CoyoteAdapter.java	10 Dec 2002 08:43:21 -0000	1.13
+++ tomcat4/CoyoteAdapter.java	20 Jan 2003 23:45:16 -0000
@@ -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;
 
 
 /**
Index: tomcat4/CoyoteConnector.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteConnector.java,v
retrieving revision 1.21
diff -u -r1.21 CoyoteConnector.java
--- tomcat4/CoyoteConnector.java	15 Jan 2003 15:15:13 -0000	1.21
+++ tomcat4/CoyoteConnector.java	20 Jan 2003 23:45:16 -0000
@@ -65,36 +65,16 @@
 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 +85,10 @@
 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.ObjectName;
+import javax.management.MBeanServer;
+import javax.management.MBeanRegistration;
 
 
 /**
@@ -117,7 +101,7 @@
 
 
 public final class CoyoteConnector
-    implements Connector, Lifecycle {
+    implements Connector, Lifecycle, MBeanRegistration{
 
 
     // ----------------------------------------------------- Instance Variables
@@ -321,7 +305,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";
 
 
@@ -502,7 +486,7 @@
 
     /**
      * Set the value of compression.
-     * 
+     *
      * @param compression The new compression value, which can be "on", "off"
      * or "force"
      */
@@ -681,9 +665,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) {
@@ -784,8 +768,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 ) {
@@ -889,7 +873,7 @@
 
     /**
      * Set the value of the Uri validation flag.
-     * 
+     *
      * @param useURIValidationHack The new flag value
      */
     public void setUseURIValidationHack(boolean useURIValidationHack) {
@@ -984,7 +968,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() {
@@ -1013,7 +997,7 @@
         throws LifecycleException {
 
         if (initialized)
-            throw new LifecycleException 
+            throw new LifecycleException
                 (sm.getString("coyoteConnector.alreadyInitialized"));
 
         this.initialized = true;
@@ -1033,62 +1017,62 @@
         }
         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, "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);
         }
 
@@ -1116,6 +1100,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) {
@@ -1151,5 +1150,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() {
+    }
 
 }
