You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/09 16:10:05 UTC

svn commit: r1501280 - in /tomcat/trunk/java/org/apache: catalina/startup/ tomcat/util/descriptor/ tomcat/util/descriptor/web/

Author: markt
Date: Tue Jul  9 14:10:04 2013
New Revision: 1501280

URL: http://svn.apache.org/r1501280
Log:
Refactor WebXml parsing to new package.
Based on a patch by violetagg.

Added:
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/Constants.java   (with props)
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings_es.properties
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java
      - copied, changed from r1501133, tomcat/trunk/java/org/apache/catalina/startup/XmlErrorHandler.java
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java   (with props)
Removed:
    tomcat/trunk/java/org/apache/catalina/startup/XmlErrorHandler.java
Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/startup/LocalStrings_es.properties
    tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties
    tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings_es.properties

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1501280&r1=1501279&r2=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Tue Jul  9 14:10:04 2013
@@ -87,7 +87,7 @@ import org.apache.tomcat.util.bcel.class
 import org.apache.tomcat.util.bcel.classfile.ElementValue;
 import org.apache.tomcat.util.bcel.classfile.ElementValuePair;
 import org.apache.tomcat.util.bcel.classfile.JavaClass;
-import org.apache.tomcat.util.descriptor.DigesterFactory;
+import org.apache.tomcat.util.descriptor.XmlErrorHandler;
 import org.apache.tomcat.util.descriptor.web.ApplicationListener;
 import org.apache.tomcat.util.descriptor.web.ContextEjb;
 import org.apache.tomcat.util.descriptor.web.ContextEnvironment;
@@ -106,8 +106,8 @@ import org.apache.tomcat.util.descriptor
 import org.apache.tomcat.util.descriptor.web.SecurityRoleRef;
 import org.apache.tomcat.util.descriptor.web.ServletDef;
 import org.apache.tomcat.util.descriptor.web.SessionConfig;
-import org.apache.tomcat.util.descriptor.web.WebRuleSet;
 import org.apache.tomcat.util.descriptor.web.WebXml;
+import org.apache.tomcat.util.descriptor.web.WebXmlParser;
 import org.apache.tomcat.util.digester.Digester;
 import org.apache.tomcat.util.digester.RuleSet;
 import org.apache.tomcat.util.res.StringManager;
@@ -252,20 +252,7 @@ public class ContextConfig implements Li
      */
     protected boolean handlesTypesNonAnnotations = false;
 
-    /**
-     * The <code>Digester</code> we will use to process web application
-     * deployment descriptor files.
-     */
-    protected Digester webDigester = null;
-    protected WebRuleSet webRuleSet = null;
-
-    /**
-     * The <code>Digester</code> we will use to process web fragment
-     * deployment descriptor files.
-     */
-    protected Digester webFragmentDigester = null;
-    protected WebRuleSet webFragmentRuleSet = null;
-
+    private WebXmlParser webXmlParser;
 
     // ------------------------------------------------------------- Properties
     /**
@@ -457,25 +444,6 @@ public class ContextConfig implements Li
 
 
     /**
-     * Create and return a Digester configured to process the
-     * web application deployment descriptor (web.xml).
-     */
-    public void createWebXmlDigester(boolean namespaceAware,
-            boolean validation) {
-
-        webRuleSet = new WebRuleSet(false);
-        webDigester = DigesterFactory.newDigester(validation,
-                namespaceAware, webRuleSet);
-        webDigester.getParser();
-
-        webFragmentRuleSet = new WebRuleSet(true);
-        webFragmentDigester = DigesterFactory.newDigester(validation,
-                namespaceAware, webFragmentRuleSet);
-        webFragmentDigester.getParser();
-    }
-
-
-    /**
      * Create (if necessary) and return a Digester configured to process the
      * context configuration descriptor for an application.
      */
@@ -771,7 +739,7 @@ public class ContextConfig implements Li
 
         contextConfig(contextDigester);
 
-        createWebXmlDigester(context.getXmlNamespaceAware(),
+        webXmlParser = new WebXmlParser(context.getXmlNamespaceAware(),
                 context.getXmlValidation());
     }
 
@@ -1145,7 +1113,9 @@ public class ContextConfig implements Li
 
         // Parse context level web.xml
         InputSource contextWebXml = getContextWebXmlSource();
-        parseWebXml(contextWebXml, webXml, false);
+        if (!webXmlParser.parseWebXml(contextWebXml, webXml, false)) {
+            ok = false;
+        }
 
         ServletContext sContext = context.getServletContext();
 
