Author: markt Date: Thu Mar 4 21:18:03 2010 New Revision: 919187 URL: http://svn.apache.org/viewvc?rev=919187&view=rev Log: Lifecycle refactoring StandardPipeline (and turn Eclipse compilation warnings up to 11)
Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java 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/StandardPipeline.java tomcat/trunk/java/org/apache/catalina/core/StandardServer.java tomcat/trunk/java/org/apache/catalina/core/StandardService.java Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=919187&r1=919186&r2=919187&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original) +++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Thu Mar 4 21:18:03 2010 @@ -26,7 +26,6 @@ import javax.management.ObjectName; import org.apache.catalina.Container; -import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleException; import org.apache.catalina.LifecycleState; import org.apache.catalina.Service; @@ -51,8 +50,7 @@ */ -public class Connector extends LifecycleBase - implements Lifecycle, MBeanRegistration { +public class Connector extends LifecycleBase implements MBeanRegistration { private static final Log log = LogFactory.getLog(Connector.class); @@ -967,6 +965,7 @@ * * @exception LifecycleException if a fatal startup error occurs */ + @Override protected void startInternal() throws LifecycleException { if( !initialized ) initialize(); @@ -1027,6 +1026,7 @@ * * @exception LifecycleException if a fatal shutdown error occurs */ + @Override protected void stopInternal() throws LifecycleException { setState(LifecycleState.STOPPING); 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=919187&r1=919186&r2=919187&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Thu Mar 4 21:18:03 2010 @@ -186,9 +186,6 @@ standardHost.warURL=Invalid URL for web application archive: {0} standardHost.validationEnabled=XML validation enabled standardHost.validationDisabled=XML validation disabled -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.initialize.initialized=This server has already been initialized standardServer.shutdownViaPort=A valid shutdown command was received via the shutdown port. Stopping the Server instance. standardService.initialize.initialized=This service has already been initialized 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=919187&r1=919186&r2=919187&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 21:18:03 2010 @@ -162,9 +162,6 @@ standardHost.warURL = URL inv\u00E1lida para archivo de aplicaci\u00F3n web\: {0} standardHost.validationEnabled = Activada la validaci\u00F3n XML standardHost.validationDisabled = Desactivada la validaci\u00F3n XML -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.initialize.initialized = Ya se ha inicializado este servidor standardService.initialize.initialized = Ya ha sido inicializado este servicio standardService.initialize.failed = Servicio inicializando en {0} fall\u00F3 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=919187&r1=919186&r2=919187&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 21:18:03 2010 @@ -135,9 +135,6 @@ standardHost.unfoundContext=Impossible de trouver un contexte pour l''URI {0} demand\u00e9e standardHost.warRequired=Une URL vers l''archive d''application web (war) est n\u00e9cessaire standardHost.warURL=URL vers l''archive d''application web (war) invalide: {0} -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.initialize.initialized=Ce serveur a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9 standardService.initialize.initialized=Ce service a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9 standardService.start.name=D\u00e9marrage du service {0} 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=919187&r1=919186&r2=919187&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 21:18:03 2010 @@ -142,9 +142,6 @@ standardHost.warURL=Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30a2\u30fc\u30ab\u30a4\u30d6\u306b\u5bfe\u3059\u308b\u7121\u52b9\u306aURL\u3067\u3059: {0} standardHost.validationEnabled=XML\u691c\u8a3c\u306f\u6709\u52b9\u3067\u3059 standardHost.validationDisabled=XML\u691c\u8a3c\u306f\u7121\u52b9\u3067\u3059 -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.initialize.initialized=\u3053\u306e\u30b5\u30fc\u30d0\u306f\u65e2\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u307e\u3059 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 Modified: tomcat/trunk/java/org/apache/catalina/core/StandardPipeline.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardPipeline.java?rev=919187&r1=919186&r2=919187&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardPipeline.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardPipeline.java Thu Mar 4 21:18:03 2010 @@ -27,11 +27,10 @@ import org.apache.catalina.Container; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleException; -import org.apache.catalina.LifecycleListener; +import org.apache.catalina.LifecycleState; import org.apache.catalina.Pipeline; import org.apache.catalina.Valve; -import org.apache.catalina.util.LifecycleSupport; -import org.apache.tomcat.util.res.StringManager; +import org.apache.catalina.util.LifecycleBase; import org.apache.catalina.valves.ValveBase; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -51,9 +50,8 @@ * @author Craig R. McClanahan */ -public class StandardPipeline - implements Pipeline, Contained, Lifecycle - { +public class StandardPipeline extends LifecycleBase + implements Pipeline, Contained { private static final Log log = LogFactory.getLog(StandardPipeline.class); @@ -106,25 +104,6 @@ /** - * The lifecycle event support for this component. - */ - protected LifecycleSupport lifecycle = new LifecycleSupport(this); - - - /** - * The string manager for this package. - */ - protected static final StringManager sm = - StringManager.getManager(Constants.Package); - - - /** - * Has this component been started yet? - */ - protected boolean started = false; - - - /** * The first valve associated with this Pipeline. */ protected Valve first = null; @@ -177,60 +156,15 @@ } - // ------------------------------------------------------ Lifecycle Methods - - - /** - * Add a lifecycle event 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 lifecycle event listener from this component. - * - * @param listener The listener to remove - */ - public void removeLifecycleListener(LifecycleListener listener) { - - lifecycle.removeLifecycleListener(listener); - - } - - /** - * Prepare for active use of the public methods of this Component. + * Start {...@link Valve}s) in this pipeline and implement the requirements + * of {...@link LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error - * that prevents it from being started + * that prevents this component from being used */ - public synchronized void start() throws LifecycleException { - - // Validate and update our current component state - if (started) - throw new LifecycleException - (sm.getString("standardPipeline.alreadyStarted")); - - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null); - - started = true; + @Override + protected synchronized void startInternal() throws LifecycleException { // Start the Valves in our pipeline (including the basic), if any Valve current = first; @@ -244,34 +178,21 @@ current = current.getNext(); } - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(START_EVENT, null); - - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null); - + setState(LifecycleState.STARTING); } /** - * Gracefully shut down active use of the public methods of this Component. + * Stop {...@link Valve}s) in this pipeline and implement the requirements + * of {...@link LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error - * that needs to be reported + * that prevents this component from being used */ - public synchronized void stop() throws LifecycleException { + @Override + protected synchronized void stopInternal() throws LifecycleException { - // Validate and update our current component state - if (!started) - throw new LifecycleException - (sm.getString("standardPipeline.notStarted")); - - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null); - - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(STOP_EVENT, null); - started = false; + setState(LifecycleState.STOPPING); // Stop the Valves in our pipeline (including the basic), if any Valve current = first; @@ -284,11 +205,21 @@ unregisterValve(current); current = current.getNext(); } - - // Notify our interested LifecycleListeners - lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null); } + + /** + * Return a String representation of this component. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("Pipeline["); + sb.append(container); + sb.append(']'); + return sb.toString(); + } + + private void registerValve(Valve valve) { if( valve instanceof ValveBase && @@ -373,7 +304,7 @@ // Stop the old component if necessary if (oldBasic != null) { - if (started && (oldBasic instanceof Lifecycle)) { + if (getState().isAvailable() && (oldBasic instanceof Lifecycle)) { try { ((Lifecycle) oldBasic).stop(); } catch (LifecycleException e) { @@ -445,7 +376,7 @@ ((Contained) valve).setContainer(this.container); // Start the new component if necessary - if (started) { + if (getState().isAvailable()) { if (valve instanceof Lifecycle) { try { ((Lifecycle) valve).start(); @@ -547,7 +478,7 @@ ((Contained) valve).setContainer(null); // Stop this valve if necessary - if (started) { + if (getState().isAvailable()) { if (valve instanceof Lifecycle) { try { ((Lifecycle) valve).stop(); 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=919187&r1=919186&r2=919187&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardServer.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardServer.java Thu Mar 4 21:18:03 2010 @@ -651,6 +651,7 @@ * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ + @Override protected void startInternal() throws LifecycleException { setState(LifecycleState.STARTING); @@ -671,6 +672,7 @@ * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ + @Override protected void stopInternal() throws LifecycleException { setState(LifecycleState.STOPPING); 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=919187&r1=919186&r2=919187&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardService.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardService.java Thu Mar 4 21:18:03 2010 @@ -440,6 +440,7 @@ * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ + @Override protected void startInternal() throws LifecycleException { if( ! initialized ) @@ -479,6 +480,7 @@ * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ + @Override protected void stopInternal() throws LifecycleException { // Stop our defined Connectors first --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org