Author: markt
Date: Mon Mar  8 12:39:57 2010
New Revision: 920297

URL: http://svn.apache.org/viewvc?rev=920297&view=rev
Log:
Handle component failure without throwing a whole stack of exceptions
Adds a new permitted transition from NEW to STOPPED that does not fire any 
events

Modified:
    tomcat/trunk/java/org/apache/catalina/Lifecycle.java
    tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java

Modified: tomcat/trunk/java/org/apache/catalina/Lifecycle.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Lifecycle.java?rev=920297&r1=920296&r2=920297&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Lifecycle.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Lifecycle.java Mon Mar  8 12:39:57 
2010
@@ -27,23 +27,25 @@
  * <br>
  * The valid state transitions for components that support Lifecycle are:
  * <pre>
- *                  --------------------<--------------------------
- *                  |                                             |
- *     start()      |        auto          auto         stop()    |       
- * NEW --->--- STARTING_PREP -->- STARTING -->- STARTED -->---    |
- *                                                 |         |    |
- *                                     auto        |         |    |
- *      ---------<----- MUST_STOP --<---------------         |    |
- *      |                                                    |    |
- *      ---------------------------<--------------------------    ^
- *      |                                                         |
- *      |        auto          auto                start()        |
- * STOPPING_PREP -->- STOPPING -->- STOPPED -------------->--------
- *      ^
- *      |stop()
- *      |
- *   FAILED
- * 
+ *                            --------------------<--------------------------
+ *                            |                                             |
+ *               start()      |        auto          auto         stop()    |  
     
+ * NEW ------------->--- STARTING_PREP -->- STARTING -->- STARTED -->---    |
+ *  |                                                        |         |    |
+ *  |                                            auto        |         |    |
+ *  |stop()       ---------<----- MUST_STOP --<---------------         |    |
+ *  |             |                                                    |    |
+ *  |             ---------------------------<--------------------------    ^
+ *  |             |                                                         |
+ *  |             |        auto          auto                start()        |
+ *  |        STOPPING_PREP -->- STOPPING -->- STOPPED -------------->--------
+ *  |             ^                              ^
+ *  |             |stop()                        |
+ *  |             |                              |
+ *  |          FAILED                            |
+ *  |                                            |
+ *  --->------------------------------>-----------
+ *   
  * Any state can transition to FAILED.
  * 
  * Calling start() while a component is in states STARTING_PREP, STARTING or
@@ -52,6 +54,11 @@
  * Calling stop() while a component is in states STOPPING_PREP, STOPPING or
  * STOPPED has no effect.
  * 
+ * Calling stop() while a component is in state NEW transitions the component
+ * to STOPPED. This is typically encountered when a component fails to start 
and
+ * does not start all its sub-components. When the component is stopped, it 
will
+ * try to stop all sub-components - even those it didn't start.
+ * 
  * MUST_STOP is used to indicate that the {...@link #stop()} should be called 
on
  * the component as soon as {...@link start()} exits.
  * 

Modified: tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java?rev=920297&r1=920296&r2=920297&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java Mon Mar  8 
12:39:57 2010
@@ -185,6 +185,11 @@
                 return;
             }
             
+            if (state.equals(LifecycleState.NEW)) {
+                state = LifecycleState.STOPPED;
+                return;
+            }
+
             if (!state.equals(LifecycleState.STARTED) &&
                     !state.equals(LifecycleState.FAILED)) {
                 invalidTransition(Lifecycle.BEFORE_STOP_EVENT);



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

Reply via email to