tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core ContainerBase.java
Date Mon, 10 Apr 2000 18:44:44 GMT
craigmcc    00/04/10 11:44:43

  Modified:    proposals/catalina build.xml
               proposals/catalina/src/share/org/apache/tomcat
                        Container.java Lifecycle.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        ContainerBase.java
  Added:       proposals/catalina/src/share/org/apache/tomcat
                        ContainerListener.java LifecycleEvent.java
                        LifecycleListener.java
  Removed:     proposals/catalina/src/share/org/apache/tomcat
                        ContainerEventListener.java
  Log:
  Add LifecycleEvent events and listeners to the Lifecycle contract.  For
  example, this allows components interested in the startup and shutdown of
  a Context to be notified about "start" and "stop", supporting the same
  functionality as that provided by ContextInterceptors in Tomcat 3.x.
  However, the concept is generalized to apply to all components that
  implement Lifecycle.
  
  Also, add manifest constants for event names, and regularize the class
  name and method signature patterns for container and lifecycle events.
  
  NOTE:  This currently breaks some compiles -- I will fix that in a few
  minutes.
  
  Revision  Changes    Path
  1.4       +8 -4      jakarta-tomcat/proposals/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/build.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- build.xml	2000/02/13 07:09:30	1.3
  +++ build.xml	2000/04/10 18:44:37	1.4
  @@ -1,10 +1,10 @@
   <project name="Tomcat-Next" default="main" basedir=".">
   
     <!-- Initialize property values -->
  +  <property name="ant.home"       value="../../../jakarta-ant"/>
     <property name="build.compiler" value="classic"/>
     <property name="catalina.build" value="../../../build/catalina"/>
     <property name="catalina.home"  value="../../../dist/catalina"/>
  -  <property name="jakarta.tools"  value="../../../jakarta-tools"/>
   
     <!-- Create directories and copy static files -->
     <target name="prepare">
  @@ -15,14 +15,18 @@
       <mkdir dir="${catalina.build}/etc"/>
       <mkdir dir="${catalina.build}/src"/>
       <mkdir dir="${catalina.build}/lib"/>
  -    <copyfile src="${jakarta.tools}/projectx-tr2.jar"
  -             dest="${catalina.build}/lib/xml.jar"/>
  +  </target>
  +
  +  <!-- Copy static files -->
  +  <target name="static" depends="prepare">
  +    <copyfile src="${ant.home}/lib/xml.jar"
  +              dest="${catalina.build}/lib/xml.jar"/>
       <copydir src="src/bin"  dest="${catalina.build}/bin"/>
       <copydir src="src/conf" dest="${catalina.build}/conf"/>
     </target>
   
     <!-- Compile the build directory -->
  -  <target name="main" depends="prepare">
  +  <target name="main" depends="prepare,static">
       <javac srcdir="src/share" destdir="${catalina.build}/classes"
        classpath="${catalina.build}/lib/xml.jar" debug="on"/>
     </target>
  
  
  
  1.5       +37 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Container.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Container.java	2000/01/29 21:01:10	1.4
  +++ Container.java	2000/04/10 18:44:39	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Container.java,v
