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/servlets DefaultServlet.java
Date Sat, 29 Jul 2000 05:20:44 GMT
craigmcc    00/07/28 22:20:44

  Modified:    proposals/catalina/src/share/org/apache/tomcat/core
                        ApplicationContext.java ApplicationDispatcher.java
                        ContainerBase.java RootContext.java
                        StandardContext.java StandardHost.java
               proposals/catalina/src/share/org/apache/tomcat/servlets
                        DefaultServlet.java
  Log:
  Tune performance of these classes by switching to collections classes
  and using toArray() appropriately.
  
  (About half done reviewing the "core" package).
  
  Revision  Changes    Path
  1.10      +31 -17    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java
  
  Index: ApplicationContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ApplicationContext.java	2000/05/22 20:11:09	1.9
  +++ ApplicationContext.java	2000/07/29 05:20:39	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java,v
1.9 2000/05/22 20:11:09 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/05/22 20:11:09 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationContext.java,v
1.10 2000/07/29 05:20:39 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/07/29 05:20:39 $
    *
    * ====================================================================
    *
  @@ -68,9 +68,10 @@
   import java.io.InputStream;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Vector;
  +import java.util.HashMap;
   import javax.servlet.RequestDispatcher;
   import javax.servlet.Servlet;
   import javax.servlet.ServletContext;
  @@ -82,6 +83,7 @@
   import org.apache.tomcat.Resources;
   import org.apache.tomcat.Wrapper;
   import org.apache.tomcat.connector.HttpRequestBase;
  +import org.apache.tomcat.util.Enumerator;
   import org.apache.tomcat.util.StringManager;
   
   
  @@ -91,7 +93,7 @@
    * associated with each instance of <code>StandardContext</code>.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/05/22 20:11:09 $
  + * @version $Revision: 1.10 $ $Date: 2000/07/29 05:20:39 $
    */
   
   final class ApplicationContext
  @@ -121,7 +123,7 @@
       /**
        * The context attributes for this context.
        */
  -    private Hashtable attributes = new Hashtable();
  +    private HashMap attributes = new HashMap();
   
   
       /**
  @@ -131,6 +133,13 @@
   
   
       /**
  +     * Empty collection to serve as the basis for empty enumerations.
  +     * <strong>DO NOT ADD ANY ELEMENTS TO THIS COLLECTION!</strong>
  +     */
  +    private static final ArrayList empty = new ArrayList();
  +
  +
  +    /**
        * The string manager for this package.
        */
       private static final StringManager sm =
  @@ -148,7 +157,9 @@
        */
       public Object getAttribute(String name) {
   
  -	return (attributes.get(name));
  +	synchronized (attributes) {
  +	    return (attributes.get(name));
  +	}
   
       }
   
  @@ -159,7 +170,9 @@
        */
       public Enumeration getAttributeNames() {
   
  -	return (attributes.keys());
  +	synchronized (attributes) {
  +	    return (new Enumerator(attributes.keySet()));
  +	}
   
       }
   
  @@ -225,10 +238,7 @@
       public Enumeration getInitParameterNames() {
   
   	String parameters[] = context.findParameters();
  -	Vector results = new Vector();
  -	for (int i = 0; i < parameters.length; i++)
  -	    results.addElement(parameters[i]);
  -	return (results.elements());
  +	return (new Enumerator(Arrays.asList(parameters)));
   
       }
   
  @@ -425,7 +435,7 @@
        */
       public Enumeration getServletNames() {
   
  -	return ((new Vector()).elements());
  +	return (new Enumerator(empty));
   
       }
   
  @@ -435,7 +445,7 @@
        */
       public Enumeration getServlets() {
   
  -	return ((new Vector()).elements());
  +	return (new Enumerator(empty));
   
       }
   
  @@ -494,7 +504,9 @@
        */
       public void removeAttribute(String name) {
   
  -	attributes.remove(name);
  +	synchronized (attributes) {
  +	    attributes.remove(name);
  +	}
   
       }
   
  @@ -508,7 +520,9 @@
        */
       public void setAttribute(String name, Object value) {
   
  -	attributes.put(name, value);
  +	synchronized (attributes) {
  +	    attributes.put(name, value);
  +	}
   
       }
   
  
  
  
  1.10      +4 -5      jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationDispatcher.java
  
  Index: ApplicationDispatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationDispatcher.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ApplicationDispatcher.java	2000/06/23 17:51:16	1.9
  +++ ApplicationDispatcher.java	2000/07/29 05:20:39	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationDispatcher.java,v
1.9 2000/06/23 17:51:16 craigmcc Exp $
  - * $Revision: 1.9 $
  - * $Date: 2000/06/23 17:51:16 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ApplicationDispatcher.java,v
1.10 2000/07/29 05:20:39 craigmcc Exp $
  + * $Revision: 1.10 $
  + * $Date: 2000/07/29 05:20:39 $
    *
    * ====================================================================
    *
  @@ -67,7 +67,6 @@
   
   import java.io.IOException;
   import java.io.PrintWriter;
  -import java.util.Hashtable;
   import javax.servlet.RequestDispatcher;
   import javax.servlet.ServletContext;
   import javax.servlet.ServletException;
  @@ -93,7 +92,7 @@
    * from this resource.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.9 $ $Date: 2000/06/23 17:51:16 $
  + * @version $Revision: 1.10 $ $Date: 2000/07/29 05:20:39 $
    */
   
   final class ApplicationDispatcher
  
  
  
  1.18      +33 -36    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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ContainerBase.java	2000/05/22 20:11:09	1.17
  +++ ContainerBase.java	2000/07/29 05:20:39	1.18
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.17 2000/05/22 20:11:09 craigmcc Exp $
  - * $Revision: 1.17 $
  - * $Date: 2000/05/22 20:11:09 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/ContainerBase.java,v