@@ -1559,14 +1529,20 @@ public class ContextConfig implements Li
                 // This is unusual enough to log
                 log.info(sm.getString("contextConfig.defaultMissing"));
             } else {
-                parseWebXml(globalWebXml, webXmlDefaultFragment, false);
+                if (!webXmlParser.parseWebXml(
+                        globalWebXml, webXmlDefaultFragment, false)) {
+                    ok = false;
+                }
             }
 
             // Parse host level web.xml if present
             // Additive apart from welcome pages
             webXmlDefaultFragment.setReplaceWelcomeFiles(true);
 
-            parseWebXml(hostWebXml, webXmlDefaultFragment, false);
+            if (!webXmlParser.parseWebXml(
+                    hostWebXml, webXmlDefaultFragment, false)) {
+                ok = false;
+            }
 
             // Don't update the cache if an error occurs
             if (globalTimeStamp != -1 && hostTimeStamp != -1) {
@@ -1962,79 +1938,6 @@ public class ContextConfig implements Li
 
 
     /**
-     * Parses the given source and stores the parsed data in the given web.xml
-     * representation. The byte stream will be closed at the end of the parse
-     * operation.
-     *
-     * @param source Input source containing the XML data to be parsed
-     * @param dest The object representation of common elements of web.xml and
-     *             web-fragment.xml
-     * @param fragment Specifies whether the source is web-fragment.xml or
-     *                 web.xml
-     */
-    protected void parseWebXml(InputSource source, WebXml dest,
-            boolean fragment) {
-
-        if (source == null) {
-            return;
-        }
-
-        XmlErrorHandler handler = new XmlErrorHandler();
-
-        Digester digester;
-        WebRuleSet ruleSet;
-        if (fragment) {
-            digester = webFragmentDigester;
-            ruleSet = webFragmentRuleSet;
-        } else {
-            digester = webDigester;
-            ruleSet = webRuleSet;
-        }
-
-        digester.push(dest);
-        digester.setErrorHandler(handler);
-
-        if(log.isDebugEnabled()) {
-            log.debug(sm.getString("contextConfig.applicationStart",
-                    source.getSystemId()));
-        }
-
-        try {
-            digester.parse(source);
-
-            if (handler.getWarnings().size() > 0 ||
-                    handler.getErrors().size() > 0) {
-                ok = false;
-                handler.logFindings(log, source.getSystemId());
-            }
-        } catch (SAXParseException e) {
-            log.error(sm.getString("contextConfig.applicationParse",
-                    source.getSystemId()), e);
-            log.error(sm.getString("contextConfig.applicationPosition",
-                             "" + e.getLineNumber(),
-                             "" + e.getColumnNumber()));
-            ok = false;
-        } catch (Exception e) {
-            log.error(sm.getString("contextConfig.applicationParse",
-                    source.getSystemId()), e);
-            ok = false;
-        } finally {
-            digester.reset();
-            ruleSet.recycle();
-
-            InputStream is = source.getByteStream();
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (Throwable t) {
-                    ExceptionUtils.handleThrowable(t);
-                }
-            }
-        }
-    }
-
-
-    /**
      * Scan /WEB-INF/lib for JARs and for each one found add it and any
      * /META-INF/web-fragment.xml to the resulting Map. web-fragment.xml files
      * will be parsed before being added to the map. Every JAR will be added and
@@ -2783,7 +2686,9 @@ public class ContextConfig implements Li
                     InputSource source = new InputSource(
                             resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
                     source.setByteStream(is);
-                    parseWebXml(source, fragment, true);
+                    if (!webXmlParser.parseWebXml(source, fragment, true)) {
+                        ok = false;
+                    }
                 }
             } finally {
                 if (jar != null) {
@@ -2822,7 +2727,9 @@ public class ContextConfig implements Li
                     InputSource source =
                         new InputSource(fragmentFile.toURI().toURL().toString());
                     source.setByteStream(stream);
-                    parseWebXml(source, fragment, true);
+                    if (!webXmlParser.parseWebXml(source, fragment, true)) {
+                        ok = false;
+                    }
                 } else {
                     // If there is no web.xml, normal folder no impact on
                     // distributable

Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties?rev=1501280&r1=1501279&r2=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties Tue Jul  9 14:10:04 2013
@@ -130,5 +130,3 @@ userConfig.start=UserConfig: Processing 
 userConfig.stop=UserConfig: Processing STOP
 userConfig.deploy.threaded.error=Error waiting for multi-thread deployment of user directories to complete
 webAnnotationSet.invalidInjection=Invalid method resource injection annotation.
-xmlErrorHandler.error=Non-fatal error [{0}] reported processing [{1}].
-xmlErrorHandler.warning=Warning [{0}] reported processing [{1}].

Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings_es.properties?rev=1501280&r1=1501279&r2=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings_es.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings_es.properties Tue Jul  9 14:10:04 2013
@@ -106,7 +106,3 @@ userConfig.deploying = Desplegando aplic
 userConfig.error = Error durante el despliegue de la aplicaci\u00F3n web para el usario {0}
 userConfig.start = "UserConfig"\: Tratamiento del "START"
 userConfig.stop = "UserConfig"\: Tratamiento del "STOP"
-webRuleSet.absoluteOrdering = Elemento <absolute-ordering> no v\u00E1lido en web-fragment.xml y ser\u00E1 ignorado
-webRuleSet.relativeOrdering = elemento <ordering> no v\u00E1lido en web.xml y ser\u00E1 ignorado
-xmlErrorHandler.error = Error no fatal [{0}] reportado por el proceso [{1}].
-xmlErrorHandler.warning = Aviso [{0}] reportado por el proceso [{1}].

Modified: tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=1501280&r1=1501279&r2=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java Tue Jul  9 14:10:04 2013
@@ -40,6 +40,7 @@ import org.apache.tomcat.JarScanner;
 import org.apache.tomcat.JarScannerCallback;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.descriptor.DigesterFactory;
+import org.apache.tomcat.util.descriptor.XmlErrorHandler;
 import org.apache.tomcat.util.descriptor.web.ApplicationListener;
 import org.apache.tomcat.util.digester.Digester;
 import org.apache.tomcat.util.res.StringManager;

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/Constants.java?rev=1501280&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/Constants.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/Constants.java Tue Jul  9 14:10:04 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor;
+
+public class Constants {
+
+    public static final String PACKAGE_NAME =
+            Constants.class.getPackage().getName();
+
+}

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/Constants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties?rev=1501280&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings.properties Tue Jul  9 14:10:04 2013
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+xmlErrorHandler.error=Non-fatal error [{0}] reported processing [{1}].
+xmlErrorHandler.warning=Warning [{0}] reported processing [{1}].

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings_es.properties?rev=1501280&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings_es.properties (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/LocalStrings_es.properties Tue Jul  9 14:10:04 2013
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+xmlErrorHandler.error = Error no fatal [{0}] reportado por el proceso [{1}].
+xmlErrorHandler.warning = Aviso [{0}] reportado por el proceso [{1}].

Copied: tomcat/trunk/java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java (from r1501133, tomcat/trunk/java/org/apache/catalina/startup/XmlErrorHandler.java)
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java?p2=tomcat/trunk/java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java&p1=tomcat/trunk/java/org/apache/catalina/startup/XmlErrorHandler.java&r1=1501133&r2=1501280&rev=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/XmlErrorHandler.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/XmlErrorHandler.java Tue Jul  9 14:10:04 2013
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.catalina.startup;
+package org.apache.tomcat.util.descriptor;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -28,7 +28,7 @@ import org.xml.sax.SAXParseException;
 public class XmlErrorHandler implements ErrorHandler {
 
     private static final StringManager sm =
-        StringManager.getManager(Constants.Package);
+        StringManager.getManager(Constants.PACKAGE_NAME);
 
     private final Set<SAXParseException> errors = new HashSet<>();
 

Modified: tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties?rev=1501280&r1=1501279&r2=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings.properties Tue Jul  9 14:10:04 2013
@@ -57,4 +57,8 @@ webXml.mergeConflictString=The [{0}] wit
 webXml.multipleOther=Multiple others entries in ordering
 webXml.unrecognisedPublicId=The public ID [{0}] did not match any of the known public ID's for web.xml files so the version could not be identified
 webXml.version.unknown=Unknown version string [{0}]. Default version will be used.
-webXml.wrongFragmentName=Used a wrong fragment name {0} at web.xml absolute-ordering tag!
\ No newline at end of file
+webXml.wrongFragmentName=Used a wrong fragment name {0} at web.xml absolute-ordering tag!
+
+webXmlParser.applicationParse=Parse error in application web.xml file at {0}
+webXmlParser.applicationPosition=Occurred at line {0} column {1}
+webXmlParser.applicationStart=Parsing application web.xml file at {0}

Modified: tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings_es.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings_es.properties?rev=1501280&r1=1501279&r2=1501280&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings_es.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/LocalStrings_es.properties Tue Jul  9 14:10:04 2013
@@ -15,3 +15,7 @@
 
 webRuleSet.absoluteOrdering = Elemento <absolute-ordering> no v\u00E1lido en web-fragment.xml y ser\u00E1 ignorado
 webRuleSet.relativeOrdering = elemento <ordering> no v\u00E1lido en web.xml y ser\u00E1 ignorado
+
+webXmlParser.applicationParse = Error de evaluaci\u00F3n (parse) en el archivo web.xml de la aplicaci\u00F3n a {0}
+webXmlParser.applicationPosition = Se ha producido en la l\u00EDnea {0} columna {1}
+webXmlParser.applicationStart = Analizando fichero de aplicaci\u00F3n web.xml en {0}

Added: tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java?rev=1501280&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java Tue Jul  9 14:10:04 2013
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util.descriptor.web;
+
+import java.io.InputStream;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.descriptor.DigesterFactory;
+import org.apache.tomcat.util.descriptor.XmlErrorHandler;
+import org.apache.tomcat.util.digester.Digester;
+import org.apache.tomcat.util.res.StringManager;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXParseException;
+
+public class WebXmlParser {
+
+    private static final Log log = LogFactory.getLog( WebXmlParser.class );
+
+    /**
+     * The string resources for this package.
+     */
+    private static final StringManager sm =
+        StringManager.getManager(Constants.PACKAGE_NAME);
+
+    /**
+     * The <code>Digester</code> we will use to process web application
+     * deployment descriptor files.
+     */
+    private final Digester webDigester;
+    private final WebRuleSet webRuleSet;
+
+    /**
+     * The <code>Digester</code> we will use to process web fragment
+     * deployment descriptor files.
+     */
+    private final Digester webFragmentDigester;
+    private final WebRuleSet webFragmentRuleSet;
+
+
+    public WebXmlParser(boolean namespaceAware, boolean validation) {
+        webRuleSet = new WebRuleSet(false);
+        webDigester = DigesterFactory.newDigester(validation,
+                namespaceAware, webRuleSet);
+        webDigester.getParser();
+
+        webFragmentRuleSet = new WebRuleSet(true);
+        webFragmentDigester = DigesterFactory.newDigester(validation,
+                namespaceAware, webFragmentRuleSet);
+        webFragmentDigester.getParser();
+    }
+
+
+    public boolean parseWebXml(InputSource source, WebXml dest,
+            boolean fragment) {
+
+        boolean ok = true;
+
+        if (source == null) {
+            return ok;
+        }
+
+        XmlErrorHandler handler = new XmlErrorHandler();
+
+        Digester digester;
+        WebRuleSet ruleSet;
+        if (fragment) {
+            digester = webFragmentDigester;
+            ruleSet = webFragmentRuleSet;
+        } else {
+            digester = webDigester;
+            ruleSet = webRuleSet;
+        }
+
+        digester.push(dest);
+        digester.setErrorHandler(handler);
+
+        if(log.isDebugEnabled()) {
+            log.debug(sm.getString("webXmlParser.applicationStart",
+                    source.getSystemId()));
+        }
+
+        try {
+            digester.parse(source);
+
+            if (handler.getWarnings().size() > 0 ||
+                    handler.getErrors().size() > 0) {
+                ok = false;
+                handler.logFindings(log, source.getSystemId());
+            }
+        } catch (SAXParseException e) {
+            log.error(sm.getString("webXmlParser.applicationParse",
+                    source.getSystemId()), e);
+            log.error(sm.getString("webXmlParser.applicationPosition",
+                             "" + e.getLineNumber(),
+                             "" + e.getColumnNumber()));
+            ok = false;
+        } catch (Exception e) {
+            log.error(sm.getString("webXmlParser.applicationParse",
+                    source.getSystemId()), e);
+            ok = false;
+        } finally {
+            InputStream is = source.getByteStream();
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                }
+            }
+
+            digester.reset();
+            ruleSet.recycle();
+        }
+
+        return ok;
+    }
+}
\ No newline at end of file

Propchange: tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
------------------------------------------------------------------------------
    svn:eol-style = native



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