tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r940305 - in /tomcat/trunk/java/org/apache/catalina: LifecycleMBeanRegistration.java core/LocalStrings.properties core/StandardEngine.java core/StandardServer.java core/StandardService.java core/StandardThreadExecutor.java
Date Sun, 02 May 2010 19:10:41 GMT
Author: markt
Date: Sun May  2 19:10:40 2010
New Revision: 940305

URL: http://svn.apache.org/viewvc?rev=940305&view=rev
Log:
Add a setDomain() method to LifecycleMBeanRegistration since not all components (eg Exectutor)
retain a reference to their parent.
Implement this new method where required.
Implement MBean (de)registration for Executors using the new interface.

Modified:
    tomcat/trunk/java/org/apache/catalina/LifecycleMBeanRegistration.java
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
    tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
    tomcat/trunk/java/org/apache/catalina/core/StandardService.java
    tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java

Modified: tomcat/trunk/java/org/apache/catalina/LifecycleMBeanRegistration.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/LifecycleMBeanRegistration.java?rev=940305&r1=940304&r2=940305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/LifecycleMBeanRegistration.java (original)
+++ tomcat/trunk/java/org/apache/catalina/LifecycleMBeanRegistration.java Sun May  2 19:10:40
2010
@@ -43,4 +43,8 @@ public interface LifecycleMBeanRegistrat
      */
     public String getDomain();
 
+    /**
+     * Specify the domain under which this component should be registered.
+     */
+    public void setDomain(String domain);
 }

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=940305&r1=940304&r2=940305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Sun May  2 19:10:40
2010
@@ -197,6 +197,7 @@ standardService.onameFail=MBean name spe
 standardService.register.failed=Error registering Service at domain {0}
 standardService.start.name=Starting service {0}
 standardService.stop.name=Stopping service {0}
+standardThreadExecutor.onameFail=MBean name specified for Thread Executor [{0}] is not valid
 standardWrapper.allocate=Error allocating a servlet instance
 standardWrapper.allocateException=Allocate exception for servlet {0}
 standardWrapper.containerServlet=Loading container servlet {0}

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java?rev=940305&r1=940304&r2=940305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardEngine.java Sun May  2 19:10:40 2010
@@ -367,10 +367,6 @@ public class StandardEngine
     @Override
     protected void destroyInternal() throws LifecycleException {
         
-        // if we created it, make sure it's also destroyed
-        // this call implizit this.stop()
-        ((StandardService)service).destroy();
-
         if( mbeans != null ) {
             try {
                 Registry.getRegistry(null, null)

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardServer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardServer.java?rev=940305&r1=940304&r2=940305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Sun May  2 19:10:40 2010
@@ -768,6 +768,11 @@ public final class StandardServer extend
     }
 
     
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+    
+    
     public ObjectName getObjectName() {
         if (oname == null) {
             StringBuilder name = new StringBuilder(getDomain());

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardService.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardService.java?rev=940305&r1=940304&r2=940305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardService.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardService.java Sun May  2 19:10:40 2010
@@ -521,6 +521,9 @@ public class StandardService extends Lif
 
         // Initialize any Executors
         for (Executor executor : findExecutors()) {
+            if (executor instanceof LifecycleMBeanRegistration) {
+                ((LifecycleMBeanRegistration) executor).setDomain(getDomain());
+            }
             executor.init();
         }
 
@@ -593,6 +596,10 @@ public class StandardService extends Lif
         return domain;
     }
 
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+    
     public ObjectName getObjectName() {
         if (oname == null) {
             StringBuilder name = new StringBuilder(getDomain());

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java?rev=940305&r1=940304&r2=940305&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java Sun May  2 19:10:40
2010
@@ -20,18 +20,35 @@ package org.apache.catalina.core;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.TimeUnit;
 
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
 import org.apache.catalina.Executor;
 import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleMBeanRegistration;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.util.LifecycleBase;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.threads.ResizableExecutor;
 import org.apache.tomcat.util.threads.TaskQueue;
 import org.apache.tomcat.util.threads.TaskThreadFactory;
 import org.apache.tomcat.util.threads.ThreadPoolExecutor;
 
 public class StandardThreadExecutor extends LifecycleBase
-        implements Executor, ResizableExecutor {
+        implements Executor, ResizableExecutor, LifecycleMBeanRegistration {
+    
+    private static final Log log =
+        LogFactory.getLog(StandardThreadExecutor.class);
     
+    /**
+     * The string manager for this package.
+     */
+    private static final StringManager sm =
+        StringManager.getManager(Constants.Package);
+
     // ---------------------------------------------- Properties
     /**
      * Default thread priority
@@ -290,6 +307,58 @@ public class StandardThreadExecutor exte
         return false;
     }
     
+
+    protected volatile String domain;
+    protected volatile ObjectName oname;
+
+    /**
+     * Obtain the MBean domain for this server. The domain is set by the
+     * containing Service.
+     */
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+    
+    public ObjectName getObjectName() {
+        if (oname == null) {
+            StringBuilder name = new StringBuilder(getDomain());
+            name.append(":type=Executor,name=");
+            name.append(getName());
+            
+            try {
+                oname = new ObjectName(name.toString());
+            } catch (MalformedObjectNameException e) {
+                log.warn(sm.getString(
+                        "standardThreadExecutor.onameFail", name), e);
+            } catch (NullPointerException e) {
+                // Never going to happen
+            }
+        }
+        
+        return oname;
+    }
     
+    public ObjectName preRegister(MBeanServer server,
+                                  ObjectName name) throws Exception {
+        oname=name;
+        domain=name.getDomain();
+        return name;
+    }
+
+    public void postRegister(Boolean registrationDone) {
+        // NOOP
+    }
+
+    public void preDeregister() throws Exception {
+        // NOOP
+    }
+
+    public void postDeregister() {
+        // NOOP
+    }
     
 }



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


Mime
View raw message