You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by jf...@apache.org on 2003/03/05 22:42:22 UTC

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

jfarcand    2003/03/05 13:42:22

  Modified:    catalina/src/share/org/apache/catalina/startup
                        ContextConfig.java WebRuleSet.java
  Log:
  New Servlet 2.4 PDF 2 features:
  
  - remove web.xml extensibility support
  - add support for SRV.12.3:
  
  <quote>
  The sub elements under web-app can be in an arbitrary order in this version of the specification. Because of the restriction of XML Schema, The multiplicity of the elements distributable, session-config, welcome-file-list, jsp-config, login-config, and locale-encoding-mapping-list was changed from optional to 0 or more. The containers must inform the developer with a descriptive error message when the deployment descriptor contains more than one element of session-config, jsp-con-fig, and login-config. The container must concatenate the items in welcome-file-list and locale-encoding-mapping-list when there are multiple occurrences. The multiple occurrence of distributable must be treated exactly in the same way as the single occurrence of distributable.
  </quote>
  
  Revision  Changes    Path
  1.19      +12 -2     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java
  
  Index: ContextConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ContextConfig.java	29 Jan 2003 23:02:38 -0000	1.18
  +++ ContextConfig.java	5 Mar 2003 21:42:22 -0000	1.19
  @@ -196,6 +196,12 @@
        * deployment descriptor files.
        */
       private static Digester webDigester = null;
  +    
  +    
  +    /**
  +     * The <code>Rule</code> used to parse the web.xml
  +     */
  +    private static WebRuleSet webRuleSet = new WebRuleSet();
   
       /**
        * Attribute value used to turn on/off XML validation
  @@ -352,6 +358,8 @@
                   }
               }
           }
  +        webRuleSet.recycle();
  +
           long t2=System.currentTimeMillis();
           if( (t2-t1 ) > 200 ) 
               log.debug("Processed  " + url + " "  + ( t2-t1));
  @@ -619,7 +627,7 @@
           webEntityResolver = registerLocalSchema(webEntityResolver);
   
           webDigester.setEntityResolver(webEntityResolver);
  -        webDigester.addRuleSet(new WebRuleSet());
  +        webDigester.addRuleSet(webRuleSet);
           return (webDigester);
       }
   
  @@ -686,6 +694,8 @@
                   }
               }
           }
  +        webRuleSet.recycle();
  +        
           long t2=System.currentTimeMillis();
           if( (t2-t1) > 200 )
               log.debug("Processed default web.xml " + file + " "  + ( t2-t1));
  
  
  
  1.8       +93 -27    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/WebRuleSet.java
  
  Index: WebRuleSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/WebRuleSet.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebRuleSet.java	23 Aug 2002 14:54:48 -0000	1.7
  +++ WebRuleSet.java	5 Mar 2003 21:42:22 -0000	1.8
  @@ -91,6 +91,24 @@
        * The matching pattern prefix to use for recognizing our elements.
        */
       protected String prefix = null;
  +    
  +    
  +    /**
  +     * The <code>SetSessionConfig</code> rule used to parse the web.xml
  +     */
  +    protected SetSessionConfig sessionConfig;
  +    
  +    
  +    /**
  +     * The <code>SetLoginConfig</code> rule used to parse the web.xml
  +     */
  +    protected SetLoginConfig loginConfig;
  +
  +    
  +    /**
  +     * The <code>SetJspConfig</code> rule used to parse the web.xml
  +     */    
  +    protected SetJspConfig jspConfig;
   
   
       // ------------------------------------------------------------ Constructor
  @@ -136,7 +154,10 @@
        *  should be added.
        */
       public void addRuleInstances(Digester digester) {
  -
  +        sessionConfig = new SetSessionConfig(digester);
  +        jspConfig = new SetJspConfig(digester);
  +        loginConfig = new SetLoginConfig(digester);
  +        
           digester.addRule(prefix + "web-app",
                            new SetPublicIdRule(digester, "setPublicId"));
   
  @@ -145,9 +166,6 @@
           digester.addCallParam(prefix + "web-app/context-param/param-name", 0);
           digester.addCallParam(prefix + "web-app/context-param/param-value", 1);
   
  -        digester.addRule(prefix + "web-app/deployment-extension",
  -                         new CheckDeploymentExtensionRule(digester));
  -
           digester.addCallMethod(prefix + "web-app/display-name",
                                  "setDisplayName", 0);
   
  @@ -264,12 +282,18 @@
   
            digester.addCallMethod(prefix + "web-app/listener/listener-class",
                                   "addApplicationListener", 0);
  -
  +         
  +        digester.addRule(prefix + "web-app/jsp-config",
  +                         jspConfig);
  +        
           digester.addCallMethod(prefix + "web-app/jsp-config/jsp-property-group/url-pattern",
                                  "addJspMapping", 0);
   
           digester.addCallMethod(prefix + "web-app/listener/listener-class",
                                  "addApplicationListener", 0);
  +        
  +        digester.addRule(prefix + "web-app/login-config",
  +                         loginConfig);
   
           digester.addObjectCreate(prefix + "web-app/login-config",
                                    "org.apache.catalina.deploy.LoginConfig");
  @@ -383,9 +407,6 @@
                               "addChild",
                               "org.apache.catalina.Container");
   
  -        digester.addRule(prefix + "web-app/servlet/deployment-extension",
  -                         new CheckDeploymentExtensionRule(digester));
  -
           digester.addCallMethod(prefix + "web-app/servlet/init-param",
                                  "addInitParameter", 2);
           digester.addCallParam(prefix + "web-app/servlet/init-param/param-name",
  @@ -415,6 +436,9 @@
           digester.addCallParam(prefix + "web-app/servlet-mapping/servlet-name", 1);
           digester.addCallParam(prefix + "web-app/servlet-mapping/url-pattern", 0);
   
  +        digester.addRule(prefix + "web-app/session-config",
  +                         sessionConfig);
  +        
           digester.addCallMethod(prefix + "web-app/session-config/session-timeout",
                                  "setSessionTimeout", 1,
                                  new Class[] { Integer.TYPE });
  @@ -435,39 +459,81 @@
   
       }
   
  -
  +    /**
  +     * Reset counter used for validating the web.xml file.
  +     */
  +    public void recycle(){
  +        jspConfig.isJspConfigSet = false;
  +        sessionConfig.isSessionConfigSet = false;
  +        loginConfig.isLoginConfigSet = false;
  +    }
   }
   
   
   // ----------------------------------------------------------- Private Classes
   
  +
   /**
  - * A Rule that checks mustUnderstand attribute.  It throws an Exception if
  - * mustUnderstand attribute is true since stand-alone Tomcat currently does
  - * not have a way of recognizing an extension within a deployment descriptor.
  + * Rule to check that the <code>login-config</code> is occuring 
  + * only 1 time within the web.xml
    */
  +final class SetLoginConfig extends Rule {
  +    protected boolean isLoginConfigSet = false;
  +    public SetLoginConfig(Digester digester) {
  +        super(digester);
  +    }
   
  -final class CheckDeploymentExtensionRule extends Rule {
  +    public void begin(Attributes attributes) throws Exception {
  +        if (isLoginConfigSet){
  +            throw new IllegalArgumentException(
  +            "<login-config> element is limited to 1 occurance");
  +        }
  +        isLoginConfigSet = true;
  +    }
  +
  +}
   
  -    public CheckDeploymentExtensionRule(Digester digester) {
  +
  +/**
  + * Rule to check that the <code>jsp-config</code> is occuring 
  + * only 1 time within the web.xml
  + */
  +final class SetJspConfig extends Rule {
  +    protected boolean isJspConfigSet = false;
  +    public SetJspConfig(Digester digester) {
           super(digester);
       }
   
       public void begin(Attributes attributes) throws Exception {
  -        String mustUnderstand = attributes.getValue("mustUnderstand");
  -        if ((mustUnderstand != null) && (mustUnderstand.equals("true"))) {
  -            String namespace = attributes.getValue("namespace");
  -            if (digester.getDebug() > 0) {
  -                digester.log("Exception thrown CheckDeploymentExtensionRule");
  -            }
  -            throw new Exception("deployment-extension "+namespace+
  -            " attribute mustUnderstand is set to true");
  +        if (isJspConfigSet){
  +            throw new IllegalArgumentException(
  +            "<jsp-config> element is limited to 1 occurance");
           }
  -
  +        isJspConfigSet = true;
       }
   
   }
   
  +
  +/**
  + * Rule to check that the <code>jsp-config</code> is occuring 
  + * only 1 time within the web.xml
  + */
  +final class SetSessionConfig extends Rule {
  +    protected boolean isSessionConfigSet = false;
  +    public SetSessionConfig(Digester digester) {
  +        super(digester);
  +    }
  +
  +    public void begin(Attributes attributes) throws Exception {
  +        if (isSessionConfigSet){
  +            throw new IllegalArgumentException(
  +            "<session-config> element is limited to 1 occurance");
  +        }
  +        isSessionConfigSet = true;
  +    }
  +
  +}
   
   /**
    * A Rule that calls the <code>setAuthConstraint(true)</code> method of
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org