Author: jboynes
Date: Sat Jul 20 17:12:49 2013
New Revision: 1505172
URL: http://svn.apache.org/r1505172
Log:
Simplify parsing web.xml in JspC in preparation for handling fragments
Modified:
tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java?rev=1505172&r1=1505171&r2=1505172&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
(original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java Sat Jul
20 17:12:49 2013
@@ -17,6 +17,7 @@
package org.apache.jasper.servlet;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.MalformedURLException;
@@ -48,13 +49,13 @@ import javax.servlet.descriptor.TaglibDe
import org.apache.jasper.JasperException;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.util.ExceptionUtils;
+import org.apache.tomcat.util.descriptor.web.Constants;
import org.apache.tomcat.util.descriptor.web.JspConfigDescriptorImpl;
import org.apache.tomcat.util.descriptor.web.JspPropertyGroup;
import org.apache.tomcat.util.descriptor.web.JspPropertyGroupDescriptorImpl;
import org.apache.tomcat.util.descriptor.web.TaglibDescriptorImpl;
import org.apache.tomcat.util.descriptor.web.WebXml;
import org.apache.tomcat.util.descriptor.web.WebXmlParser;
-import org.xml.sax.InputSource;
/**
@@ -128,30 +129,16 @@ public class JspCServletContext implemen
// Use this class's classloader as Ant will have set the TCCL to its
own
webXmlParser.setClassLoader(getClass().getClassLoader());
- InputStream webXmlStream = getResourceAsStream(
- org.apache.tomcat.util.descriptor.web.Constants.
- WEB_XML_LOCATION);
-
- if (webXmlStream != null) {
- URL webXmlUrl;
- try {
- webXmlUrl = getResource(
- org.apache.tomcat.util.descriptor.web.Constants.
- WEB_XML_LOCATION);
- } catch (MalformedURLException e) {
- // Should never happen. Just in case...
- throw new JasperException(e);
- }
-
- InputSource source = new InputSource(webXmlUrl.toExternalForm());
- source.setByteStream(webXmlStream);
- if (!webXmlParser.parseWebXml(source, webXml, false)) {
+ try {
+ URL url = getResource(Constants.WEB_XML_LOCATION);
+ if (!webXmlParser.parseWebXml(url, webXml, false)) {
+ // TODO - message
throw new JasperException(Localizer.getMessage(""));
}
+ } catch (IOException e) {
+ throw new JasperException(e);
}
-
-
Set<JspPropertyGroup> jspPropertyGroups =
webXml.getJspPropertyGroups();
Map<String,String> tagLibs = webXml.getTaglibs();
Modified:
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=1505172&r1=1505171&r2=1505172&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/descriptor/web/WebXmlParser.java
Sat Jul 20 17:12:49 2013
@@ -16,7 +16,9 @@
*/
package org.apache.tomcat.util.descriptor.web;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
@@ -65,6 +67,24 @@ public class WebXmlParser {
webFragmentDigester.getParser();
}
+ /**
+ * Parse a web descriptor at a location.
+ *
+ * @param url the location; if null no load will be attempted
+ * @param dest the instance to be populated by the parse operation
+ * @param fragment indicate if the descriptor is a web-app or web-fragment
+ * @return true if the descriptor was successfully parsed
+ * @throws IOException if there was a problem reading from the URL
+ */
+ public boolean parseWebXml(URL url, WebXml dest, boolean fragment) throws
IOException {
+ if (url == null) {
+ return true;
+ }
+ InputSource source = new InputSource(url.toExternalForm());
+ source.setByteStream(url.openStream());
+ return parseWebXml(source, dest, fragment);
+ }
+
public boolean parseWebXml(InputSource source, WebXml dest,
boolean fragment) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]