1.4 2000/01/29 21:01:10 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/01/29 21:01:10 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Container.java,v
1.5 2000/04/10 18:44:39 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/04/10 18:44:39 $
    *
    * ====================================================================
    *
  @@ -119,12 +119,43 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/01/29 21:01:10 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/10 18:44:39 $
    */
   
   public interface Container {
   
   
  +    // ----------------------------------------------------- Manifest Constants
  +
  +
  +    /**
  +     * The ContainerEvent event type sent when a child container is added
  +     * by <code>addChild()</code>.
  +     */
  +    public static final String ADD_CHILD_EVENT = "addChild";
  +
  +
  +    /**
  +     * The ContainerEvent event type sent when a valve is added
  +     * by <code>addValve()</code>, if this Container supports pipelines.
  +     */
  +    public static final String ADD_VALVE_EVENT = "addValve";
  +
  +
  +    /**
  +     * The ContainerEvent event type sent when a child container is removed
  +     * by <code>removeChild()</code>.
  +     */
  +    public static final String REMOVE_CHILD_EVENT = "removeChild";
  +
  +
  +    /**
  +     * The ContainerEvent event type sent when a valve is removed
  +     * by <code>removeValve()</code>, if this Container supports pipelines.
  +     */
  +    public static final String REMOVE_VALVE_EVENT = "removeValve";
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -267,7 +298,7 @@
        *
        * @param listener The listener to add
        */
  -    public void addContainerEventListener(ContainerEventListener listener);
  +    public void addContainerListener(ContainerListener listener);
   
   
       /**
  @@ -344,7 +375,7 @@
        *
        * @param listener The listener to remove
        */
  -    public void removeContainerEventListener(ContainerEventListener listener);
  +    public void removeContainerListener(ContainerListener listener);
   
   
       /**
  
  
  
  1.3       +39 -6     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Lifecycle.java
  
  Index: Lifecycle.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Lifecycle.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Lifecycle.java	2000/01/29 03:47:28	1.2
  +++ Lifecycle.java	2000/04/10 18:44:40	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Lifecycle.java,v
1.2 2000/01/29 03:47:28 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/01/29 03:47:28 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Lifecycle.java,v
1.3 2000/04/10 18:44:40 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/10 18:44:40 $
    *
    * ====================================================================
    *
  @@ -72,20 +72,52 @@
    * provide a consistent mechanism to start and stop the component.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/01/29 03:47:28 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/10 18:44:40 $
    */
   
   public interface Lifecycle {
   
   
  +    // ----------------------------------------------------- Manifest Constants
  +
  +
  +    /**
  +     * The LifecycleEvent type for the "component start" event.
  +     */
  +    public static final String START_EVENT = "start";
  +
  +
  +    /**
  +     * The LifecycleEvent type for the "component stop" event.
  +     */
  +    public static final String STOP_EVENT = "stop";
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
   
       /**
  +     * Add a LifecycleEvent listener to this component.
  +     *
  +     * @param listener The listener to add
  +     */
  +    public void addLifecycleListener(LifecycleListener listener);
  +
  +
  +    /**
  +     * Remove a LifecycleEvent listener from this component.
  +     *
  +     * @param listener The listener to remove
  +     */
  +    public void removeLifecycleListener(LifecycleListener 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.
  +     * methods of this component are utilized.  It should also send a
  +     * LifecycleEvent of type START_EVENT to any registered listeners.
        *
        * @exception IllegalStateException if this component has already been
        *  started
  @@ -98,7 +130,8 @@
       /**
        * 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.
  +     * instance of this component.  It should also send a LifecycleEvent
  +     * of type STOP_EVENT to any registered listeners.
        *
        * @exception IllegalStateException if this component has not been started
        * @exception LifecycleException if this component detects a fatal error
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/ContainerListener.java
  
  Index: ContainerListener.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/ContainerListener.java,v
1.1 2000/04/10 18:44:40 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/10 18:44:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.tomcat;
  
  
  import java.util.EventObject;
  
  
  /**
   * Interface defining a listener for significant Container generated events.
   * Note that "container start" and "container stop" events are normally
   * LifecycleEvents, not ContainerEvents.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/10 18:44:40 $
   */
  
  public interface ContainerListener {
  
  
      /**
       * Acknowledge the occurrence of the specified event.
       *
       * @param event ContainerEvent that has occurred
       */
      public void containerEvent(ContainerEvent event);
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/LifecycleEvent.java
  
  Index: LifecycleEvent.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/LifecycleEvent.java,v
1.1 2000/04/10 18:44:40 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/10 18:44:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.tomcat;
  
  
  import java.util.EventObject;
  
  
  /**
   * General event for notifying listeners of significant changes on a component
   * that implements the Lifecycle interface.  In particular, this will be useful
   * on Containers, where these events replace the ContextInterceptor concept in
   * Tomcat 3.x.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/10 18:44:40 $
   */
  
  public final class LifecycleEvent
      extends EventObject {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a new LifecycleEvent with the specified parameters.
       *
       * @param lifecycle Component on which this event occurred
       * @param type Event type (required)
       */
      public LifecycleEvent(Lifecycle lifecycle, String type) {
  
  	this(lifecycle, type, null);
  
      }
  
  
      /**
       * Construct a new LifecycleEvent with the specified parameters.
       *
       * @param lifecycle Component on which this event occurred
       * @param type Event type (required)
       * @param data Event data (if any)
       */
      public LifecycleEvent(Lifecycle lifecycle, String type, Object data) {
  
  	super(lifecycle);
  	this.lifecycle = lifecycle;
  	this.type = type;
  	this.data = data;
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The event data associated with this event.
       */
      private Object data = null;
  
  
      /**
       * The Lifecycle on which this event occurred.
       */
      private Lifecycle lifecycle = null;
  
  
      /**
       * The event type this instance represents.
       */
      private String type = null;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the event data of this event.
       */
      public Object getData() {
  
  	return (this.data);
  
      }
  
  
      /**
       * Return the Lifecycle on which this event occurred.
       */
      public Lifecycle getLifecycle() {
  
  	return (this.lifecycle);
  
      }
  
  
      /**
       * Return the event type of this event.
       */
      public String getType() {
  
  	return (this.type);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/LifecycleListener.java
  
  Index: LifecycleListener.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/LifecycleListener.java,v
1.1 2000/04/10 18:44:40 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/10 18:44:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:  
   *       "This product includes software developed by the 
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */ 
  
  
  package org.apache.tomcat;
  
  
  import java.util.EventObject;
  
  
  /**
   * Interface defining a listener for significant events (including "component
   * start" and "component stop" generated by a component that implements the
   * Lifecycle interface.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/10 18:44:40 $
   */
  
  public interface LifecycleListener {
  
  
      /**
       * Acknowledge the occurrence of the specified event.
       *
       * @param event LifecycleEvent that has occurred
       */
      public void lifecycleEvent(LifecycleEvent event);
  
  
  }
  
  
  
  1.8       +70 -16    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java
  
  Index: ContainerBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ContainerBase.java	2000/02/13 07:09:30	1.7
  +++ ContainerBase.java	2000/04/10 18:44:41	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.7 2000/02/13 07:09:30 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/02/13 07:09:30 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.8 2000/04/10 18:44:41 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/04/10 18:44:41 $
    *
    * ====================================================================
    *
  @@ -74,9 +74,11 @@
   import javax.servlet.ServletException;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.ContainerEvent;
  -import org.apache.tomcat.ContainerEventListener;
  +import org.apache.tomcat.ContainerListener;
   import org.apache.tomcat.Lifecycle;
  +import org.apache.tomcat.LifecycleEvent;
   import org.apache.tomcat.LifecycleException;
  +import org.apache.tomcat.LifecycleListener;
   import org.apache.tomcat.Loader;
   import org.apache.tomcat.Logger;
   import org.apache.tomcat.Manager;
  @@ -104,7 +106,7 @@
    * This implementation fires property change events, per the JavaBeans design
    * pattern, for changes in singleton properties.  In addition, it fires the
    * following <code>ContainerEvent</code> events to listeners who register
  - * themselves with <code>addContainerEventListener()</code>:
  + * themselves with <code>addContainerListener()</code>:
    * <table border=1>
    *   <tr>
    *     <th>Type</th>
  @@ -146,7 +148,7 @@
    * class comments of the implementation class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/02/13 07:09:30 $
  + * @version $Revision: 1.8 $ $Date: 2000/04/10 18:44:41 $
    */
   
   public abstract class ContainerBase
  @@ -175,6 +177,12 @@
   
   
       /**
  +     * The lifecycle event listeners for this Container.
  +     */
  +    protected Vector lifecycles = new Vector();
  +
  +
  +    /**
        * The container event listeners for this Container.
        */
       protected Vector listeners = new Vector();
  @@ -547,7 +555,7 @@
        *
        * @param listener The listener to add
        */
  -    public void addContainerEventListener(ContainerEventListener listener) {
  +    public void addContainerListener(ContainerListener listener) {
   
   	listeners.addElement(listener);
   
  @@ -592,7 +600,7 @@
   						   "' is not unique");
   	    child.setParent((Container) this);	// May throw IAE
   	    children.put(child.getName(), child);
  -	    fireContainerEvent("addChild", child);
  +	    fireContainerEvent(ADD_CHILD_EVENT, child);
   	}
   
       }
  @@ -671,7 +679,7 @@
   		return;
   	    children.remove(child.getName());
   	    child.setParent(null);
  -	    fireContainerEvent("removeChild", child);
  +	    fireContainerEvent(REMOVE_CHILD_EVENT, child);
   	}
   
       }
  @@ -682,7 +690,7 @@
        *
        * @param listener The listener to remove
        */
  -    public void removeContainerEventListener(ContainerEventListener listener) {
  +    public void removeContainerListener(ContainerListener listener) {
   
   	listeners.removeElement(listener);
   
  @@ -705,6 +713,30 @@
   
   
       /**
  +     * Add a lifecycle event listener to this component.
  +     *
  +     * @param listener The listener to add
  +     */
  +    public void addLifecycleListener(LifecycleListener listener) {
  +
  +	lifecycles.addElement(listener);
  +
  +    }
  +
  +
  +    /**
  +     * Remove a lifecycle event listener from this component.
  +     *
  +     * @param listener The listener to remove
  +     */
  +    public void removeLifecycleListener(LifecycleListener listener) {
  +
  +	listeners.removeElement(listener);
  +
  +    }
  +
  +
  +    /**
        * Prepare for active use of the public methods of this Component.
        *
        * @exception IllegalStateException if this component has already been
  @@ -719,7 +751,7 @@
   	    throw new LifecycleException
   		(sm.getString("containerBase.alreadyStarted"));
   	started = true;
  -	fireContainerEvent("start", null);
  +	fireLifecycleEvent(START_EVENT, null);
   
   	// Start our subordinate components, if any
   	if ((loader != null) && (loader instanceof Lifecycle))
  @@ -758,7 +790,7 @@
   	    throw new LifecycleException
   		(sm.getString("containerBase.notStarted"));
   	started = false;
  -	fireContainerEvent("stop", null);
  +	fireLifecycleEvent(STOP_EVENT, null);
   
   	// Stop the Valves in our pipeline (including the basic), if any
   	Valve current = basic;
  @@ -835,7 +867,7 @@
   	    }
   	}
   
  -	fireContainerEvent("addValve", valve);
  +	fireContainerEvent(ADD_VALVE_EVENT, valve);
   
       }
   
  @@ -883,7 +915,7 @@
   		if (next != null)
   		    next.setPrevious(previous);
   	    }
  -	    fireContainerEvent("removeValve", valve);
  +	    fireContainerEvent(REMOVE_VALVE_EVENT, valve);
   	    break;
   	}
   
  @@ -895,7 +927,8 @@
   
       /**
        * Notify all container event listeners that a particular event has
  -     * occurred for this Container.
  +     * occurred for this Container.  The default implementation performs
  +     * this notification synchronously using the calling thread.
        *
        * @param type Event type
        * @param data Event data
  @@ -907,8 +940,29 @@
   	synchronized (this) {
   	    list = (Vector) listeners.clone();
   	}
  +	for (int i = 0; i < list.size(); i++)
  +	    ((ContainerListener) list.elementAt(i)).containerEvent(event);
  +
  +    }
  +
  +
  +    /**
  +     * Notify all lifecycle event listeners that a particular event has
  +     * occurred for this Container.  The default implementation performs
  +     * this notification synchronously using the calling thread.
  +     *
  +     * @param type Event type
  +     * @param data Event data
  +     */
  +    protected void fireLifecycleEvent(String type, Object data) {
  +
  +	LifecycleEvent event = new LifecycleEvent(this, type, data);
  +	Vector list = null;
  +	synchronized (this) {
  +	    list = (Vector) listeners.clone();
  +	}
   	for (int i = 0; i < list.size(); i++)
  -	    ((ContainerEventListener) list.elementAt(i)).eventOccurred(event);
  +	    ((LifecycleListener) list.elementAt(i)).lifecycleEvent(event);
   
       }
   
  
  
  

Mime
View raw message