1.18 2000/07/29 05:20:39 craigmcc Exp $
  + * $Revision: 1.18 $
  + * $Date: 2000/07/29 05:20:39 $
    *
    * ====================================================================
    *
  @@ -68,9 +68,9 @@
   import java.beans.PropertyChangeListener;
   import java.beans.PropertyChangeSupport;
   import java.io.IOException;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Vector;
  +import java.util.ArrayList;
  +import java.util.HashMap;
  +import java.util.Iterator;
   import javax.servlet.ServletException;
   import org.apache.tomcat.Container;
   import org.apache.tomcat.ContainerEvent;
  @@ -150,7 +150,7 @@
    * class comments of the implementation class.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.17 $ $Date: 2000/05/22 20:11:09 $
  + * @version $Revision: 1.18 $ $Date: 2000/07/29 05:20:39 $
    */
   
   public abstract class ContainerBase
  @@ -169,7 +169,7 @@
       /**
        * The child Containers belonging to this Container, keyed by name.
        */
  -    protected Hashtable children = new Hashtable();
  +    protected HashMap children = new HashMap();
   
   
       /**
  @@ -193,7 +193,7 @@
       /**
        * The container event listeners for this Container.
        */
  -    protected Vector listeners = new Vector();
  +    protected ArrayList listeners = new ArrayList();
   
   
       /**
  @@ -223,7 +223,7 @@
       /**
        * The set of Mappers associated with this Container, keyed by protocol.
        */
  -    protected Hashtable mappers = new Hashtable();
  +    protected HashMap mappers = new HashMap();
   
   
       /**
  @@ -793,7 +793,9 @@
        */
       public void addContainerListener(ContainerListener listener) {
   
  -	listeners.addElement(listener);
  +	synchronized (listeners) {
  +	    listeners.add(listener);
  +	}
   
       }
   
  @@ -856,7 +858,9 @@
   
   	if (name == null)
   	    return (null);
  -	return ((Container) children.get(name));
  +	synchronized (children) {	// Required by post-start changes
  +	    return ((Container) children.get(name));
  +	}
   
       }
   
  @@ -868,12 +872,8 @@
       public Container[] findChildren() {
   
   	synchronized (children) {
  -	    int n = children.size();
  -	    Container results[] = new Container[n];
  -	    Enumeration containers = children.elements();
  -	    for (int i = 0; i < n; i++)
  -		results[i] = (Container) containers.nextElement();
  -	    return (results);
  +	    Container results[] = new Container[children.size()];
  +	    return ((Container[]) children.values().toArray(results));
   	}
   
       }
  @@ -891,7 +891,9 @@
   	if (mapper != null)
   	    return (mapper);
   	else
  -	    return ((Mapper) mappers.get(protocol));
  +	    synchronized (mappers) {
  +		return ((Mapper) mappers.get(protocol));
  +	    }
   
       }
   
  @@ -903,15 +905,8 @@
       public Mapper[] findMappers() {
   
   	synchronized (mappers) {
  -	    int i = 0;
  -	    int n = mappers.size();
  -	    Mapper results[] = new Mapper[n];
  -	    Enumeration keys = mappers.keys();
  -	    while (keys.hasMoreElements()) {
  -		String key = (String) keys.nextElement();
  -		results[i++] = (Mapper) mappers.get(key);
  -	    }
  -	    return (results);
  +	    Mapper results[] = new Mapper[mappers.size()];
  +	    return ((Mapper[]) mappers.values().toArray(results));
   	}
   
       }
  @@ -1000,7 +995,9 @@
        */
       public void removeContainerListener(ContainerListener listener) {
   
  -	listeners.removeElement(listener);
  +	synchronized (listeners) {
  +	    listeners.remove(listener);
  +	}
   
       }
   
  @@ -1029,8 +1026,8 @@
   	    if (mappers.size() != 1)
   		this.mapper = null;
   	    else {
  -		Enumeration elements = mappers.elements();
  -	        this.mapper = (Mapper) elements.nextElement();
  +		Iterator values = mappers.values().iterator();
  +	        this.mapper = (Mapper) values.next();
   	    }
   	    fireContainerEvent(REMOVE_MAPPER_EVENT, mapper);
   	}
  @@ -1345,12 +1342,12 @@
       protected void fireContainerEvent(String type, Object data) {
   
   	ContainerEvent event = new ContainerEvent(this, type, data);
  -	Vector list = null;
  -	synchronized (this) {
  -	    list = (Vector) listeners.clone();
  +	ContainerListener list[] = new ContainerListener[0];
  +	synchronized (listeners) {
  +	    list = (ContainerListener[]) listeners.toArray(list);
   	}
  -	for (int i = 0; i < list.size(); i++)
  -	    ((ContainerListener) list.elementAt(i)).containerEvent(event);
  +	for (int i = 0; i < list.length; i++)
  +	    ((ContainerListener) list[i]).containerEvent(event);
   
       }
   
  
  
  
  1.3       +31 -14    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/RootContext.java
  
  Index: RootContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/RootContext.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RootContext.java	2000/04/27 05:55:15	1.2
  +++ RootContext.java	2000/07/29 05:20:40	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/RootContext.java,v
1.2 2000/04/27 05:55:15 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/04/27 05:55:15 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/RootContext.java,v
1.3 2000/07/29 05:20:40 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/07/29 05:20:40 $
    *
    * ====================================================================
    *
  @@ -68,9 +68,10 @@
   import java.io.InputStream;
   import java.net.MalformedURLException;
   import java.net.URL;
  +import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Vector;
  +import java.util.HashMap;
   import javax.servlet.RequestDispatcher;
   import javax.servlet.Servlet;
   import javax.servlet.ServletContext;
  @@ -78,6 +79,7 @@
   import org.apache.tomcat.Host;
   import org.apache.tomcat.Logger;
   import org.apache.tomcat.Resources;
  +import org.apache.tomcat.util.Enumerator;
   
   
   /**
  @@ -87,7 +89,7 @@
    * allowed by the security configuration of this deployment.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/04/27 05:55:15 $
  + * @version $Revision: 1.3 $ $Date: 2000/07/29 05:20:40 $
    */
   
   final class RootContext
  @@ -117,10 +119,17 @@
       /**
        * The context attributes for this context.
        */
  -    private Hashtable attributes = new Hashtable();
  +    private HashMap attributes = new HashMap();
   
   
       /**
  +     * Empty collection to serve as the basis for empty enumerations.
  +     * <strong>DO NOT ADD ANY ELEMENTS TO THIS COLLECTION!</strong>
  +     */
  +    private static final ArrayList empty = new ArrayList();
  +
  +
  +    /**
        * The Host instance with which we are associated.
        */
       private StandardHost host = null;
  @@ -137,7 +146,9 @@
        */
       public Object getAttribute(String name) {
   
  -	return (attributes.get(name));
  +	synchronized (attributes) {
  +	    return (attributes.get(name));
  +	}
   
       }
   
  @@ -148,7 +159,9 @@
        */
       public Enumeration getAttributeNames() {
   
  -	return (attributes.keys());
  +	synchronized (attributes) {
  +	    return (new Enumerator(attributes.keySet()));
  +	}
   
       }
   
  @@ -193,7 +206,7 @@
        */
       public Enumeration getInitParameterNames() {
   
  -	return ((new Vector()).elements());
  +	return (new Enumerator(empty));
   
       }
   
  @@ -345,7 +358,7 @@
        */
       public Enumeration getServletNames() {
   
  -	return ((new Vector()).elements());
  +	return (new Enumerator(empty));
   
       }
   
  @@ -355,7 +368,7 @@
        */
       public Enumeration getServlets() {
   
  -	return ((new Vector()).elements());
  +	return (new Enumerator(empty));
   
       }
   
  @@ -414,7 +427,9 @@
        */
       public void removeAttribute(String name) {
   
  -	attributes.remove(name);
  +	synchronized (attributes) {
  +	    attributes.remove(name);
  +	}
   
       }
   
  @@ -428,7 +443,9 @@
        */
       public void setAttribute(String name, Object value) {
   
  -	attributes.put(name, value);
  +	synchronized (attributes) {
  +	    attributes.put(name, value);
  +	}
   
       }
   
  
  
  
  1.23      +256 -131  jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- StandardContext.java	2000/07/01 22:25:39	1.22
  +++ StandardContext.java	2000/07/29 05:20:40	1.23
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.22 2000/07/01 22:25:39 craigmcc Exp $
  - * $Revision: 1.22 $
  - * $Date: 2000/07/01 22:25:39 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardContext.java,v
1.23 2000/07/29 05:20:40 craigmcc Exp $
  + * $Revision: 1.23 $
  + * $Date: 2000/07/29 05:20:40 $
    *
    * ====================================================================
    *
  @@ -67,9 +67,9 @@
   
   import java.io.File;
   import java.io.IOException;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import java.util.Vector;
  +import java.util.ArrayList;
  +import java.util.HashMap;
  +import java.util.Iterator;
   import javax.servlet.ServletContext;
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServletRequest;
  @@ -97,7 +97,7 @@
    * requests directed to a particular servlet.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.22 $ $Date: 2000/07/01 22:25:39 $
  + * @version $Revision: 1.23 $ $Date: 2000/07/29 05:20:40 $
    */
   
   public final class StandardContext
  @@ -125,7 +125,7 @@
       /**
        * The security constraints for this web application.
        */
  -    private Vector constraints = new Vector();
  +    private SecurityConstraint constraints[] = new SecurityConstraint[0];
   
   
       /**
  @@ -149,20 +149,20 @@
       /**
        * The EJB resource references for this web application, keyed by name.
        */
  -    private Hashtable ejbs = new Hashtable();
  +    private HashMap ejbs = new HashMap();
   
   
       /**
        * The environment entries for this web application, keyed by name.
        */
  -    private Hashtable envs = new Hashtable();
  +    private HashMap envs = new HashMap();
   
   
       /**
        * The exception pages for this web application, keyed by fully qualified
        * class name of the Java exception.
        */
  -    private Hashtable exceptionPages = new Hashtable();
  +    private HashMap exceptionPages = new HashMap();
   
   
       /**
  @@ -188,14 +188,14 @@
       /**
        * The MIME mappings for this web application, keyed by extension.
        */
  -    private Hashtable mimeMappings = new Hashtable();
  +    private HashMap mimeMappings = new HashMap();
   
   
       /**
        * The context initialization parameters for this web application,
        * keyed by name.
        */
  -    private Hashtable parameters = new Hashtable();
  +    private HashMap parameters = new HashMap();
   
   
       /**
  @@ -213,27 +213,27 @@
       /**
        * The resource references for this web application, keyed by name.
        */
  -    private Hashtable resources = new Hashtable();
  +    private HashMap resources = new HashMap();
   
   
       /**
        * The security role mappings for this application, keyed by role
        * name (as used within the application).
        */
  -    private Hashtable roleMappings = new Hashtable();
  +    private HashMap roleMappings = new HashMap();
   
   
       /**
        * The security roles for this application, keyed by role name.
        */
  -    private Hashtable securityRoles = new Hashtable();
  +    private String securityRoles[] = new String[0];
   
   
       /**
        * The servlet mappings for this web application, keyed by
        * matching pattern.
        */
  -    private Hashtable servletMappings = new Hashtable();
  +    private HashMap servletMappings = new HashMap();
   
   
       /**
  @@ -246,19 +246,19 @@
        * The status code error pages for this web application, keyed by
        * HTTP status code (as an Integer).
        */
  -    private Hashtable statusPages = new Hashtable();
  +    private HashMap statusPages = new HashMap();
   
   
       /**
        * The JSP tag libraries for this web application, keyed by URI
        */
  -    private Hashtable taglibs = new Hashtable();
  +    private HashMap taglibs = new HashMap();
   
   
       /**
  -     * The welcome files for this application
  +     * The welcome files for this application.
        */
  -    private Vector welcomeFiles = new Vector();
  +    private String welcomeFiles[] = new String[0];
   
   
       /**
  @@ -534,9 +534,13 @@
        */
       public void addConstraint(SecurityConstraint constraint) {
   
  -	if (!constraints.contains(constraint)) {
  -	    constraints.addElement(constraint);
  -	    fireContainerEvent("addConstraint", constraint);
  +	synchronized (constraints) {
  +	    SecurityConstraint results[] =
  +		new SecurityConstraint[constraints.length + 1];
  +	    for (int i = 0; i < constraints.length; i++)
  +		results[i] = constraints[i];
  +	    results[constraints.length] = constraint;
  +	    constraints = results;
   	}
   
       }
  @@ -550,7 +554,9 @@
        */
       public void addEjb(ContextEjb ejb) {
   
  -	ejbs.put(ejb.getName(), ejb);
  +	synchronized (ejbs) {
  +	    ejbs.put(ejb.getName(), ejb);
  +	}
   	fireContainerEvent("addEjb", ejb.getName());
   
       }
  @@ -582,7 +588,9 @@
        */
       public void addEnvironment(ContextEnvironment environment) {
   
  -	envs.put(environment.getName(), environment);
  +	synchronized (envs) {
  +	    envs.put(environment.getName(), environment);
  +	}
   	fireContainerEvent("addEnvironment", environment.getName());
   
       }
  @@ -612,11 +620,16 @@
       public void addErrorPage(ErrorPage errorPage) {
   
   	String exceptionType = errorPage.getExceptionType();
  -	if (exceptionType != null)
  -	    exceptionPages.put(exceptionType, errorPage);
  -	else
  -	    statusPages.put(new Integer(errorPage.getErrorCode()),
  -			    errorPage);
  +	if (exceptionType != null) {
  +	    synchronized (exceptionPages) {
  +		exceptionPages.put(exceptionType, errorPage);
  +	    }
  +	} else {
  +	    synchronized (statusPages) {
  +		statusPages.put(new Integer(errorPage.getErrorCode()),
  +				errorPage);
  +	    }
  +	}
   	fireContainerEvent("addErrorPage", errorPage);
   
       }
  @@ -631,7 +644,9 @@
        */
       public void addMimeMapping(String extension, String mimeType) {
   
  -	mimeMappings.put(extension, mimeType);
  +	synchronized (mimeMappings) {
  +	    mimeMappings.put(extension, mimeType);
  +	}
   	fireContainerEvent("addMimeMapping", extension);
   
       }
  @@ -646,7 +661,9 @@
        */
       public void addParameter(String name, String value) {
   
  -	parameters.put(name, value);
  +	synchronized (parameters) {
  +	    parameters.put(name, value);
  +	}
   	fireContainerEvent("addParameter", name);
   
       }
  @@ -659,7 +676,9 @@
        */
       public void addResource(ContextResource resource) {
   
  -	resources.put(resource.getName(), resource);
  +	synchronized (resources) {
  +	    resources.put(resource.getName(), resource);
  +	}
   	fireContainerEvent("addResource", resource.getName());
   
       }
  @@ -689,7 +708,9 @@
        */
       public void addRoleMapping(String role, String link) {
   
  -	roleMappings.put(role, link);
  +	synchronized (roleMappings) {
  +	    roleMappings.put(role, link);
  +	}
   	fireContainerEvent("addRoleMapping", role);
   
       }
  @@ -702,7 +723,13 @@
        */
       public void addSecurityRole(String role) {
   
  -	securityRoles.put(role, role);
  +	synchronized (securityRoles) {
  +	    String results[] =new String[securityRoles.length + 1];
  +	    for (int i = 0; i < securityRoles.length; i++)
  +		results[i] = securityRoles[i];
  +	    results[securityRoles.length] = name;
  +	    securityRoles = results;
  +	}
   	fireContainerEvent("addSecurityRole", role);
   
       }
  @@ -717,7 +744,9 @@
        */
       public void addServletMapping(String pattern, String name) {
   
  -	servletMappings.put(pattern, name);
  +	synchronized (servletMappings) {
  +	    servletMappings.put(pattern, name);
  +	}
   	fireContainerEvent("addServletMapping", pattern);
   
       }
  @@ -731,7 +760,9 @@
        */
       public void addTaglib(String uri, String location) {
   
  -	taglibs.put(uri, location);
  +	synchronized (taglibs) {
  +	    taglibs.put(uri, location);
  +	}
   	fireContainerEvent("addTaglib", uri);
   
       }
  @@ -744,7 +775,13 @@
        */
       public void addWelcomeFile(String name) {
   
  -	welcomeFiles.addElement(name);
  +	synchronized (welcomeFiles) {
  +	    String results[] =new String[welcomeFiles.length + 1];
  +	    for (int i = 0; i < welcomeFiles.length; i++)
  +		results[i] = welcomeFiles[i];
  +	    results[welcomeFiles.length] = name;
  +	    welcomeFiles = results;
  +	}
   	postWelcomeFiles();
   	fireContainerEvent("addWelcomeFile", name);
   
  @@ -770,14 +807,7 @@
        */
       public SecurityConstraint[] findConstraints() {
   
  -	synchronized (constraints) {
  -	    SecurityConstraint results[] =
  -		new SecurityConstraint[constraints.size()];
  -	    Enumeration elements = constraints.elements();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (SecurityConstraint) elements.nextElement();
  -	    return (results);
  -	}
  +	return (constraints);
   
       }
   
  @@ -790,7 +820,9 @@
        */
       public ContextEjb findEjb(String name) {
   
  -	return ((ContextEjb) ejbs.get(name));
  +	synchronized (ejbs) {
  +	    return ((ContextEjb) ejbs.get(name));
  +	}
   
       }
   
  @@ -803,10 +835,7 @@
   
   	synchronized (ejbs) {
   	    ContextEjb results[] = new ContextEjb[ejbs.size()];
  -	    Enumeration elements = ejbs.elements();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (ContextEjb) elements.nextElement();
  -	    return (results);
  +	    return ((ContextEjb[]) ejbs.values().toArray(results));
   	}
   
       }
  @@ -820,7 +849,9 @@
        */
       public ContextEnvironment findEnvironment(String name) {
   
  -	return ((ContextEnvironment) envs.get(name));
  +	synchronized (envs) {
  +	    return ((ContextEnvironment) envs.get(name));
  +	}
   
       }
   
  @@ -834,10 +865,7 @@
   
   	synchronized (envs) {
   	    ContextEnvironment results[] = new ContextEnvironment[envs.size()];
  -	    Enumeration elements = envs.elements();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (ContextEnvironment) elements.nextElement();
  -	    return (results);
  +	    return ((ContextEnvironment[]) envs.values().toArray(results));
   	}
   
       }
  @@ -864,7 +892,9 @@
        */
       public ErrorPage findErrorPage(String exceptionType) {
   
  -	return ((ErrorPage) exceptionPages.get(exceptionType));
  +	synchronized (exceptionPages) {
  +	    return ((ErrorPage) exceptionPages.get(exceptionType));
  +	}
   
       }
   
  @@ -875,16 +905,23 @@
        */
       public ErrorPage[] findErrorPages() {
   
  -	ErrorPage results[] =
  -	    new ErrorPage[exceptionPages.size() + statusPages.size()];
  -	int n = 0;
  -	Enumeration errorPages = exceptionPages.elements();
  -	while (errorPages.hasMoreElements())
  -	    results[n++] = (ErrorPage) errorPages.nextElement();
  -	errorPages = statusPages.elements();
  -	while (errorPages.hasMoreElements())
  -	    results[n++] = (ErrorPage) errorPages.nextElement();
  -	return (results);
  +	synchronized(exceptionPages) {
  +	    synchronized(statusPages) {
  +		ErrorPage results1[] = new ErrorPage[exceptionPages.size()];
  +		results1 =
  +		    (ErrorPage[]) exceptionPages.values().toArray(results1);
  +		ErrorPage results2[] = new ErrorPage[statusPages.size()];
  +		results2 =
  +		    (ErrorPage[]) statusPages.values().toArray(results2);
  +		ErrorPage results[] =
  +		    new ErrorPage[results1.length + results2.length];
  +		for (int i = 0; i < results1.length; i++)
  +		    results[i] = results1[i];
  +		for (int i = results1.length; i < results.length; i++)
  +		    results[i] = results2[i - results1.length];
  +		return (results);
  +	    }
  +	}
   
       }
   
  @@ -897,7 +934,9 @@
        */
       public String findMimeMapping(String extension) {
   
  -	return ((String) mimeMappings.get(extension));
  +	synchronized (mimeMappings) {
  +	    return ((String) mimeMappings.get(extension));
  +	}
   
       }
   
  @@ -910,10 +949,8 @@
   
   	synchronized (mimeMappings) {
   	    String results[] = new String[mimeMappings.size()];
  -	    Enumeration elements = mimeMappings.keys();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) elements.nextElement();
  -	    return (results);
  +	    return
  +		((String[]) mimeMappings.keySet().toArray(results));
   	}
   
       }
  @@ -927,7 +964,9 @@
        */
       public String findParameter(String name) {
   
  -	return ((String) parameters.get(name));
  +	synchronized (parameters) {
  +	    return ((String) parameters.get(name));
  +	}
   
       }
   
  @@ -941,10 +980,7 @@
   
   	synchronized (parameters) {
   	    String results[] = new String[parameters.size()];
  -	    Enumeration elements = parameters.keys();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) elements.nextElement();
  -	    return (results);
  +	    return ((String[]) parameters.keySet().toArray(results));
   	}
   
       }
  @@ -958,7 +994,9 @@
        */
       public ContextResource findResource(String name) {
   
  -	return ((ContextResource) resources.get(name));
  +	synchronized (resources) {
  +	    return ((ContextResource) resources.get(name));
  +	}
   
       }
   
  @@ -971,10 +1009,7 @@
   
   	synchronized (resources) {
   	    ContextResource results[] = new ContextResource[resources.size()];
  -	    Enumeration elements = resources.elements();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (ContextResource) elements.nextElement();
  -	    return (results);
  +	    return ((ContextResource[]) resources.values().toArray(results));
   	}
   
       }
  @@ -989,7 +1024,10 @@
        */
       public String findRoleMapping(String role) {
   
  -	String realRole = (String) roleMappings.get(role);
  +	String realRole = null;
  +	synchronized (roleMappings) {
  +	    realRole = (String) roleMappings.get(role);
  +	}
   	if (realRole != null)
   	    return (realRole);
   	else
  @@ -1006,7 +1044,13 @@
        */
       public boolean findSecurityRole(String role) {
   
  -	return (securityRoles.get(role) != null);
  +	synchronized (securityRoles) {
  +	    for (int i = 0; i < securityRoles.length; i++) {
  +		if (role.equals(securityRoles[i]))
  +		    return (true);
  +	    }
  +	}
  +	return (false);
   
       }
   
  @@ -1017,13 +1061,7 @@
        */
       public String[] findSecurityRoles() {
   
  -	synchronized (securityRoles) {
  -	    String results[] = new String[securityRoles.size()];
  -	    Enumeration elements = resources.keys();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) elements.nextElement();
  -	    return (results);
  -	}
  +	return (securityRoles);
   
       }
   
  @@ -1036,7 +1074,9 @@
        */
       public String findServletMapping(String pattern) {
   
  -	return ((String) servletMappings.get(pattern));
  +	synchronized (servletMappings) {
  +	    return ((String) servletMappings.get(pattern));
  +	}
   
       }
   
  @@ -1049,10 +1089,8 @@
   
   	synchronized (servletMappings) {
   	    String results[] = new String[servletMappings.size()];
  -	    Enumeration elements = servletMappings.keys();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) elements.nextElement();
  -	    return (results);
  +	    return
  +	       ((String[]) servletMappings.keySet().toArray(results));
   	}
   
       }
  @@ -1080,9 +1118,10 @@
   
   	synchronized (statusPages) {
   	    int results[] = new int[statusPages.size()];
  -	    Enumeration elements = statusPages.keys();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = ((Integer) elements.nextElement()).intValue();
  +	    Iterator elements = statusPages.keySet().iterator();
  +	    int i = 0;
  +	    while (elements.hasNext())
  +		results[i++] = ((Integer) elements.next()).intValue();
   	    return (results);
   	}
   
  @@ -1097,7 +1136,9 @@
        */
       public String findTaglib(String uri) {
   
  -	return ((String) taglibs.get(uri));
  +	synchronized (taglibs) {
  +	    return ((String) taglibs.get(uri));
  +	}
   
       }
   
  @@ -1111,10 +1152,7 @@
   
   	synchronized (taglibs) {
   	    String results[] = new String[taglibs.size()];
  -	    Enumeration elements = taglibs.keys();
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) elements.nextElement();
  -	    return (results);
  +	    return ((String[]) taglibs.keySet().toArray(results));
   	}
   
       }
  @@ -1129,12 +1167,12 @@
       public boolean findWelcomeFile(String name) {
   
   	synchronized (welcomeFiles) {
  -	    for (int i = 0; i < welcomeFiles.size(); i++) {
  -		if (name.equals((String) welcomeFiles.elementAt(i)))
  +	    for (int i = 0; i < welcomeFiles.length; i++) {
  +		if (name.equals(welcomeFiles[i]))
   		    return (true);
   	    }
  -	    return (false);
   	}
  +	return (false);
   
       }
   
  @@ -1145,12 +1183,7 @@
        */
       public String[] findWelcomeFiles() {
   
  -	synchronized (welcomeFiles) {
  -	    String results[] = new String[welcomeFiles.size()];
  -	    for (int i = 0; i < results.length; i++)
  -		results[i] = (String) welcomeFiles.elementAt(i);
  -	    return (results);
  -	}
  +	return (welcomeFiles);
   
       }
   
  @@ -1311,12 +1344,35 @@
        * @param constraint Constraint to be removed
        */
       public void removeConstraint(SecurityConstraint constraint) {
  +
  +	synchronized (constraints) {
  +
  +	    // Make sure this constraint is currently present
  +	    int n = -1;
  +	    for (int i = 0; i < constraints.length; i++) {
  +		if (constraints[i].equals(constraint)) {
  +		    n = i;
  +		    break;
  +		}
  +	    }
  +	    if (n < 0)
  +		return;
   
  -	if (constraints.contains(constraint)) {
  -	    constraints.removeElement(constraint);
  -	    fireContainerEvent("removeConstraint", constraint);
  +	    // Remove the specified constraint
  +	    int j = 0;
  +	    SecurityConstraint results[] =
  +		new SecurityConstraint[constraints.length - 1];
  +	    for (int i = 0; i < constraints.length; i++) {
  +		if (i != n)
  +		    results[j++] = constraints[i];
  +	    }
  +	    constraints = results;
  +
   	}
   
  +	// Inform interested listeners
  +	fireContainerEvent("removeConstraint", constraint);
  +
       }
   
   
  @@ -1327,7 +1383,9 @@
        */
       public void removeEjb(String name) {
   
  -	ejbs.remove(name);
  +	synchronized (ejbs) {
  +	    ejbs.remove(name);
  +	}
   	fireContainerEvent("removeEjb", name);
   
       }
  @@ -1340,7 +1398,9 @@
        */
       public void removeEnvironment(String name) {
   
  -	envs.remove(name);
  +	synchronized (envs) {
  +	    envs.remove(name);
  +	}
   	fireContainerEvent("removeEnvironment", name);
   
       }
  @@ -1355,10 +1415,15 @@
       public void removeErrorPage(ErrorPage errorPage) {
   
   	String exceptionType = errorPage.getExceptionType();
  -	if (exceptionType != null)
  -	    exceptionPages.remove(exceptionType);
  -	else
  -	    statusPages.remove(new Integer(errorPage.getErrorCode()));
  +	if (exceptionType != null) {
  +	    synchronized (exceptionPages) {
  +		exceptionPages.remove(exceptionType);
  +	    }
  +	} else {
  +	    synchronized (statusPages) {
  +		statusPages.remove(new Integer(errorPage.getErrorCode()));
  +	    }
  +	}
   	fireContainerEvent("removeErrorPage", errorPage);
   
       }
  @@ -1372,7 +1437,9 @@
        */
       public void removeMimeMapping(String extension) {
   
  -	mimeMappings.remove(extension);
  +	synchronized (mimeMappings) {
  +	    mimeMappings.remove(extension);
  +	}
   	fireContainerEvent("removeMimeMapping", extension);
   
       }
  @@ -1386,7 +1453,9 @@
        */
       public void removeParameter(String name) {
   
  -	parameters.remove(name);
  +	synchronized (parameters) {
  +	    parameters.remove(name);
  +	}
   	fireContainerEvent("removeParameter", name);
   
       }
  @@ -1399,7 +1468,9 @@
        */
       public void removeResource(String name) {
   
  -	resources.remove(name);
  +	synchronized (resources) {
  +	    resources.remove(name);
  +	}
   	fireContainerEvent("removeResource", name);
   
       }
  @@ -1412,7 +1483,9 @@
        */
       public void removeRoleMapping(String role) {
   
  -	roleMappings.remove(role);
  +	synchronized (roleMappings) {
  +	    roleMappings.remove(role);
  +	}
   	fireContainerEvent("removeRoleMapping", role);
   
       }
  @@ -1424,8 +1497,32 @@
        * @param role Security role to remove
        */
       public void removeSecurityRole(String role) {
  +
  +	synchronized (securityRoles) {
  +
  +	    // Make sure this security role is currently present
  +	    int n = -1;
  +	    for (int i = 0; i < securityRoles.length; i++) {
  +		if (role.equals(securityRoles[i])) {
  +		    n = i;
  +		    break;
  +		}
  +	    }
  +	    if (n < 0)
  +		return;
  +
  +	    // Remove the specified security role
  +	    int j = 0;
  +	    String results[] = new String[securityRoles.length - 1];
  +	    for (int i = 0; i < securityRoles.length; i++) {
  +		if (i != n)
  +		    results[j++] = securityRoles[i];
  +	    }
  +	    securityRoles = results;
  +
  +	}
   
  -	securityRoles.remove(role);
  +	// Inform interested listeners
   	fireContainerEvent("removeSecurityRole", role);
   
       }
  @@ -1439,7 +1536,9 @@
        */
       public void removeServletMapping(String pattern) {
   
  -	servletMappings.remove(pattern);
  +	synchronized (servletMappings) {
  +	    servletMappings.remove(pattern);
  +	}
   	fireContainerEvent("removeServletMapping", pattern);
   
       }
  @@ -1452,7 +1551,9 @@
        */
       public void removeTaglib(String uri) {
   
  -	taglibs.remove(uri);
  +	synchronized (taglibs) {
  +	    taglibs.remove(uri);
  +	}
   	fireContainerEvent("removeTaglib", uri);
       }
   
  @@ -1464,8 +1565,32 @@
        * @param name Name of the welcome file to be removed
        */
       public void removeWelcomeFile(String name) {
  +
  +	synchronized (welcomeFiles) {
  +
  +	    // Make sure this welcome file is currently present
  +	    int n = -1;
  +	    for (int i = 0; i < welcomeFiles.length; i++) {
  +		if (welcomeFiles[i].equals(name)) {
  +		    n = i;
  +		    break;
  +		}
  +	    }
  +	    if (n < 0)
  +		return;
  +
  +	    // Remove the specified constraint
  +	    int j = 0;
  +	    String results[] = new String[welcomeFiles.length - 1];
  +	    for (int i = 0; i < welcomeFiles.length; i++) {
  +		if (i != n)
  +		    results[j++] = welcomeFiles[i];
  +	    }
  +	    welcomeFiles = results;
  +
  +	}
   
  -	welcomeFiles.removeElement(name);
  +	// Inform interested listeners
   	postWelcomeFiles();
   	fireContainerEvent("removeWelcomeFile", name);
   
  
  
  
  1.12      +24 -19    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java
  
  Index: StandardHost.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- StandardHost.java	2000/05/22 20:11:14	1.11
  +++ StandardHost.java	2000/07/29 05:20:41	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
1.11 2000/05/22 20:11:14 craigmcc Exp $
  - * $Revision: 1.11 $
  - * $Date: 2000/05/22 20:11:14 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/core/StandardHost.java,v
1.12 2000/07/29 05:20:41 craigmcc Exp $
  + * $Revision: 1.12 $
  + * $Date: 2000/07/29 05:20:41 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    * requests directed to a particular web application.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.11 $ $Date: 2000/05/22 20:11:14 $
  + * @version $Revision: 1.12 $ $Date: 2000/07/29 05:20:41 $
    */
   
   public final class StandardHost
  @@ -381,23 +381,28 @@
   
   	alias = alias.toLowerCase();
   
  -	// Make sure this alias is currently present
  -	int n = -1;
  -	for (int i = 0; i < aliases.length; i++) {
  -	    if (aliases[i].equals(alias)) {
  -		n = i;
  -		break;
  +	synchronized (aliases) {
  +
  +	    // Make sure this alias is currently present
  +	    int n = -1;
  +	    for (int i = 0; i < aliases.length; i++) {
  +		if (aliases[i].equals(alias)) {
  +		    n = i;
  +		    break;
  +		}
   	    }
  -	}
  -	if (n < 0)
  -	    return;
  +	    if (n < 0)
  +		return;
   
  -	// Remove the specified alias
  -	int j = 0;
  -	String newAliases[] = new String[aliases.length - 1];
  -	for (int i = 0; i < aliases.length; i++) {
  -	    if (i != n)
  -		newAliases[j++] = aliases[i];
  +	    // Remove the specified alias
  +	    int j = 0;
  +	    String results[] = new String[aliases.length - 1];
  +	    for (int i = 0; i < aliases.length; i++) {
  +		if (i != n)
  +		    results[j++] = aliases[i];
  +	    }
  +	    aliases = results;
  +
   	}
   
   	// Inform interested listeners
  
  
  
  1.13      +14 -14    jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DefaultServlet.java	2000/07/25 02:11:48	1.12
  +++ DefaultServlet.java	2000/07/29 05:20:43	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.12 2000/07/25 02:11:48 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2000/07/25 02:11:48 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/DefaultServlet.java,v
1.13 2000/07/29 05:20:43 craigmcc Exp $
  + * $Revision: 1.13 $
  + * $Date: 2000/07/29 05:20:43 $
    *
    * ====================================================================
    *
  @@ -104,7 +104,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.12 $ $Date: 2000/07/25 02:11:48 $
  + * @version $Revision: 1.13 $ $Date: 2000/07/29 05:20:43 $
    */
   
   public final class DefaultServlet
  @@ -156,7 +156,7 @@
       /**
        * The set of welcome files for this web application
        */
  -    private Vector welcomes = new Vector();
  +    private String welcomes[] = new String[0];
   
   
       /**
  @@ -308,17 +308,17 @@
   	    output = 256;
   
   	// Initialize the set of welcome files for this application
  -	welcomes = (Vector) getServletContext().getAttribute
  +	welcomes = (String[]) getServletContext().getAttribute
   	    ("org.apache.tomcat.WELCOME_FILES");
   	if (welcomes == null)
  -	    welcomes = new Vector();
  +	    welcomes = new String[0];
   
   	if (debug > 0) {
   	    log("DefaultServlet.init:  input buffer size=" + input +
   		", output buffer size=" + output);
  -	    for (int i = 0; i < welcomes.size(); i++)
  +	    for (int i = 0; i < welcomes.length; i++)
   		log("DefaultServlet.init:  welcome file=" +
  -		    welcomes.elementAt(i));
  +		    welcomes[i]);
   	}
   
           // Load the MD5 helper used to calculate signatures.
  @@ -628,15 +628,15 @@
   
   	// Serve a welcome resource or file if one exists
   	// FIXME - update the welcome files list?
  -	for (int i = 0; i < welcomes.size(); i++) {
  +	for (int i = 0; i < welcomes.length; i++) {
   	    
   	    // Does the specified resource exist?
  -	    File file = new File(directory, (String) welcomes.elementAt(i));
  +	    File file = new File(directory, (String) welcomes[i]);
   	    if (!file.exists() || !file.canRead() || !file.isFile())
   		continue;
   
   	    // Can we dispatch a request for this resource (i.e. JSP page)?
  -	    String resource = servletPath + (String) welcomes.elementAt(i);
  +	    String resource = servletPath + (String) welcomes[i];
   	    RequestDispatcher rd =
   		getServletContext().getRequestDispatcher(resource);
   	    if (rd != null) {
  @@ -873,10 +873,10 @@
               
               // Serve a welcome resource or file if one exists
               // FIXME - update the welcome files list?
  -            for (int i = 0; i < welcomes.size(); i++) {
  +            for (int i = 0; i < welcomes.length; i++) {
                   
                   // Does the specified resource exist?
  -                String fileName = pathname + welcomes.elementAt(i);
  +                String fileName = pathname + welcomes[i];
                   CacheEntry fileInfo = (CacheEntry) fileCache.get(fileName);
                   if ((fileInfo != null) && (fileInfo.isValid())) {
                       return fileInfo;
  
  
  

Mime
View raw message