Author: markt Date: Wed Sep 22 13:48:58 2010 New Revision: 999945 URL: http://svn.apache.org/viewvc?rev=999945&view=rev Log: Provide better web application state information via JMX. A limited back-port of http://svn.apache.org/viewvc?rev=992245&view=rev that could be extended to other components that use LifecycleSupport and expose an MBean.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/LifecycleSupport.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=999945&r1=999944&r2=999945&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Sep 22 13:48:58 2010 @@ -162,15 +162,6 @@ PATCHES PROPOSED TO BACKPORT: -1: rjung: s/vesion/version/g -* Provide better web application state information via JMX - A limited back-port of http://svn.apache.org/viewvc?rev=992245&view=rev that - could be extended to other components that use LifecycleSupport and expose - an MBean - http://people.apache.org/~markt/patches/2010-09-03-better-state-info.patch - +1: markt, kfujino, kkolinko - -1: - kkolinko: s/Tomact/Tomcat/ - * Fix unlockAccept when the soTimeout is -1 (default). Default conf has soTimeout -1 and that will throw exception if used in setSoTimeout method. Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java?rev=999945&r1=999944&r2=999945&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java Wed Sep 22 13:48:58 2010 @@ -5882,6 +5882,10 @@ public class StandardContext return 3; // STOPPED } + public String getStateName() { + return lifecycle.getState(); + } + /** * The J2EE Server ObjectName this module is deployed on. */ Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml?rev=999945&r1=999944&r2=999945&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml Wed Sep 22 13:48:58 2010 @@ -234,6 +234,10 @@ <attribute name="state" description="Current state of this component" type="int"/> + + <attribute name="stateName" + description="The name of the LifecycleState that this component is currently in" + type="java.lang.String"/> <attribute name="stateManageable" description="State management support for this managed object" Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/LifecycleSupport.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/LifecycleSupport.java?rev=999945&r1=999944&r2=999945&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/LifecycleSupport.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/LifecycleSupport.java Wed Sep 22 13:48:58 2010 @@ -69,7 +69,13 @@ public final class LifecycleSupport { private final Object listenersLock = new Object(); // Lock object for changes to listeners - + /** + * Tracks the current state of lifecycle object based on the events that + * are fired. As far as possible, matches the state names used in Tomcat 7 + * for consistency. + */ + private String state = "NEW"; + // --------------------------------------------------------- Public Methods @@ -113,6 +119,23 @@ public final class LifecycleSupport { */ public void fireLifecycleEvent(String type, Object data) { + if (Lifecycle.INIT_EVENT.equals(type)) { + state = "INITIALIZED"; + } else if (Lifecycle.BEFORE_START_EVENT.equals(type)) { + state = "STARTING_PREP"; + } else if (Lifecycle.START_EVENT.equals(type)) { + state = "STARTING"; + } else if (Lifecycle.AFTER_START_EVENT.equals(type)) { + state = "STARTED"; + } else if (Lifecycle.BEFORE_STOP_EVENT.equals(type)) { + state = "STOPPING_PREP"; + } else if (Lifecycle.STOP_EVENT.equals(type)) { + state = "STOPPING"; + } else if (Lifecycle.AFTER_STOP_EVENT.equals(type)) { + state = "STOPPED"; + } else if (Lifecycle.DESTROY_EVENT.equals(type)) { + state = "DESTROYED"; + } LifecycleEvent event = new LifecycleEvent(lifecycle, type, data); LifecycleListener interested[] = listeners; for (int i = 0; i < interested.length; i++) @@ -150,5 +173,7 @@ public final class LifecycleSupport { } - + public String getState() { + return state; + } } Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=999945&r1=999944&r2=999945&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Sep 22 13:48:58 2010 @@ -71,6 +71,9 @@ <fix> <bug>49749</bug>: Use httpOnly setting when creating SSO cookie. (markt) </fix> + <add> + Provide better web application state information via JMX. (markt) + </add> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org