yoavs       2004/08/31 07:41:48

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
               webapps/docs/config context.xml
  Log:
  - Made TLD processing optional (default is true for backward compatability and it's 
the more common case anyways).
  - Documented new processTlds context attribute as well as tldValidation and 
tldNamespaceAware context attributes.
  
  Revision  Changes    Path
  1.143     +59 -30    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java
  
  Index: StandardContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContext.java,v
  retrieving revision 1.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- StandardContext.java      29 Aug 2004 16:46:09 -0000      1.142
  +++ StandardContext.java      31 Aug 2004 14:41:47 -0000      1.143
  @@ -613,6 +613,10 @@
        */
        private boolean webXmlNamespaceAware = false;
   
  +    /**
  +     * Attribute value used to turn on/off TLD processing
  +     */
  +    private boolean processTlds = true;
   
       /**
        * Attribute value used to turn on/off XML validation
  @@ -4026,37 +4030,13 @@
   
                   // Start the Valves in our pipeline (including the basic),
                   // if any
  -                if (pipeline instanceof Lifecycle)
  +                if (pipeline instanceof Lifecycle) {
                       ((Lifecycle) pipeline).start();
  +             }
   
  -                // Read tldListeners. XXX Option to disable
  -                TldConfig tldConfig = new TldConfig();
  -                tldConfig.setContext(this);
  -
  -                // (1)  check if the attribute has been defined
  -                //      on the context element.
  -                tldConfig.setTldValidation(tldValidation);
  -                tldConfig.setTldNamespaceAware(tldNamespaceAware);
  -
  -                // (2) if the attribute wasn't defined on the context
  -                //     try the host.
  -                if (!tldValidation){
  -                    tldConfig.setTldValidation
  -                        (((StandardHost) getParent()).getXmlValidation());
  -                }
  -
  -                if (!tldNamespaceAware){
  -                    tldConfig.setTldNamespaceAware
  -                        (((StandardHost) getParent()).getXmlNamespaceAware());
  -                }
  -                    
  -                try {
  -                    tldConfig.execute();
  -                } catch (Exception ex) {
  -                    log.error("Error reading tld listeners " 
  -                              + ex.toString(), ex);
  -                    //ok=false;
  -                }
  +                if(getProcessTlds() {
  +                 processTlds();
  +             }
   
                   // Notify our interested LifecycleListeners
                   lifecycle.fireLifecycleEvent(START_EVENT, null);
  @@ -4173,6 +4153,40 @@
   
           //cacheContext();
       }
  +
  +    /**
  +     * Processes TLDs.
  +     *
  +     * @throws LifecycleException If an error occurs
  +     */
  +     protected void processTlds() throws LifecycleException {
  +       TldConfig tldConfig = new TldConfig();
  +       tldConfig.setContext(this);
  +
  +       // (1)  check if the attribute has been defined
  +       //      on the context element.
  +       tldConfig.setTldValidation(tldValidation);
  +       tldConfig.setTldNamespaceAware(tldNamespaceAware);
  +
  +       // (2) if the attribute wasn't defined on the context
  +       //     try the host.
  +       if (!tldValidation) {
  +         tldConfig.setTldValidation
  +           (((StandardHost) getParent()).getXmlValidation());
  +       }
  +
  +       if (!tldNamespaceAware) {
  +         tldConfig.setTldNamespaceAware
  +           (((StandardHost) getParent()).getXmlNamespaceAware());
  +       }
  +                    
  +       try {
  +         tldConfig.execute();
  +       } catch (Exception ex) {
  +         log.error("Error reading tld listeners " 
  +                    + ex.toString(), ex); 
  +       }
  +     }
       
       private void cacheContext() {
           try {
  @@ -5288,6 +5302,21 @@
           return tldValidation;
       }
   
  +    /**
  +     * Sets the process TLDs attribute.
  +     *
  +     * @param newProcessTlds The new value
  +     */
  +    public void setProcessTlds(boolean newProcessTlds) {
  +     processTlds = newProcessTlds;
  +    }
  +
  +    /**
  +     * Returns the processTlds attribute value.
  +     */
  +    public boolean getProcessTlds() {
  +     return processTlds;
  +    }
   
       /**
        * Get the server.xml <host> attribute's xmlNamespaceAware.
  
  
  
  1.12      +22 -0     jakarta-tomcat-catalina/webapps/docs/config/context.xml
  
  Index: context.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/config/context.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- context.xml       27 Aug 2004 14:10:22 -0000      1.11
  +++ context.xml       31 Aug 2004 14:41:48 -0000      1.12
  @@ -264,11 +264,33 @@
           </p>
         </attribute>
   
  +      <attribute name="processTlds" required="false">
  +        <p>Whether the context should process TLDs on startup.  The default
  +        is true.  The false setting is intended for special cases
  +        that know in advance TLDs are not part of the webapp.</p>
  +      </attribute>
  +
         <attribute name="swallowOutput" required="false">
           <p>If the value of this flag is <code>true</code>, the bytes output to
           System.out and System.err by the web application will be redirected to
           the web application logger. If not specified, the default value
           of the flag is <code>false</code>.</p>
  +      </attribute>
  +
  +      <attribute value="tldNamespaceAware" required="false">
  +        <p>If the value of this flag is <code>true</code>, the TLD files
  +        XML validation will be namespace-aware.  If you turn this flag on,
  +        you should probably also turn <code>tldValidation</code> on.  The
  +        default value for this flag is <code>false</code>, and setting it
  +        to true will incur a performance penalty.
  +        </p>
  +      </attribute>
  +
  +      <attribute value="tldValidation" required="false">
  +        <p>If the value of this flag is <code>true</code>, the TLD files
  +        will be XML validated on context startup.  The default value for
  +        this flag is <code>false</code>, and setting it to true will incur
  +        a performance penalty.</p>
         </attribute>
   
         <attribute name="unpackWAR" required="false">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to