tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r966735 - in /tomcat/trunk/java/org/apache/catalina: ./ core/ startup/ util/
Date Thu, 22 Jul 2010 16:32:12 GMT
Author: markt
Date: Thu Jul 22 16:32:11 2010
New Revision: 966735

URL: http://svn.apache.org/viewvc?rev=966735&view=rev
Log:
Extend Lifecycle state machine so global listeners can start before everything else without
impacting the context and TLD config listeners

Modified:
    tomcat/trunk/java/org/apache/catalina/Lifecycle.java
    tomcat/trunk/java/org/apache/catalina/LifecycleState.java
    tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java
    tomcat/trunk/java/org/apache/catalina/core/JasperListener.java
    tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/trunk/java/org/apache/catalina/startup/TldConfig.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=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Lifecycle.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Lifecycle.java Thu Jul 22 16:32:11 2010
@@ -27,10 +27,12 @@ package org.apache.catalina;
  * <br>
  * The valid state transitions for components that support Lifecycle are:
  * <pre>
- *                                  --------------------<-----------------------
- *                                  |                                          |
- *    init()           start()      |        auto          auto         stop() |
- * NEW ->-- INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->---
 |
+ *    init()
+ * NEW ->-- INITIALIZING
+ * |||           |                  --------------------<-----------------------
+ * |||           |auto              |                                          |
+ * |||           |     start()      |        auto          auto         stop() |
+ * |||      INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->---
 |
  * |||                              ^                             |         |  |
  * |||        start()               |                             |         |  |
  * ||----------->--------------------                             |         |  |
@@ -99,9 +101,15 @@ public interface Lifecycle {
 
 
     /**
-     * The LifecycleEvent type for the "component init" event.
+     * The LifecycleEvent type for the "component after init" event.
      */
-    public static final String INIT_EVENT = "init";
+    public static final String BEFORE_INIT_EVENT = "before_init";
+
+
+    /**
+     * The LifecycleEvent type for the "component after init" event.
+     */
+    public static final String AFTER_INIT_EVENT = "after_init";
 
 
     /**

Modified: tomcat/trunk/java/org/apache/catalina/LifecycleState.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/LifecycleState.java?rev=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/LifecycleState.java (original)
+++ tomcat/trunk/java/org/apache/catalina/LifecycleState.java Thu Jul 22 16:32:11 2010
@@ -23,7 +23,8 @@ package org.apache.catalina;
  */
 public enum LifecycleState {
     NEW(false, null),
-    INITIALIZED(false, Lifecycle.INIT_EVENT),
+    INITIALIZING(false, Lifecycle.BEFORE_INIT_EVENT),
+    INITIALIZED(false, Lifecycle.AFTER_INIT_EVENT),
     STARTING_PREP(false, Lifecycle.BEFORE_START_EVENT),
     STARTING(true, Lifecycle.START_EVENT),
     STARTED(true, Lifecycle.AFTER_START_EVENT),

Modified: tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java?rev=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java Thu Jul 22 16:32:11
2010
@@ -97,7 +97,7 @@ public class AprLifecycleListener
      */
     public void lifecycleEvent(LifecycleEvent event) {
 
-        if (Lifecycle.INIT_EVENT.equals(event.getType())) {
+        if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
             synchronized (lock) {
                 init();
                 if (aprAvailable) {

Modified: tomcat/trunk/java/org/apache/catalina/core/JasperListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JasperListener.java?rev=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/JasperListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/JasperListener.java Thu Jul 22 16:32:11 2010
@@ -57,7 +57,7 @@ public class JasperListener
      */
     public void lifecycleEvent(LifecycleEvent event) {
 
-        if (Lifecycle.INIT_EVENT.equals(event.getType())) {
+        if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
             try {
                 // Set JSP factory
                 Class.forName("org.apache.jasper.compiler.JspRuntimeContext",

Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Thu Jul
22 16:32:11 2010
@@ -136,7 +136,7 @@ public class JreMemoryLeakPreventionList
     @Override
     public void lifecycleEvent(LifecycleEvent event) {
         // Initialise these classes when Tomcat starts
-        if (Lifecycle.INIT_EVENT.equals(event.getType())) {
+        if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
             /*
              * Several components end up calling:
              * sun.awt.AppContext.getAppContext()

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Thu Jul 22 16:32:11 2010
@@ -327,7 +327,7 @@ public class ContextConfig
                 originalDocBase = docBase;
             }
             configureStop();
-        } else if (event.getType().equals(Lifecycle.INIT_EVENT)) {
+        } else if (event.getType().equals(Lifecycle.AFTER_INIT_EVENT)) {
             init();
         } else if (event.getType().equals(Lifecycle.DESTROY_EVENT)) {
             destroy();

Modified: tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java Thu Jul 22 16:32:11 2010
@@ -577,7 +577,7 @@ public final class TldConfig  implements
             return;
         }
         
-        if (event.getType().equals(Lifecycle.INIT_EVENT)) {
+        if (event.getType().equals(Lifecycle.AFTER_INIT_EVENT)) {
             init();
         } else if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
             try {

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=966735&r1=966734&r2=966735&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/LifecycleBase.java Thu Jul 22 16:32:11 2010
@@ -92,11 +92,12 @@ public abstract class LifecycleBase impl
     
     public synchronized final void init() throws LifecycleException {
         if (!state.equals(LifecycleState.NEW)) {
-            invalidTransition(Lifecycle.INIT_EVENT);
+            invalidTransition(Lifecycle.BEFORE_INIT_EVENT);
         }
+        setState(LifecycleState.INITIALIZING);
 
         initInternal();
-        
+
         setState(LifecycleState.INITIALIZED);
     }
     



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


Mime
View raw message