You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/03/04 19:47:17 UTC

svn commit: r919121 - in /tomcat/trunk/java/org/apache/catalina/core: LocalStrings.properties LocalStrings_es.properties LocalStrings_fr.properties LocalStrings_ja.properties StandardServer.java

Author: markt
Date: Thu Mar  4 18:47:17 2010
New Revision: 919121

URL: http://svn.apache.org/viewvc?rev=919121&view=rev
Log:
Lifecycle refactoring
StandardServer - relatively straight forward

Modified:
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings_fr.properties
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings_ja.properties
    tomcat/trunk/java/org/apache/catalina/core/StandardServer.java

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=919121&r1=919120&r2=919121&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Thu Mar  4 18:47:17 2010
@@ -189,12 +189,8 @@
 standardPipeline.alreadyStarted=Pipeline has already been started
 standardPipeline.notStarted=Pipeline has not been started
 standardPipeline.noValve=No more Valves in the Pipeline processing this request
-standardServer.addContainer.ise=No connectors available to associate this container with
 standardServer.initialize.initialized=This server has already been initialized
 standardServer.shutdownViaPort=A valid shutdown command was received via the shutdown port. Stopping the Server instance.
-standardServer.start.connectors=At least one connector is not associated with any container
-standardServer.start.started=This server has already been started
-standardServer.stop.notStarted=This server has not yet been started
 standardService.initialize.initialized=This service has already been initialized
 standardService.initialize.failed=Service initializing at {0} failed
 standardService.register.failed=Error registering Service at domain {0}

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties?rev=919121&r1=919120&r2=919121&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings_es.properties Thu Mar  4 18:47:17 2010
@@ -165,11 +165,7 @@
 standardPipeline.alreadyStarted = Ya se ha arrancado la Tuber\u00EDa (Pipeline)
 standardPipeline.notStarted = No se ha arrancado la Tuber\u00EDa (Pipeline)
 standardPipeline.noValve = No hay m\u00E1s V\u00E1lvulas en la Tuber\u00EDa (Pipeline) procesando este requerimiento
-standardServer.addContainer.ise = No hay conectores disponibles para ser asociados con este contenedor
 standardServer.initialize.initialized = Ya se ha inicializado este servidor
-standardServer.start.connectors = Al menos un conector no est\u00E1 asociado con cualquier contenedor
-standardServer.start.started = Ya ha sido arrancado este servidor
-standardServer.stop.notStarted = A\u00FAn no ha sido arrancado este servidor
 standardService.initialize.initialized = Ya ha sido inicializado este servicio
 standardService.initialize.failed = Servicio inicializando en {0} fall\u00F3
 standardService.register.failed = Error registrando servicio en dominio {0}

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings_fr.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings_fr.properties?rev=919121&r1=919120&r2=919121&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings_fr.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings_fr.properties Thu Mar  4 18:47:17 2010
@@ -138,11 +138,7 @@
 standardPipeline.alreadyStarted=Le "Pipeline" a d\u00e9j\u00e0 \u00e9t\u00e9 d\u00e9marr\u00e9
 standardPipeline.notStarted=le "Pipeline" n''a pas \u00e9t\u00e9 d\u00e9marr\u00e9
 standardPipeline.noValve=Plus aucune Valve dans le "Pipeline" traitant cette requ\u00eate
-standardServer.addContainer.ise=Aucun connecteur n''est disponible pour associer avec ce conteneur (container)
 standardServer.initialize.initialized=Ce serveur a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9
-standardServer.start.connectors=Au moins un connecteur n''est associ\u00e9 \u00e0 aucun conteneur (container)
-standardServer.start.started=Ce serveur a d\u00e9j\u00e0 \u00e9t\u00e9 d\u00e9marr\u00e9
-standardServer.stop.notStarted=Ce serveur n''a pas encore \u00e9t\u00e9 d\u00e9marr\u00e9
 standardService.initialize.initialized=Ce service a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9
 standardService.start.name=D\u00e9marrage du service {0}
 standardService.start.started=Ce service a d\u00e9j\u00e0 \u00e9t\u00e9 d\u00e9marr\u00e9

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings_ja.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings_ja.properties?rev=919121&r1=919120&r2=919121&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings_ja.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings_ja.properties Thu Mar  4 18:47:17 2010
@@ -145,11 +145,7 @@
 standardPipeline.alreadyStarted=\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306f\u65e2\u306b\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u3059
 standardPipeline.notStarted=\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u306f\u307e\u3060\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u305b\u3093
 standardPipeline.noValve=\u3053\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3059\u308b\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u4e2d\u306b\u3053\u308c\u4ee5\u4e0a\u306e\u30d0\u30eb\u30d6\u306f\u3042\u308a\u307e\u305b\u3093
-standardServer.addContainer.ise=\u3053\u306e\u30b3\u30f3\u30c6\u30ca\u3092\u95a2\u9023\u3065\u3051\u308b\u305f\u3081\u306e\u30b3\u30cd\u30af\u30bf\u304c\u5229\u7528\u3067\u304d\u307e\u305b\u3093
 standardServer.initialize.initialized=\u3053\u306e\u30b5\u30fc\u30d0\u306f\u65e2\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u307e\u3059
