tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfarc...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup TldConfig.java
Date Tue, 12 Aug 2003 16:15:52 GMT
jfarcand    2003/08/12 09:15:52

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardContext.java
               catalina/src/share/org/apache/catalina/startup
                        TldConfig.java
  Log:
  Add support for Tld validation (also fix bug 21917: TldConfig.java does not set SystemId).
Validation only works with Crimson right now.
  
  Revision  Changes    Path
  1.83      +3 -1      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.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- StandardContext.java	10 Aug 2003 09:47:33 -0000	1.82
  +++ StandardContext.java	12 Aug 2003 16:15:52 -0000	1.83
  @@ -3956,6 +3956,8 @@
                   // Read tldListeners. XXX Option to disable
                   TldConfig tldConfig = new TldConfig();
                   tldConfig.setContext(this);
  +                tldConfig.setXmlValidation(((StandardHost) getParent()).getXmlValidation());
  +                tldConfig.setXmlNamespaceAware(((StandardHost) getParent()).getXmlNamespaceAware());
                   try {
                       tldConfig.execute();
                   } catch (Exception ex) {
  
  
  
  1.15      +52 -28    jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/TldConfig.java
  
  Index: TldConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/TldConfig.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TldConfig.java	28 Jul 2003 22:57:41 -0000	1.14
  +++ TldConfig.java	12 Aug 2003 16:15:52 -0000	1.15
  @@ -94,7 +94,7 @@
   import org.apache.commons.digester.Digester;
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
  -
  +import org.xml.sax.InputSource;
   /**
    * Startup event listener for a <b>Context</b> that configures the properties
    * of that Context, and the associated defined servlets.
  @@ -149,6 +149,44 @@
   
       // --------------------------------------------------------- Public Methods
   
  +     /**
  +     * Set the validation feature of the XML parser used when
  +     * parsing xml instances.
  +     * @param xmlValidation true to enable xml instance validation
  +     */
  +    public void setXmlValidation(boolean xmlValidation){
  +        this.xmlValidation = xmlValidation;
  +    }
  +
  +    /**
  +     * Get the server.xml <host> attribute's xmlValidation.
  +     * @return true if validation is enabled.
  +     *
  +     */
  +    public boolean getXmlValidation(){
  +        return xmlValidation;
  +    }
  +
  +    /**
  +     * Get the server.xml <host> attribute's xmlNamespaceAware.
  +     * @return true if namespace awarenes is enabled.
  +     *
  +     */
  +    public boolean getXmlNamespaceAware(){
  +        return xmlNamespaceAware;
  +    }
  +
  +
  +    /**
  +     * Set the namespace aware feature of the XML parser used when
  +     * parsing xml instances.
  +     * @param xmlNamespaceAware true to enable namespace awareness
  +     */
  +    public void setXmlNamespaceAware(boolean xmlNamespaceAware){
  +        this.xmlNamespaceAware=xmlNamespaceAware;
  +    }    
  +
  +
       public boolean isRescan() {
           return rescan;
       }
  @@ -177,6 +215,7 @@
           return result;
       }
   
  +
       /**
        * Scan for and configure all tag library descriptors found in this
        * web application.
  @@ -458,7 +497,7 @@
   
           JarFile jarFile = null;
           String name = null;
  -        InputStream inputStream = null;
  +        InputSource inputSource = null;
   
           String jarPath = file.getAbsolutePath();
   
  @@ -477,10 +516,9 @@
                   if (log.isTraceEnabled()) {
                       log.trace("  Processing TLD at '" + name + "'");
                   }
  -                inputStream = jarFile.getInputStream(entry);
  -                tldScanStream(inputStream);
  -                inputStream.close();
  -                inputStream = null;
  +                inputSource = new InputSource(jarFile.getInputStream(entry));
  +                tldScanStream(inputSource);
  +                inputSource = null;
                   name = null;
               }
           } catch (Exception e) {
  @@ -494,13 +532,6 @@
                             e);
               }
           } finally {
  -            if (inputStream != null) {
  -                try {
  -                    inputStream.close();
  -                } catch (Throwable t) {
  -                    // Ignore
  -                }
  -            }
               if (jarFile != null) {
                   try {
                       jarFile.close();
  @@ -521,7 +552,7 @@
        *
        * @exception Exception if an exception occurs while scanning this TLD
        */
  -    private void tldScanStream(InputStream resourceStream)
  +    private void tldScanStream(InputSource resourceStream)
           throws Exception {
   
           if (tldDigester == null){
  @@ -554,30 +585,23 @@
               log.debug(" Scanning TLD at resource path '" + resourcePath + "'");
           }
   
  -        InputStream inputStream = null;
  +        InputSource inputSource = null;
           try {
  -            inputStream =
  -                context.getServletContext().getResourceAsStream(resourcePath);
  -            if (inputStream == null) {
  +            inputSource =
  +                new InputSource(
  +                    context.getServletContext().getResourceAsStream(resourcePath));
  +            if (inputSource == null) {
                   throw new IllegalArgumentException
                       (sm.getString("contextConfig.tldResourcePath",
                                     resourcePath));
               }
  -            tldScanStream(inputStream);
  +            tldScanStream(inputSource);
           } catch (Exception e) {
                throw new ServletException
                    (sm.getString("contextConfig.tldFileException", resourcePath,
                                  context.getPath()),
                     e);
  -        } finally {
  -            if (inputStream != null) {
  -                try {
  -                    inputStream.close();
  -                } catch (Throwable t) {
  -                    // Ignore
  -                }
  -            }
  -        }
  +        } 
   
       }
   
  
  
  

Mime
View raw message