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/startup Catalina.java ContextConfig.java LocalStrings.properties
Date Wed, 26 Apr 2000 01:04:01 GMT
craigmcc    00/04/25 18:04:01

  Modified:    proposals/catalina build.xml
               proposals/catalina/src/conf server.xml
               proposals/catalina/src/share/org/apache/tomcat
                        Resources.java
               proposals/catalina/src/share/org/apache/tomcat/core
                        ContainerBase.java LocalStrings.properties
                        StandardServer.java
               proposals/catalina/src/share/org/apache/tomcat/startup
                        Catalina.java ContextConfig.java
                        LocalStrings.properties
  Added:       proposals/catalina/src/share/org/apache/tomcat/resources
                        Constants.java LocalStrings.properties
                        StandardResources.java
  Removed:     proposals/catalina/src/share/org/apache/tomcat/core
                        StandardResources.java
  Log:
  Enhance the standard Resources implementation, including the following:
  * Move it to org.apache.tomcat.resources.StandardResources (instead of
    in the "core" package).
  * Add optimizations for file-based versus URL-based document roots.
  * Add property change listener so that changes to the document root of
    the context are automatically propogated.
  
  Enhanced the lifecycle management and context configuration so that it
  works, although it hasn't yet been tried with a web.xml file yet.  You
  can again start and stop Catalina successfully.
  
  Clean up other lifecycle-related bugs, particularly in the order that
  components are started and stopped.
  
  Revision  Changes    Path
  1.7       +5 -1      jakarta-tomcat/proposals/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/build.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- build.xml	2000/04/21 23:38:10	1.6
  +++ build.xml	2000/04/26 01:03:58	1.7
  @@ -6,7 +6,7 @@
     <property name="catalina.build" value="../../../build/catalina"/>
     <property name="catalina.home"  value="../../../dist/catalina"/>
   
  -  <!-- Create directories and copy static files -->
  +  <!-- Create directories -->
     <target name="prepare">
       <mkdir dir="${catalina.build}"/>
       <mkdir dir="${catalina.build}/bin"/>
  @@ -16,6 +16,10 @@
       <mkdir dir="${catalina.build}/src"/>
       <mkdir dir="${catalina.build}/lib"/>
       <mkdir dir="${catalina.build}/logs"/>
  +    <mkdir dir="${catalina.build}/webapps"/>
  +    <mkdir dir="${catalina.build}/webapps/ROOT"/>
  +    <mkdir dir="${catalina.build}/webapps/ROOT/WEB-INF"/>
  +    <mkdir dir="${catalina.build}/webapps/ROOT/WEB-INF/classes"/>
     </target>
   
     <!-- Copy static files -->
  
  
  
  1.8       +4 -3      jakarta-tomcat/proposals/catalina/src/conf/server.xml
  
  Index: server.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/conf/server.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- server.xml	2000/04/25 20:11:28	1.7
  +++ server.xml	2000/04/26 01:03:58	1.8
  @@ -12,7 +12,7 @@
   
     <!-- Define the top level container in our container hierarchy -->
   
  -  <Engine defaultHost="localhost" unknownHost="localhost">
  +  <Engine name="engine" defaultHost="localhost" unknownHost="localhost">
   
       <!-- Lifecycle listeners are notified of component start and stop -->
       <!-- <Lifecycle className="....LifecycleListener...." param="value"/> -->
  @@ -41,7 +41,7 @@
                 timestamp="true"/>
   
         <!-- Initial context to start playing with -->
  -      <Context path="/" docBase="webpages/ROOT">
  +      <Context path="/" docBase="webapps/ROOT">
           <Listener className="org.apache.tomcat.startup.ContextConfig"
   	          debug="1"/>
           <!--
  @@ -49,7 +49,8 @@
   	         checkInterval="15" maxActiveSessions="100"
                    pathname="localhost_sessions/ROOT.sessions"/>
           -->
  -        <Resources className="org.apache.tomcat.resources.StandardResources"/>
  +        <Resources className="org.apache.tomcat.resources.StandardResources"
  +	           debug="1"/>
         </Context>
   
       </Host>
  
  
  
  1.3       +16 -4     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Resources.java
  
  Index: Resources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Resources.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Resources.java	2000/01/29 07:46:32	1.2
  +++ Resources.java	2000/04/26 01:03:59	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Resources.java,v
