You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2001/09/04 20:15:31 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup ContextConfig.java

craigmcc    01/09/04 11:15:31

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
               catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java
  Log:
  When an application's deployment descriptor file specifies one or more
  <welcome-file> elements, *replace* any existing list defined in the
  default "conf/web.xml" file, rather than appending to it.
  
  PR: Bugzilla #3082
  Submitted by:	Michael Rimov <ri...@centercomp.com>
  
  Revision  Changes    Path
  1.75      +46 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- StandardContext.java	2001/08/27 19:10:25	1.74
  +++ StandardContext.java	2001/09/04 18:15:30	1.75
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v 1.74 2001/08/27 19:10:25 craigmcc Exp $
  - * $Revision: 1.74 $
  - * $Date: 2001/08/27 19:10:25 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardContext.java,v 1.75 2001/09/04 18:15:30 craigmcc Exp $
  + * $Revision: 1.75 $
  + * $Date: 2001/09/04 18:15:30 $
    *
    * ====================================================================
    *
  @@ -142,7 +142,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.74 $ $Date: 2001/08/27 19:10:25 $
  + * @version $Revision: 1.75 $ $Date: 2001/09/04 18:15:30 $
    */
   
   public class StandardContext
  @@ -378,6 +378,16 @@
   
   
       /**
  +     * Should the next call to <code>addWelcomeFile()</code> cause replacement
  +     * of any existing welcome files?  This will be set before processing the
  +     * web application's deployment descriptor, so that application specified
  +     * choices <strong>replace</strong>, rather than append to, those defined in
  +     * the global descriptor.
  +     */
  +    private boolean replaceWelcomeFiles = false;
  +
  +
  +    /**
        * The resource environment references for this web application,
        * keyed by name.
        */
  @@ -973,6 +983,32 @@
   
   
       /**
  +     * Return the "replace welcome files" property.
  +     */
  +    public boolean isReplaceWelcomeFiles() {
  +
  +        return (this.replaceWelcomeFiles);
  +
  +    }
  +
  +
  +    /**
  +     * Set the "replace welcome files" property.
  +     *
  +     * @param replaceWelcomeFiles The new property value
  +     */
  +    public void setReplaceWelcomeFiles(boolean replaceWelcomeFiles) {
  +
  +        boolean oldReplaceWelcomeFiles = this.replaceWelcomeFiles;
  +        this.replaceWelcomeFiles = replaceWelcomeFiles;
  +        support.firePropertyChange("replaceWelcomeFiles",
  +                                   new Boolean(oldReplaceWelcomeFiles),
  +                                   new Boolean(this.replaceWelcomeFiles));
  +
  +    }
  +
  +
  +    /**
        * Return the servlet context for which this Context is a facade.
        */
       public synchronized ServletContext getServletContext() {
  @@ -1638,6 +1674,12 @@
       public void addWelcomeFile(String name) {
   
           synchronized (welcomeFiles) {
  +            // Welcome files from the application deployment descriptor
  +            // completely replace those from the default conf/web.xml file
  +            if (replaceWelcomeFiles) {
  +                welcomeFiles = new String[0];
  +                setReplaceWelcomeFiles(false);
  +            }
               String results[] =new String[welcomeFiles.length + 1];
               for (int i = 0; i < welcomeFiles.length; i++)
                   results[i] = welcomeFiles[i];
  
  
  
  1.52      +8 -4      jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- ContextConfig.java	2001/08/27 19:10:25	1.51
  +++ ContextConfig.java	2001/09/04 18:15:30	1.52
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.51 2001/08/27 19:10:25 craigmcc Exp $
  - * $Revision: 1.51 $
  - * $Date: 2001/08/27 19:10:25 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.52 2001/09/04 18:15:30 craigmcc Exp $
  + * $Revision: 1.52 $
  + * $Date: 2001/09/04 18:15:30 $
    *
    * ====================================================================
    *
  @@ -128,7 +128,7 @@
    * of that Context, and the associated defined servlets.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.51 $ $Date: 2001/08/27 19:10:25 $
  + * @version $Revision: 1.52 $ $Date: 2001/09/04 18:15:30 $
    */
   
   public final class ContextConfig
  @@ -251,6 +251,8 @@
   
           // Process the application web.xml file
           try {
  +            if (context instanceof StandardContext)
  +                ((StandardContext) context).setReplaceWelcomeFiles(true);
               mapper.readXml(stream, context);
           } catch (InvocationTargetException e) {
               log(sm.getString("contextConfig.applicationConfig"),
  @@ -724,6 +726,8 @@
   
           // Process the default web.xml file
           try {
  +            if (context instanceof StandardContext)
  +                ((StandardContext) context).setReplaceWelcomeFiles(true);
               mapper.readXml(stream, context);
           } catch (InvocationTargetException e) {
               log(sm.getString("contextConfig.defaultConfig"),