tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1043531 - in /tomcat/trunk: checkstyle.xml java/org/apache/catalina/connector/Connector.java java/org/apache/catalina/connector/CoyoteAdapter.java java/org/apache/coyote/AbstractProtocolHandler.java java/org/apache/coyote/Adapter.java
Date Wed, 08 Dec 2010 17:15:50 GMT
Author: markt
Date: Wed Dec  8 17:15:50 2010
New Revision: 1043531

URL: http://svn.apache.org/viewvc?rev=1043531&view=rev
Log:
Re-factoring in support of https://issues.apache.org/bugzilla/show_bug.cgi?id=50360
ProtocolHandler should register itself with MBean server rather than have the connector do
it.

Modified:
    tomcat/trunk/checkstyle.xml
    tomcat/trunk/java/org/apache/catalina/connector/Connector.java
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java
    tomcat/trunk/java/org/apache/coyote/Adapter.java

Modified: tomcat/trunk/checkstyle.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/checkstyle.xml?rev=1043531&r1=1043530&r2=1043531&view=diff
==============================================================================
--- tomcat/trunk/checkstyle.xml (original)
+++ tomcat/trunk/checkstyle.xml Wed Dec  8 17:15:50 2010
@@ -27,6 +27,11 @@
   <module name="FileTabCharacter"/>
 
   <module name="TreeWalker">
+    <!-- Block Checks -->
+    <!--  ~60 errors
+    <module name="AvoidNestedBlocks"/>
+    -->
+
     <!-- Coding -->
     <module name="IllegalInstantiation"/>
     
@@ -54,12 +59,12 @@
     https://sourceforge.net/tracker/?func=detail&aid=3039718&group_id=29721&atid=397078
     <module name="GenericWhitespace"/>
     -->
+    <module name="EmptyForInitializerPad"/>
+    <module name="EmptyForIteratorPad"/>
     <!--  ~ 1000 errors
     <module name="OperatorWrap">
       <property name="option" value="oel"/>
     </module>
     -->
-    <module name="EmptyForInitializerPad"/>
-    <module name="EmptyForIteratorPad"/>
   </module>
 </module>
\ No newline at end of file

Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=1043531&r1=1043530&r2=1043531&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Wed Dec  8 17:15:50 2010
@@ -907,9 +907,6 @@ public class Connector extends Lifecycle
                  ("coyoteConnector.protocolHandlerInitializationFailed"), e);
         }
 
-        onameProtocolHandler = register(protocolHandler,
-                createObjectNameKeyProperties("ProtocolHandler"));
-
         // Initialize mapper listener
         mapperListener.init();
     }
@@ -967,7 +964,6 @@ public class Connector extends Lifecycle
     @Override
     protected void destroyInternal() throws LifecycleException {
         mapperListener.destroy();
-        unregister(onameProtocolHandler);
         
         try {
             protocolHandler.destroy();

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1043531&r1=1043530&r2=1043531&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Wed Dec  8 17:15:50
2010
@@ -464,6 +464,12 @@ public class CoyoteAdapter implements Ad
     }
     
     
+    @Override
+    public String getDomain() {
+        return connector.getDomain();
+    }
+
+
     // ------------------------------------------------------ Protected Methods
 
 

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java?rev=1043531&r1=1043530&r2=1043531&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocolHandler.java Wed Dec  8 17:15:50 2010
@@ -23,6 +23,7 @@ import java.util.concurrent.Executor;
 
 import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.juli.logging.Log;
@@ -334,6 +335,24 @@ public abstract class AbstractProtocolHa
         // NOOP
     }
 
+    private ObjectName createObjectName() throws MalformedObjectNameException {
+        // Use the same domain as the connector
+        domain = adapter.getDomain();
+        
+        if (domain == null) {
+            return null;
+        }
+
+        StringBuilder name = new StringBuilder(getDomain());
+        name.append(":type=ProtocolHandler,port=");
+        name.append(getPort());
+        InetAddress address = getAddress();
+        if (address != null) {
+            name.append(",address=");
+            name.append(ObjectName.quote(address.toString()));
+        }
+        return new ObjectName(name.toString());
+    }
 
     // ------------------------------------------------------- Lifecycle methods
 
@@ -349,6 +368,15 @@ public abstract class AbstractProtocolHa
             getLog().info(sm.getString("abstractProtocolHandler.init",
                     getName()));
 
+        if (oname == null) {
+            // Component not pre-registered so register it
+            oname = createObjectName();
+            if (oname != null) {
+                Registry.getRegistry(null, null).registerComponent(this, oname,
+                    null);
+            }
+        }
+
         if (this.domain != null) {
             try {
                 tpOname = new ObjectName(domain + ":" +
@@ -450,6 +478,12 @@ public abstract class AbstractProtocolHa
                     getName()), e);
         }
         
+        // If object was pre-registered (mserver != null) what ever registered
+        // the ProtocolHandler should de-register it
+        if (oname != null && mserver == null) {
+                Registry.getRegistry(null, null).unregisterComponent(oname);
+        }
+
         if (tpOname != null)
             Registry.getRegistry(null, null).unregisterComponent(tpOname);
         if (rgOname != null)

Modified: tomcat/trunk/java/org/apache/coyote/Adapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/Adapter.java?rev=1043531&r1=1043530&r2=1043531&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/Adapter.java (original)
+++ tomcat/trunk/java/org/apache/coyote/Adapter.java Wed Dec  8 17:15:50 2010
@@ -54,4 +54,12 @@ public interface Adapter {
             throws Exception;
 
     public void log(Request req, Response res, long time);
+
+    /**
+     * Provide the name of the domain to use to register MBeans for conponents
+     * associated with the connector.
+     * 
+     * @return  The MBean domain name
+     */
+    public String getDomain();
 }



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


Mime
View raw message