1.2 2000/01/29 07:46:32 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/01/29 07:46:32 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/Resources.java,v
1.3 2000/04/26 01:03:59 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/04/26 01:03:59 $
    *
    * ====================================================================
    *
  @@ -82,7 +82,7 @@
    * normally configured for this Container.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/01/29 07:46:32 $
  + * @version $Revision: 1.3 $ $Date: 2000/04/26 01:03:59 $
    */
   
   public interface Resources {
  @@ -216,6 +216,18 @@
        * @param path The path to the desired resource
        */
       public InputStream getResourceAsStream(String path);
  +
  +
  +    /**
  +     * Return the last modified date/time of the resource at the specified
  +     * path, where <code>path</code> would be suitable for passing as an
  +     * argument to <code>getResource()</code> or
  +     * <code>getResourceAsStream()</code>.  If there is no resource at the
  +     * specified location, return -1.
  +     *
  +     * @param path The path to the desired resource
  +     */
  +    public long getResourceModified(String path);
   
   
       /**
  
  
  
  1.12      +28 -8     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ContainerBase.java	2000/04/18 04:53:41	1.11
  +++ ContainerBase.java	2000/04/26 01:03:59	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.11 2000/04/18 04:53:41 craigmcc Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/04/18 04:53:41 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.12 2000/04/26 01:03:59 craigmcc Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/04/26 01:03:59 $
    *
    * ====================================================================
    *
  @@ -149,7 +149,7 @@
    * class comments of the implementation class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2000/04/18 04:53:41 $
  + * @version $Revision: 1.12 $ $Date: 2000/04/26 01:03:59 $
    */
   
   public abstract class ContainerBase
  @@ -747,7 +747,7 @@
   						   child.getName() +
   						   "' is not unique");
   	    child.setParent((Container) this);	// May throw IAE
  -	    if (child instanceof Lifecycle) {
  +	    if (started && (child instanceof Lifecycle)) {
   		try {
   		    ((Lifecycle) child).start();
   		} catch (LifecycleException e) {
  @@ -833,7 +833,7 @@
   	    if (children.get(child.getName()) == null)
   		return;
   	    children.remove(child.getName());
  -	    if (child instanceof Lifecycle) {
  +	    if (started && (child instanceof Lifecycle)) {
   		try {
   		    ((Lifecycle) child).stop();
   		} catch (LifecycleException e) {
  @@ -912,8 +912,8 @@
   	if (started)
   	    throw new LifecycleException
   		(sm.getString("containerBase.alreadyStarted"));
  -	started = true;
   	lifecycle.fireLifecycleEvent(START_EVENT, null);
  +	started = true;
   
   	// Start our subordinate components, if any
   	if ((loader != null) && (loader instanceof Lifecycle))
  @@ -927,6 +927,13 @@
   	if ((resources != null) && (resources instanceof Lifecycle))
   	    ((Lifecycle) resources).start();
   
  +	// Start our child containers, if any
  +	Container children[] = findChildren();
  +	for (int i = 0; i < children.length; i++) {
  +	    if (children[i] instanceof Lifecycle)
  +		((Lifecycle) children[i]).start();
  +	}
  +
   	// Start the Valves in our pipeline (including the basic), if any
   	Valve current = first;
   	while (current != null) {
  @@ -951,8 +958,8 @@
   	if (!started)
   	    throw new LifecycleException
   		(sm.getString("containerBase.notStarted"));
  -	started = false;
   	lifecycle.fireLifecycleEvent(STOP_EVENT, null);
  +	started = false;
   
   	// Stop the Valves in our pipeline (including the basic), if any
   	Valve current = basic;
  @@ -964,6 +971,13 @@
   	    current = current.getPrevious();
   	}
   
  +	// Stop our child containers, if any
  +	Container children[] = findChildren();
  +	for (int i = 0; i < children.length; i++) {
  +	    if (children[(children.length-1)-i] instanceof Lifecycle)
  +		((Lifecycle) children[(children.length-1)-i]).stop();
  +	}
  +
   	// Stop our subordinate components, if any
   	if ((resources != null) && (resources instanceof Lifecycle))
   	    ((Lifecycle) resources).stop();
  @@ -1127,6 +1141,8 @@
   	Logger logger = getLogger();
   	if (logger != null)
   	    logger.log(message);
  +	else
  +	    System.out.println(message);
   
       }
   
  @@ -1143,6 +1159,10 @@
   	Logger logger = getLogger();
   	if (logger != null)
   	    logger.log(message, throwable);
  +	else {
  +	    System.out.println(message + ": " + throwable);
  +	    throwable.printStackTrace(System.out);
  +	}
   
       }
   
  
  
  
  1.8       +0 -2      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/LocalStrings.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LocalStrings.properties	2000/04/17 02:34:34	1.7
  +++ LocalStrings.properties	2000/04/26 01:03:59	1.8
  @@ -23,8 +23,6 @@
   standardLoader.notStarted=Loader has not yet been started
   standardLoader.read=Repository $0 cannot be read
   standardLoader.type=Repository $0 is not a supported file type
  -standardResources.malformedPath=Path must start with '/'
  -standardResources.malformedURL=Malformed URL
   standardServer.addContainer.ise=No connectors available to associate this container with
   standardServer.start.connectors=At least one connector is not associated with any container
   standardServer.start.started=This server has already been started
  
  
  
  1.6       +6 -6      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StandardServer.java	2000/04/25 20:11:29	1.5
  +++ StandardServer.java	2000/04/26 01:03:59	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java,v
1.5 2000/04/25 20:11:29 craigmcc Exp $
  - * $Revision: 1.5 $
  - * $Date: 2000/04/25 20:11:29 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardServer.java,v
1.6 2000/04/26 01:03:59 craigmcc Exp $
  + * $Revision: 1.6 $
  + * $Date: 2000/04/26 01:03:59 $
    *
    * ====================================================================
    *
  @@ -89,7 +89,7 @@
    * (but not required) when deploying and starting Tomcat.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.5 $ $Date: 2000/04/25 20:11:29 $
  + * @version $Revision: 1.6 $ $Date: 2000/04/26 01:03:59 $
    */
   
   public final class StandardServer
  @@ -429,8 +429,8 @@
   	if (n > 0)
   	    throw new LifecycleException
   		(sm.getString("standardServer.start.connectors"));
  -	started = true;
   	lifecycle.fireLifecycleEvent(START_EVENT, null);
  +	started = true;
   
   	// Start our defined Containers first
   	Enumeration conts = containers.elements();
  @@ -467,8 +467,8 @@
   	if (!started)
   	    throw new LifecycleException
   		(sm.getString("standardServer.stop.notStarted"));
  -	started = false;
   	lifecycle.fireLifecycleEvent(STOP_EVENT, null);
  +	started = false;
   
   	// Stop our defined Connectors first
   	Enumeration conns = connectors.elements();
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/Constants.java
  
  Index: Constants.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/Constants.java,v
1.1 2000/04/26 01:04:00 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/26 01:04:00 $
   *
   * ====================================================================
   *
   * 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.resources;
  
  
  public class Constants {
  
      public static final String Package = "org.apache.tomcat.resources";
  
  }
  
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  standardResources.alreadyStarted=Resources has already been started
  standardResources.directory=File base {0} is not a directory
  standardResources.notStarted=Resources has not yet been started
  standardResources.slash=Document base {0} must not end with a slash
  
  
  
  1.1                  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java
  
  Index: StandardResources.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/resources/StandardResources.java,v
1.1 2000/04/26 01:04:00 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/04/26 01:04:00 $
   *
   * ====================================================================
   *
   * 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.resources;
  
  
  import java.beans.PropertyChangeEvent;
  import java.beans.PropertyChangeSupport;
  import java.beans.PropertyChangeListener;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.InputStream;
  import java.io.IOException;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.Vector;
  import org.apache.tomcat.Container;
  import org.apache.tomcat.Context;
  import org.apache.tomcat.Lifecycle;
  import org.apache.tomcat.LifecycleEvent;
  import org.apache.tomcat.LifecycleException;
  import org.apache.tomcat.LifecycleListener;
  import org.apache.tomcat.Logger;
  import org.apache.tomcat.Resources;
  import org.apache.tomcat.util.LifecycleSupport;
  import org.apache.tomcat.util.StringManager;
  import org.apache.tomcat.util.URLUtil;
  
  
  /**
   * Standard implementation of the <b>Resources</b> interface.  Resource
   * requests are resolved against the document base that is configured.
   * For the purposes of this implementation, a document base can be:
   * <ul>
   * <li>An absolute disk directory pathname (no trailing slash).
   * <li>A relative disk directory pathname (no trailing slash), which will
   *     be resolved against the current working directory at runtime
   * <li>A URL prefix (no trailing slash) to a resource base that is potentially
   *     remote.
   * </ul>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/04/26 01:04:00 $
   */
  
  public final class StandardResources
      implements Resources, Lifecycle, PropertyChangeListener {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a new instance of this class with default values.
       */
      public StandardResources() {
  
  	super();
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The Container this component is associated with.
       */
      private Container container = null;
  
  
      /**
       * The debugging detail level for this component.
       */
      private int debug = 0;
  
  
      /**
       * The document root for this component.
       */
      private String docBase = null;
  
  
      /**
       * The document root for this component, expressed as an absolute or
       * relative pathname, or <code>null</code> if the document root is
       * not filesystem-based.
       */
      private String fileBase = null;
  
  
      /**
       * The descriptive information string for this implementation.
       */
      private static final String info =
  	"org.apache.tomcat.resources.StandardResources/1.0";
  
  
      /**
       * The lifecycle event support for this component.
       */
      protected LifecycleSupport lifecycle = new LifecycleSupport(this);
  
  
      /**
       * The string manager for this package.
       */
      private static final StringManager sm =
  	StringManager.getManager(Constants.Package);
  
  
      /**
       * Has this component been started?
       */
      private boolean started = false;
  
  
      /**
       * The property change support for this component.
       */
      protected PropertyChangeSupport support = new PropertyChangeSupport(this);
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the Container with which this Resources has been associated.
       */
      public Container getContainer() {
  
  	return (this.container);
  
      }
  
  
      /**
       * Set the Container with which this Resources has been associated.
       *
       * @param container The associated Container
       */
      public void setContainer(Container container) {
  
  	Container oldContainer = this.container;
  	if ((oldContainer != null) && (oldContainer instanceof Context))
  	    ((Context) oldContainer).removePropertyChangeListener(this);
  
  	this.container = container;
  	// We are interested in property changes to the document base
  	if ((this.container != null) && (this.container instanceof Context)) {
  	    ((Context) this.container).addPropertyChangeListener(this);
  	    setDocBase(((Context) this.container).getDocBase());
  	}
  
  	support.firePropertyChange("container", oldContainer, this.container);
  
      }
  
  
      /**
       * Return the debugging detail level for this component.
       */
      public int getDebug() {
  
  	return (this.debug);
  
      }
  
  
      /**
       * Set the debugging detail level for this component.
       *
       * @param debug The new debugging detail level
       */
      public void setDebug(int debug) {
  
  	this.debug = debug;
  
      }
  
  
      /**
       * Return the document root for this component.
       */
      public String getDocBase() {
  
  	return (this.docBase);
  
      }
  
  
      /**
       * Set the document root for this component.
       *
       * @param docBase The new document root
       *
       * @exception IllegalArgumentException if this would create a
       *  malformed URL
       */
      public void setDocBase(String docBase) {
  
  	// Validate the format of the proposed document root
  	if ((docBase != null) && (docBase.length() > 1) &&
  	    docBase.endsWith("/"))
  	    throw new IllegalArgumentException
  		(sm.getString("standardResources.slash", docBase));
  
  	// Change the document root property
  	String oldDocBase = this.docBase;
  	this.docBase = docBase.toString();
  	support.firePropertyChange("docBase", oldDocBase, this.docBase);
  	if (debug > 0) {
  	    String containerName = null;
  	    if (container != null)
  		containerName = container.getName();
  	    log("Setting container '" + containerName +
  		"' docBase to '" + this.docBase + "'");
  	}
  
  	// Calculate the corresponding file base (if any)
  	fileBase = null;
  	if (this.docBase == null)
  	    return;
  	int colon = this.docBase.indexOf(":");
  	if (colon <= 1)			// No colon, or Windows drive letter
  	    fileBase = docBase;
  	if (this.docBase.startsWith("file:")) {
  	    if (this.docBase.startsWith("file://"))
  		fileBase = docBase.substring(7);
  	    else
  		fileBase = docBase.substring(5);
  	    if ((fileBase.length() > 2) &&
  		(fileBase.charAt(1) == '|'))
  		fileBase =
  		    fileBase.substring(0, 1) + ":" + fileBase.substring(2);
  	}
  
  	// Make sure that fileBase is an absolute pathname to a directory
  	if (fileBase != null) {
  	    File file = new File(fileBase);
  	    if (!file.isAbsolute())
  		fileBase = file.getAbsolutePath();
  	    if (!file.isDirectory())
  		throw new IllegalArgumentException
  		    (sm.getString("standardResources.directory", fileBase));
  	}
  
  	if (debug > 0)
  	    log("Also setting fileBase to '" +
  		fileBase + "'");
  
      }
  
  
      /**
       * Return descriptive information about this Resources implementation and
       * the corresponding version number, in the format
       * <code>&lt;description&gt;/&lt;version&gt;</code>.
       */
      public String getInfo() {
  
  	return (info);
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Add a property change listener to this component.
       *
       * @param listener The listener to add
       */
      public void addPropertyChangeListener(PropertyChangeListener listener) {
  
  	support.addPropertyChangeListener(listener);
  
      }
  
  
      /**
       * Return the MIME type of the specified file, or <code>null</code> if
       * the MIME type is not known.  The MIME type is determined by the
       * configuration of the servlet container, and may be specified in a
       * web application descriptor.  Common MIME types are
       * <code>"text/html"</code> and <code>"image/gif"</code>.
       *
       * @param file Name of the file whose MIME type is to be determined
       */
      public String getMimeType(String file) {
  
  	if (file == null)
  	    return (null);
  	if ((container != null) || (!(container instanceof Context)))
  	    return (null);
  	int period = file.lastIndexOf(".");
  	if (period < 0)
  	    return (null);
  	String extension = file.substring(period + 1);
  	if (extension.length() < 1)
  	    return (null);
  	else
  	    return (((Context) container).findMimeMapping(extension));
  
      }
  
  
      /**
       * Return the real path for a given virtual path.  For example, the
       * virtual path <code>"/index.html"</code> has a real path of whatever
       * file on the server's filesystem would be served by a request for
       * <code>"/index.html"</code>.
       * <p>
       * The real path returned will be in a form appropriate to the computer
       * and operating system on which the servlet container is running,
       * including the proper path separators.  This method returns
       * <code>null</code> if the servlet container cannot translate the
       * virtual path to a real path for any reason (such as when the content
       * is being made available from a <code>.war</code> archive).
       *
       * @param path The virtual path to be translated
       */
      public String getRealPath(String path) {
  
  	if ((fileBase == null) || (path == null) || (!path.startsWith("/")))
  	    return (null);
  	else
  	    return (fileBase + path);
  
      }
  
  
      /**
       * Return a URL to the resource that is mapped to the specified path.
       * The path must begin with a "/" and is interpreted as relative to
       * the current context root.
       * <p>
       * This method allows the Container to make a resource available to
       * servlets from any source.  Resources can be located on a local or
       * remote file system, in a database, or in a <code>.war</code> file.
       * <p>
       * The servlet container must implement the URL handlers and
       * <code>URLConnection</code> objects that are necessary to access
       * the resource.
       * <p>
       * This method returns <code>null</code> if no resource is mapped to
       * the pathname.
       * <p>
       * Some Containers may allow writing to the URL returned by this method,
       * using the methods of the URL class.
       * <p>
       * The resource content is returned directly, so be aware that
       * requesting a <code>.jsp</code> page returns the JSP source code.
       * Use a <code>RequestDispatcher</code> instead to include results
       * of an execution.
       * <p>
       * This method has a different purpose than
       * <code>java.lang.Class.getResource()</code>, which looks up resources
       * based on a class loader.  This method does not use class loaders.
       *
       * @param path The path to the desired resource
       *
       * @exception MalformedURLException if the pathname is not given
       *  in the correct form
       */
      public URL getResource(String path) throws MalformedURLException {
  
  	if (path == null)
  	    return (null);
  
  	// Deal with URL-based document root
  	if (fileBase == null) {
  	    ;	// FIXME -- return NULL if resource does not exist
  	    return (new URL(docBase + path));
  	}
  
  	// Deal with file-based document root
  	File file = new File(fileBase + path);
  	if (!file.exists())
  	    return (null);
  	String url = null;
  	if ((fileBase.length() > 2) && (fileBase.charAt(1) == ':'))
  	    url = "file:///" + fileBase.substring(0, 1) + ":" +
  		fileBase.substring(2) + path;
  	else
  	    url = "file://" + fileBase + path;
  	return (new URL(url));
  
      }
  
  
      /**
       * Return the resource located at the named path as an
       * <code>InputStream</code> object.
       * <p>
       * The data in the <code>InputStream</code> can be of any type or length.
       * The path must be specified according to the rules given in
       * <code>getResource()</code>.  This method returns <code>null</code>
       * if no resource exists at the specified path.
       * <p>
       * Meta-information such as content length and content type that is
       * available via the <code>getResource()</code> method is lost when
       * using this method.
       * <p>
       * The servlet container must implement the URL handlers and
       * <code>URLConnection</code> objects that are necessary to access
       * the resource.
       * <p>
       * This method is different from
       * <code>java.lang.Class.getResourceAsStream()</code>, which uses a
       * class loader.  This method allows servlet containers to make a
       * resource available to a servlet from any location, without using
       * a class loader.
       *
       * @param path The path to the desired resource
       */
      public InputStream getResourceAsStream(String path) {
  
  	if (path == null)
  	    return (null);
  
  	// Deal with URL-based document root
  	if (fileBase == null) {
  	    try {
  		URL url = getResource(path);
  		return (url.openStream());
  	    } catch (MalformedURLException e) {
  		return (null);
  	    } catch (IOException e) {
  		return (null);
  	    }
  	}
  
  	// Deal with file-based document root
  	try {
  	    return (new FileInputStream(fileBase + path));
  	} catch (Throwable t) {
  	    return (null);
  	}
  
      }
  
  
      /**
       * Return the last modified date/time of the resource at the specified
       * path, where <code>path</code> would be suitable for passing as an
       * argument to <code>getResource()</code> or
       * <code>getResourceAsStream()</code>.  If there is no resource at the
       * specified location, return -1.
       *
       * @param path The path to the desired resource
       */
      public long getResourceModified(String path) {
  
  	if (path == null)
  	    return (-1);
  
  	// Deal with URL-based document root
  	if (fileBase == null) {
  	    return (-1);	// FIXME - URL-based document root
  	}
  
  	// Deal with file-based document root
  	File file = new File(fileBase + path);
  	if (file.exists())
  	    return (file.lastModified());
  	else
  	    return (-1);
  
      }
  
  
      /**
       * Remove a property change listener from this component.
       *
       * @param listener The listener to remove
       */
      public void removePropertyChangeListener(PropertyChangeListener listener) {
  
  	support.removePropertyChangeListener(listener);
  
      }
  
  
      // ----------------------------------------- PropertyChangeListener Methods
  
  
      /**
       * Process property change events from our associated Context.
       *
       * @param event The property change event that has occurred
       */
      public void propertyChange(PropertyChangeEvent event) {
  
  	// Validate the source of this event
  	if (!(event.getSource() instanceof Context))
  	    return;
  	Context context = (Context) event.getSource();
  
  	// Process a relevant property change
  	if (event.getPropertyName().equals("docBase"))
  	    setDocBase((String) event.getNewValue());
  
      }
  
  
      // -------------------------------------------------------- Private Methods
  
  
      /**
       * Log a message on the Logger associated with our Container (if any)
       *
       * @param message Message to be logged
       */
      private void log(String message) {
  
  	Logger logger = null;
  	if (container != null)
  	    logger = container.getLogger();
  	if (logger != null)
  	    logger.log("StandardResources[" + container.getName() + "]: "
  		       + message);
  	else {
  	    String containerName = null;
  	    if (container != null)
  		containerName = container.getName();
  	    System.out.println("StandardResources[" + containerName
  			       + "]: " + message);
  	}
  
      }
  
  
      /**
       * Log a message on the Logger associated with our Container (if any)
       *
       * @param message Message to be logged
       * @param throwable Associated exception
       */
      private void log(String message, Throwable throwable) {
  
  	Logger logger = null;
  	if (container != null)
  	    logger = container.getLogger();
  	if (logger != null)
  	    logger.log("StandardResources[" + container.getName() + "] "
  		       + message, throwable);
  	else {
  	    String containerName = null;
  	    if (container != null)
  		containerName = container.getName();
  	    System.out.println("StandardResources[" + containerName
  			       + "]: " + message);
  	    System.out.println("" + throwable);
  	    throwable.printStackTrace(System.out);
  	}
  
      }
  
  
      // ------------------------------------------------------ Lifecycle Methods
  
  
      /**
       * Add a lifecycle event listener to this component.
       *
       * @param listener The listener to add
       */
      public void addLifecycleListener(LifecycleListener listener) {
  
  	lifecycle.addLifecycleListener(listener);
  
      }
  
  
      /**
       * Remove a lifecycle event 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 after <code>configure()</code>,
       * and before any of the public methods of the component are utilized.
       *
       * @exception IllegalStateException if this component has already been
       *  started
       * @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)
  	    throw new LifecycleException
  		(sm.getString("standardResources.alreadyStarted"));
  	lifecycle.fireLifecycleEvent(START_EVENT, null);
  	started = true;
  
      }
  
  
      /**
       * 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.
       *
       * @exception IllegalStateException if this component has not been started
       * @exception LifecycleException if this component detects a fatal error
       *  that needs to be reported
       */
      public void stop() throws LifecycleException {
  
  	// Validate and update our current state
  	if (!started)
  	    throw new LifecycleException
  		(sm.getString("standardResources.notStarted"));
  
  	lifecycle.fireLifecycleEvent(STOP_EVENT, null);
  	started = false;
  
      }
  
  
  }
  
  
  
  1.5       +9 -19     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java
  
  Index: Catalina.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Catalina.java	2000/04/22 23:15:51	1.4
  +++ Catalina.java	2000/04/26 01:04:00	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v
1.4 2000/04/22 23:15:51 craigmcc Exp $
  - * $Revision: 1.4 $
  - * $Date: 2000/04/22 23:15:51 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/Catalina.java,v
1.5 2000/04/26 01:04:00 craigmcc Exp $
  + * $Revision: 1.5 $
  + * $Date: 2000/04/26 01:04:00 $
    *
    * ====================================================================
    *
  @@ -87,7 +87,7 @@
    * </u>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.4 $ $Date: 2000/04/22 23:15:51 $
  + * @version $Revision: 1.5 $ $Date: 2000/04/26 01:04:00 $
    */
   
   public final class Catalina {
  @@ -222,7 +222,7 @@
   	mapper.addRule("Server/Connector/Listener", mapper.setProperties());
   	mapper.addRule("Server/Connector/Listener", mapper.addChild
   		       ("addLifecycleListener",
  -			"org.apache.tomcat.Lifecycle"));
  +			"org.apache.tomcat.LifecycleListener"));
   
   	mapper.addRule("Server/Engine", mapper.objectCreate
   		       ("org.apache.tomcat.core.StandardEngine", "className"));
  @@ -233,7 +233,7 @@
   	mapper.addRule("Server/Engine/Host", mapper.objectCreate
   		       ("org.apache.tomcat.core.StandardHost", "className"));
   	mapper.addRule("Server/Engine/Host", mapper.setProperties());
  -	mapper.addRule("ServerEngine/Host", mapper.addChild
  +	mapper.addRule("Server/Engine/Host", mapper.addChild
   		       ("addChild", "org.apache.tomcat.Container"));
   
   	mapper.addRule("Server/Engine/Host/Context", mapper.objectCreate
  @@ -242,7 +242,6 @@
   	mapper.addRule("Server/Engine/Host/Context", mapper.setProperties());
   	mapper.addRule("Server/Engine/Host/Context", mapper.addChild
   		       ("addChild", "org.apache.tomcat.Container"));
  -	;	// FIXME -- Process web.xml (with a LifecycleListener?) !!!
   
   	mapper.addRule("Server/Engine/Host/Context/Listener",
   		       mapper.objectCreate
  @@ -251,7 +250,7 @@
   		       mapper.setProperties());
   	mapper.addRule("Server/Engine/Host/Context/Listener", mapper.addChild
   		       ("addLifecycleListener",
  -			"org.apache.tomcat.Lifecycle"));
  +			"org.apache.tomcat.LifecycleListener"));
   
   	mapper.addRule("Server/Engine/Host/Context/Loader",
   		       mapper.objectCreate
  @@ -305,7 +304,7 @@
   	mapper.addRule("Server/Engine/Host/Listener", mapper.setProperties());
   	mapper.addRule("Server/Engine/Host/Listener", mapper.addChild
   		       ("addLifecycleListener",
  -			"org.apache.tomcat.Lifecycle"));
  +			"org.apache.tomcat.LifecycleListener"));
   
   	mapper.addRule("Server/Engine/Host/Loader", mapper.objectCreate
   		       ("org.apache.tomcat.core.StandardLoader", "className"));
  @@ -350,7 +349,7 @@
   	mapper.addRule("Server/Engine/Listener", mapper.setProperties());
   	mapper.addRule("Server/Engine/Listener", mapper.addChild
   		       ("addLifecycleListener",
  -			"org.apache.tomcat.Lifecycle"));
  +			"org.apache.tomcat.LifecycleListener"));
   
   	mapper.addRule("Server/Engine/Loader", mapper.objectCreate
   		       ("org.apache.tomcat.core.StandardLoader", "className"));
  @@ -520,13 +519,4 @@
       }
   
   
  -    // --------------------------------------------------------- Static Methods
  -
  -
  -
   }
  -
  -
  -// ------------------------------------------------------------ Private Classes
  -
  -
  
  
  
  1.2       +23 -11    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContextConfig.java	2000/04/25 20:11:30	1.1
  +++ ContextConfig.java	2000/04/26 01:04:00	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