-standardServer.start.connectors=\u30b3\u30f3\u30c6\u30ca\u306b\u4e00\u3064\u3082\u30b3\u30cd\u30af\u30bf\u304c\u95a2\u9023\u3065\u3051\u3089\u308c\u3066\u3044\u307e\u305b\u3093
-standardServer.start.started=\u3053\u306e\u30b5\u30fc\u30d0\u306f\u65e2\u306b\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u3059
-standardServer.stop.notStarted=\u3053\u306e\u30b5\u30fc\u30d0\u306f\u307e\u3060\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u305b\u3093
 standardService.initialize.initialized=\u3053\u306e\u30b5\u30fc\u30d3\u30b9\u306f\u65e2\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u307e\u3059
 standardService.start.name=\u30b5\u30fc\u30d3\u30b9 {0} \u3092\u8d77\u52d5\u3057\u307e\u3059
 standardService.start.started=\u3053\u306e\u30b5\u30fc\u30d3\u30b9\u306f\u65e2\u306b\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u3059

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=919121&r1=919120&r2=919121&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Thu Mar  4 18:47:17 2010
@@ -35,11 +35,11 @@
 
 import org.apache.catalina.Context;
 import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Server;
 import org.apache.catalina.Service;
 import org.apache.catalina.deploy.NamingResources;
-import org.apache.catalina.util.LifecycleSupport;
+import org.apache.catalina.util.LifecycleBase;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.catalina.util.ServerInfo;
 import org.apache.juli.logging.Log;
@@ -56,7 +56,8 @@
  * @author Craig R. McClanahan
  * @version $Revision$ $Date$
  */
-public final class StandardServer implements Server, MBeanRegistration {
+public final class StandardServer extends LifecycleBase
+        implements Server, MBeanRegistration {
 
     private static final Log log = LogFactory.getLog(StandardServer.class);
    
@@ -107,12 +108,6 @@
 
 
     /**
-     * The lifecycle event support for this component.
-     */
-    private LifecycleSupport lifecycle = new LifecycleSupport(this);
-
-
-    /**
      * The naming context listener for this web application.
      */
     private NamingContextListener namingContextListener = null;
@@ -156,12 +151,6 @@
 
 
     /**
-     * Has this component been started?
-     */
-    private boolean started = false;
-
-
-    /**
      * Has this component been initialized?
      */
     private boolean initialized = false;
@@ -340,7 +329,7 @@
                 }
             }
 
-            if (started) {
+            if (getState().isAvailable()) {
                 try {
                     service.start();
                 } catch (LifecycleException e) {
@@ -655,66 +644,16 @@
     }
 
 
-    // ------------------------------------------------------ Lifecycle Methods
-
-
     /**
-     * Add a LifecycleEvent listener to this component.
-     *
-     * @param listener The listener to add
-     */
-    public void addLifecycleListener(LifecycleListener listener) {
-
-        lifecycle.addLifecycleListener(listener);
-
-    }
-
-
-    /**
-     * Get the lifecycle listeners associated with this lifecycle. If this
-     * Lifecycle has no listeners registered, a zero-length array is returned.
-     */
-    public LifecycleListener[] findLifecycleListeners() {
-
-        return lifecycle.findLifecycleListeners();
-
-    }
-
-
-    /**
-     * Remove a LifecycleEvent listener from this component.
-     *
-     * @param listener The listener to remove
-     */
-    public void removeLifecycleListener(LifecycleListener listener) {
-
-        lifecycle.removeLifecycleListener(listener);
-
-    }
-
-
-    /**
-     * Prepare for the beginning of active use of the public methods of this
-     * component.  This method should be called before any of the public
-     * methods of this component are utilized.  It should also send a
-     * LifecycleEvent of type START_EVENT to any registered listeners.
+     * Start nested components ({@link Service}s) and implement the requirements
+     * of {@link LifecycleBase#startInternal()}.
      *
      * @exception LifecycleException if this component detects a fatal error
      *  that prevents this component from being used
      */
-    public void start() throws LifecycleException {
-
-        // Validate and update our current component state
-        if (started) {
-            log.debug(sm.getString("standardServer.start.started"));
-            return;
-        }
-
-        // Notify our interested LifecycleListeners
-        lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
+    protected void startInternal() throws LifecycleException {
 
-        lifecycle.fireLifecycleEvent(START_EVENT, null);
-        started = true;
+        setState(LifecycleState.STARTING);
 
         // Start our defined Services
         synchronized (services) {
@@ -722,42 +661,25 @@
                 services[i].start();
             }
         }
-
-        // Notify our interested LifecycleListeners
-        lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
-
     }
 
 
     /**
-     * Gracefully terminate the active use of the public methods of this
-     * component.  This method should be the last one called on a given
-     * instance of this component.  It should also send a LifecycleEvent
-     * of type STOP_EVENT to any registered listeners.
+     * Stop nested components ({@link Service}s) and implement the requirements
+     * of {@link LifecycleBase#stopInternal()}.
      *
      * @exception LifecycleException if this component detects a fatal error
      *  that needs to be reported
      */
-    public void stop() throws LifecycleException {
-
-        // Validate and update our current component state
-        if (!started)
-            return;
+    protected void stopInternal() throws LifecycleException {
 
-        // Notify our interested LifecycleListeners
-        lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
-
-        lifecycle.fireLifecycleEvent(STOP_EVENT, null);
-        started = false;
+        setState(LifecycleState.STOPPING);
 
         // Stop our defined Services
         for (int i = 0; i < services.length; i++) {
             services[i].stop();
         }
 
-        // Notify our interested LifecycleListeners
-        lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
-
         if (port == -1)
             stopAwait();
 
@@ -778,7 +700,7 @@
                 log.info(sm.getString("standardServer.initialize.initialized"));
             return;
         }
-        lifecycle.fireLifecycleEvent(INIT_EVENT, null);
+        fireLifecycleEvent(INIT_EVENT, null);
         initialized = true;
 
         if( oname==null ) {



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