1.1 2000/04/25 20:11:30 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/04/25 20:11:30 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/ContextConfig.java,v
1.2 2000/04/26 01:04:00 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/04/26 01:04:00 $
    *
    * ====================================================================
    *
  @@ -73,6 +73,7 @@
   import org.apache.tomcat.Logger;
   import org.apache.tomcat.Resources;
   import org.apache.tomcat.Wrapper;
  +import org.apache.tomcat.resources.StandardResources;
   import org.apache.tomcat.util.StringManager;
   import org.apache.tomcat.util.xml.SaxContext;
   import org.apache.tomcat.util.xml.XmlAction;
  @@ -85,7 +86,7 @@
    * resource for this web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/04/25 20:11:30 $
  + * @version $Revision: 1.2 $ $Date: 2000/04/26 01:04:00 $
    */
   
   public final class ContextConfig
  @@ -151,9 +152,9 @@
   
   	// Identify the context we are associated with
   	try {
  -	    context = (Context) event.getData();
  +	    context = (Context) event.getLifecycle();
   	} catch (ClassCastException e) {
  -	    log(sm.getString("contextConfig.cce", event.getData()), e);
  +	    log(sm.getString("contextConfig.cce", event.getLifecycle()), e);
   	    return;
   	}
   
  @@ -349,8 +350,19 @@
       private void start() {
   
   	if (debug > 0)
  -	    log(sm.getString("contextConfig.start", context.getName()));
  +	    log(sm.getString("contextConfig.start"));
   
  +	// Add missing Resources component if necessary
  +	if (context.getResources() == null) {
  +	    if (debug > 0)
  +		log(sm.getString("contextConfig.defaultResources"));
  +	    Resources resources = new StandardResources();
  +	    context.setResources(resources);
  +	}
  +
  +	// Add missing Manager component if necessary
  +	;	// FIXME - missing Manager component
  +
   	// Configure a mapper to read a web application deployment descriptor
   	XmlMapper mapper = createMapper();
   
  @@ -360,19 +372,19 @@
   	// Process the deployment descriptor for this app second
   	Resources resources = context.getResources();
   	if (resources == null) {
  -	    log(sm.getString("contextConfig.resources", context.getName()));
  +	    log(sm.getString("contextConfig.resources"));
   	    return;
   	}
   	InputStream stream =
   	    resources.getResourceAsStream(Constants.WebXmlResource);
   	if (stream == null) {
  -	    log(sm.getString("contextConfig.descriptor", context.getName()));
  +	    log(sm.getString("contextConfig.descriptor"));
   	    return;
   	}
   	try {
   	    mapper.readXml(stream, context);
   	} catch (Exception e) {
  -	    log(sm.getString("contextConfig.parser", context.getName()), e);
  +	    log(sm.getString("contextConfig.parserApplication"));
   	    return;
   	}
   
  @@ -385,7 +397,7 @@
       private void stop() {
   
   	if (debug > 0)
  -	    log(sm.getString("contextConfig.stop", context.getName()));
  +	    log(sm.getString("contextConfig.stop"));
   
       }
   
  
  
  
  1.2       +7 -5      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/startup/LocalStrings.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocalStrings.properties	2000/04/25 20:11:30	1.1
  +++ LocalStrings.properties	2000/04/26 01:04:01	1.2
  @@ -1,7 +1,9 @@
   contextConfig.cce=Lifecycle event data object {0} is not a Context
  -contextConfig.descriptor=No web.xml for context {0}, using default web.xml only
   contextConfig.default=Parse error processing default web.xml
  -contextConfig.parser=Parse error processing context {0} web.xml
  -contextConfig.resources=No resources for context {0}, using default web.xml only
  -contextConfig.start=ContextConfig: Processing START for context {0}
  -contextConfig.stop=ContextConfig: Processing STOP for context {0}
  +contextConfig.defaultResources=Configuring default Resources
  +contextConfig.descriptor=No application web.xml, using default web.xml only
  +contextConfig.parserApplication=Parse error processing application web.xml
  +contextConfig.parserDefault=Parse error processing default web.xml
  +contextConfig.resources=No resources available, using default web.xml only
  +contextConfig.start=ContextConfig: Processing START
  +contextConfig.stop=ContextConfig: Processing STOP
  
  
  

Mime
View raw message