JBossWeb SVN: r1098 - trunk/java/org/apache/jasper/compiler.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-10 08:41:52 -0400 (Wed, 10 Jun 2009)
New Revision: 1098
Modified:
trunk/java/org/apache/jasper/compiler/Parser.java
Log:
- Fix the include fix.
Modified: trunk/java/org/apache/jasper/compiler/Parser.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Parser.java 2009-06-09 15:44:32 UTC (rev 1097)
+++ trunk/java/org/apache/jasper/compiler/Parser.java 2009-06-10 12:41:52 UTC (rev 1098)
@@ -125,21 +125,22 @@
// For the Top level page, add include-prelude and include-coda
PageInfo pageInfo = pc.getCompiler().getPageInfo();
- if (parent == null) {
+ if (parent == null && !isTagFile) {
parser.addInclude(root, pageInfo.getIncludePrelude());
}
if (directivesOnly) {
- parser.parseTagFileDirectives(root);
+ parser.parseFileDirectives(root);
} else {
while (reader.hasMoreInput()) {
parser.parseElements(root);
}
}
- if (parent == null) {
+ if (parent == null && !isTagFile) {
parser.addInclude(root, pageInfo.getIncludeCoda());
}
- return new Node.Nodes(root);
+ Node.Nodes page = new Node.Nodes(root);
+ return page;
}
/**
@@ -1770,7 +1771,7 @@
return JAVAX_BODY_CONTENT_TEMPLATE_TEXT;
}
- private void parseTagFileDirectives(Node parent) throws JasperException {
+ private void parseFileDirectives(Node parent) throws JasperException {
reader.setSingleFile(true);
reader.skipUntil("<");
while (reader.hasMoreInput()) {
15 years, 6 months
JBossWeb SVN: r1097 - tags.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-09 11:44:32 -0400 (Tue, 09 Jun 2009)
New Revision: 1097
Added:
tags/JBOSSWEB_2_0_0_GA_CP11/
Log:
Tag for CVE's
Copied: tags/JBOSSWEB_2_0_0_GA_CP11 (from rev 1096, branches/JBOSSWEB_2_0_0_GA_CP)
15 years, 6 months
JBossWeb SVN: r1096 - in branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache: catalina/core and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-09 03:34:49 -0400 (Tue, 09 Jun 2009)
New Revision: 1096
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java
Log:
Put back the port of r901.
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Request.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -67,7 +67,6 @@
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.ParameterMap;
-import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.util.StringParser;
@@ -1269,10 +1268,9 @@
int pos = requestPath.lastIndexOf('/');
String relative = null;
if (pos >= 0) {
- relative = RequestUtil.normalize
- (requestPath.substring(0, pos + 1) + path);
+ relative = requestPath.substring(0, pos + 1) + path;
} else {
- relative = RequestUtil.normalize(requestPath + path);
+ relative = requestPath + path;
}
return (context.getServletContext().getRequestDispatcher(relative));
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationContext.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -44,6 +44,7 @@
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.ApplicationParameter;
import org.apache.catalina.util.Enumerator;
+import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ResourceSet;
import org.apache.catalina.util.ServerInfo;
import org.apache.catalina.util.StringManager;
@@ -377,7 +378,7 @@
path = path.substring(0, pos);
}
- path = normalize(path);
+ path = RequestUtil.normalize(path);
if (path == null)
return (null);
@@ -459,7 +460,7 @@
throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
}
- path = normalize(path);
+ path = RequestUtil.normalize(path);
if (path == null)
return (null);
@@ -508,10 +509,13 @@
*/
public InputStream getResourceAsStream(String path) {
- path = normalize(path);
if (path == null)
return (null);
+ path = RequestUtil.normalize(path);
+ if (path == null)
+ return (null);
+
DirContext resources = context.getResources();
if (resources != null) {
try {
@@ -544,7 +548,7 @@
(sm.getString("applicationContext.resourcePaths.iae", path));
}
- path = normalize(path);
+ path = RequestUtil.normalize(path);
if (path == null)
return (null);
@@ -851,45 +855,6 @@
/**
- * Return a context-relative path, beginning with a "/", that represents
- * the canonical version of the specified path after ".." and "." elements
- * are resolved out. If the specified path attempts to go outside the
- * boundaries of the current context (i.e. too many ".." path elements
- * are present), return <code>null</code> instead.
- *
- * @param path Path to be normalized
- */
- private String normalize(String path) {
-
- if (path == null) {
- return null;
- }
-
- String normalized = path;
-
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
-
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- return (null); // Trying to go outside our context
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Return the normalized path that we have completed
- return (normalized);
-
- }
-
-
- /**
* Merge the context initialization parameters specified in the application
* deployment descriptor with the application parameters described in the
* server configuration, respecting the <code>override</code> property of
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/ApplicationHttpRequest.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -318,10 +318,9 @@
int pos = requestPath.lastIndexOf('/');
String relative = null;
if (pos >= 0) {
- relative = RequestUtil.normalize
- (requestPath.substring(0, pos + 1) + path);
+ relative = requestPath.substring(0, pos + 1) + path;
} else {
- relative = RequestUtil.normalize(requestPath + path);
+ relative = requestPath + path;
}
return (context.getServletContext().getRequestDispatcher(relative));
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/servlets/WebdavServlet.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -1374,71 +1374,6 @@
}
- /**
- * Return a context-relative path, beginning with a "/", that represents
- * the canonical version of the specified path after ".." and "." elements
- * are resolved out. If the specified path attempts to go outside the
- * boundaries of the current context (i.e. too many ".." path elements
- * are present), return <code>null</code> instead.
- *
- * @param path Path to be normalized
- */
- protected String normalize(String path) {
-
- if (path == null)
- return null;
-
- // Create a place for the normalized path
- String normalized = path;
-
- if (normalized == null)
- return (null);
-
- if (normalized.equals("/."))
- return "/";
-
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- if (!normalized.startsWith("/"))
- normalized = "/" + normalized;
-
- // Resolve occurrences of "//" in the normalized path
- while (true) {
- int index = normalized.indexOf("//");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 1);
- }
-
- // Resolve occurrences of "/./" in the normalized path
- while (true) {
- int index = normalized.indexOf("/./");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 2);
- }
-
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- return (null); // Trying to go outside our context
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Return the normalized path that we have completed
- return (normalized);
-
- }
-
-
// -------------------------------------------------------- Private Methods
/**
@@ -1593,7 +1528,7 @@
}
// Normalise destination path (remove '.' and '..')
- destinationPath = normalize(destinationPath);
+ destinationPath = RequestUtil.normalize(destinationPath);
String contextPath = req.getContextPath();
if ((contextPath != null) &&
@@ -2340,7 +2275,7 @@
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
- generatedXML.writeText(rewriteUrl(normalize(absoluteUri + toAppend)));
+ generatedXML.writeText(rewriteUrl(RequestUtil.normalize(absoluteUri + toAppend)));
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/ssi/SSIServletRequestUtil.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -59,13 +59,6 @@
* Path to be normalized
*/
public static String normalize(String path) {
- if (path == null) return null;
- String normalized = path;
- //Why doesn't RequestUtil do this??
- // Normalize the slashes and add leading slash if necessary
- if (normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- normalized = RequestUtil.normalize(path);
- return normalized;
+ return RequestUtil.normalize(path);
}
}
\ No newline at end of file
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/util/RequestUtil.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -93,13 +93,29 @@
* @param path Relative path to be normalized
*/
public static String normalize(String path) {
+ return normalize(path, true);
+ }
+ /**
+ * Normalize a relative URI path that may have relative values ("/./",
+ * "/../", and so on ) it it. <strong>WARNING</strong> - This method is
+ * useful only for normalizing application-generated paths. It does not
+ * try to perform security checks for malicious input.
+ *
+ * @param path Relative path to be normalized
+ * @param replaceBackSlash Should '\\' be replaced with '/'
+ */
+ public static String normalize(String path, boolean replaceBackSlash) {
+
if (path == null)
return null;
// Create a place for the normalized path
String normalized = path;
+ if (replaceBackSlash && normalized.indexOf('\\') >= 0)
+ normalized = normalized.replace('\\', '/');
+
if (normalized.equals("/."))
return "/";
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java 2009-06-08 13:39:53 UTC (rev 1095)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/naming/resources/FileDirContext.java 2009-06-09 07:34:49 UTC (rev 1096)
@@ -29,14 +29,21 @@
import java.util.Hashtable;
import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
+import javax.naming.NotContextException;
import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.AttributeModificationException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributesException;
+import javax.naming.directory.InvalidSearchControlsException;
+import javax.naming.directory.InvalidSearchFilterException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import org.apache.catalina.util.RequestUtil;
import org.apache.naming.NamingContextBindingsEnumeration;
import org.apache.naming.NamingContextEnumeration;
import org.apache.naming.NamingEntry;
@@ -754,61 +761,11 @@
// ------------------------------------------------------ Protected Methods
- /**
- * Return a context-relative path, beginning with a "/", that represents
- * the canonical version of the specified path after ".." and "." elements
- * are resolved out. If the specified path attempts to go outside the
- * boundaries of the current context (i.e. too many ".." path elements
- * are present), return <code>null</code> instead.
- *
- * @param path Path to be normalized
- */
- protected String normalize(String path) {
-
- String normalized = path;
-
- // Normalize the slashes and add leading slash if necessary
- if (File.separatorChar == '\\' && normalized.indexOf('\\') >= 0)
- normalized = normalized.replace('\\', '/');
- if (!normalized.startsWith("/"))
- normalized = "/" + normalized;
-
- // Resolve occurrences of "//" in the normalized path
- while (true) {
- int index = normalized.indexOf("//");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 1);
+ protected static String normalize(String path) {
+ return RequestUtil.normalize(path, File.separatorChar == '\\');
}
- // Resolve occurrences of "/./" in the normalized path
- while (true) {
- int index = normalized.indexOf("/./");
- if (index < 0)
- break;
- normalized = normalized.substring(0, index) +
- normalized.substring(index + 2);
- }
- // Resolve occurrences of "/../" in the normalized path
- while (true) {
- int index = normalized.indexOf("/../");
- if (index < 0)
- break;
- if (index == 0)
- return (null); // Trying to go outside our context
- int index2 = normalized.lastIndexOf('/', index - 1);
- normalized = normalized.substring(0, index2) +
- normalized.substring(index + 3);
- }
-
- // Return the normalized path that we have completed
- return (normalized);
-
- }
-
-
/**
* Return a File object representing the specified normalized
* context-relative path if it exists and is readable. Otherwise,
15 years, 6 months
JBossWeb SVN: r1095 - branches/2.1.x/webapps/docs.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-08 09:39:53 -0400 (Mon, 08 Jun 2009)
New Revision: 1095
Modified:
branches/2.1.x/webapps/docs/changelog.xml
Log:
Add the entries corresponding to r1092.
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2009-06-08 13:16:03 UTC (rev 1094)
+++ branches/2.1.x/webapps/docs/changelog.xml 2009-06-08 13:39:53 UTC (rev 1095)
@@ -24,8 +24,11 @@
<subsection name="Catalina">
<changelog>
<fix>
- Don't use XML parser from webapp to process TLD files. (markt, jclere)
+ <bug>45933</bug>: Don't use xml parser from web-app to process tld files. (markt)
</fix>
+ <fix>
+ <bug>29936</bug>: Create digesters and parsers earlier so we aren't using the webapp class loader when we create them. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
15 years, 6 months
JBossWeb SVN: r1094 - in trunk: java/org/apache/jasper/compiler and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-08 09:16:03 -0400 (Mon, 08 Jun 2009)
New Revision: 1094
Modified:
trunk/ROADMAP.txt
trunk/java/org/apache/jasper/compiler/Parser.java
trunk/webapps/docs/changelog.xml
Log:
- Port include processing fix from Jasper.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-06-08 13:15:38 UTC (rev 1093)
+++ trunk/ROADMAP.txt 2009-06-08 13:16:03 UTC (rev 1094)
@@ -5,6 +5,7 @@
- Update digester XML parsing rules for web.xml updates (session tracking-mode, cookie-config, servlet enabled,
servlets and filters async-supported, http-method-omission)
- Enforce web.xml fragments merging rules
+- Migrate relevant components to JAR repository (in paticular classloader)
- Lazy webapp startup valve
- Abstract JMX in custom modeler better
- JSP 2.2 changes
Modified: trunk/java/org/apache/jasper/compiler/Parser.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Parser.java 2009-06-08 13:15:38 UTC (rev 1093)
+++ trunk/java/org/apache/jasper/compiler/Parser.java 2009-06-08 13:16:03 UTC (rev 1094)
@@ -123,25 +123,23 @@
root.setIsDefaultPageEncoding(isDefaultPageEncoding);
root.setIsBomPresent(isBomPresent);
- if (directivesOnly) {
- parser.parseTagFileDirectives(root);
- return new Node.Nodes(root);
- }
-
- // For the Top level page, add inlcude-prelude and include-coda
+ // For the Top level page, add include-prelude and include-coda
PageInfo pageInfo = pc.getCompiler().getPageInfo();
if (parent == null) {
parser.addInclude(root, pageInfo.getIncludePrelude());
}
- while (reader.hasMoreInput()) {
- parser.parseElements(root);
+ if (directivesOnly) {
+ parser.parseTagFileDirectives(root);
+ } else {
+ while (reader.hasMoreInput()) {
+ parser.parseElements(root);
+ }
}
if (parent == null) {
parser.addInclude(root, pageInfo.getIncludeCoda());
}
- Node.Nodes page = new Node.Nodes(root);
- return page;
+ return new Node.Nodes(root);
}
/**
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-06-08 13:15:38 UTC (rev 1093)
+++ trunk/webapps/docs/changelog.xml 2009-06-08 13:16:03 UTC (rev 1094)
@@ -125,6 +125,9 @@
<fix>
Removed some casts in ELResolverImpl. Patch suggested by kkolinko. (markt)
</fix>
+ <fix>
+ <bug>47318</bug>: Process include preludes and codas when processing directives and whole pages. (markt)
+ </fix>
</changelog>
</subsection>
</section>
15 years, 6 months
JBossWeb SVN: r1093 - in branches/2.1.x: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-08 09:15:38 -0400 (Mon, 08 Jun 2009)
New Revision: 1093
Modified:
branches/2.1.x/java/org/apache/jasper/compiler/Parser.java
branches/2.1.x/webapps/docs/changelog.xml
Log:
- Port include processing fix from Jasper.
Modified: branches/2.1.x/java/org/apache/jasper/compiler/Parser.java
===================================================================
--- branches/2.1.x/java/org/apache/jasper/compiler/Parser.java 2009-06-08 11:30:55 UTC (rev 1092)
+++ branches/2.1.x/java/org/apache/jasper/compiler/Parser.java 2009-06-08 13:15:38 UTC (rev 1093)
@@ -123,25 +123,23 @@
root.setIsDefaultPageEncoding(isDefaultPageEncoding);
root.setIsBomPresent(isBomPresent);
- if (directivesOnly) {
- parser.parseTagFileDirectives(root);
- return new Node.Nodes(root);
- }
-
- // For the Top level page, add inlcude-prelude and include-coda
+ // For the Top level page, add include-prelude and include-coda
PageInfo pageInfo = pc.getCompiler().getPageInfo();
if (parent == null) {
parser.addInclude(root, pageInfo.getIncludePrelude());
}
- while (reader.hasMoreInput()) {
- parser.parseElements(root);
+ if (directivesOnly) {
+ parser.parseTagFileDirectives(root);
+ } else {
+ while (reader.hasMoreInput()) {
+ parser.parseElements(root);
+ }
}
if (parent == null) {
parser.addInclude(root, pageInfo.getIncludeCoda());
}
- Node.Nodes page = new Node.Nodes(root);
- return page;
+ return new Node.Nodes(root);
}
/**
Modified: branches/2.1.x/webapps/docs/changelog.xml
===================================================================
--- branches/2.1.x/webapps/docs/changelog.xml 2009-06-08 11:30:55 UTC (rev 1092)
+++ branches/2.1.x/webapps/docs/changelog.xml 2009-06-08 13:15:38 UTC (rev 1093)
@@ -24,6 +24,31 @@
<subsection name="Catalina">
<changelog>
<fix>
+ Don't use XML parser from webapp to process TLD files. (markt, jclere)
+ </fix>
+ </changelog>
+ </subsection>
+ <subsection name="Coyote">
+ <changelog>
+ </changelog>
+ </subsection>
+ <subsection name="Jasper">
+ <changelog>
+ <fix>
+ <bug>47318</bug>: Process include preludes and codas when processing directives and whole pages. (markt)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
+<section name="JBoss Web 2.1.3.GA (remm)">
+ <subsection name="General">
+ <changelog>
+ </changelog>
+ </subsection>
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
NPE in various realms. (markt)
</fix>
<fix>
15 years, 6 months
JBossWeb SVN: r1092 - in branches/2.1.x/java/org/apache/catalina: startup and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-08 07:30:55 -0400 (Mon, 08 Jun 2009)
New Revision: 1092
Modified:
branches/2.1.x/java/org/apache/catalina/core/StandardContext.java
branches/2.1.x/java/org/apache/catalina/startup/LocalStrings.properties
branches/2.1.x/java/org/apache/catalina/startup/TldConfig.java
Log:
Don't use xml parser from web-app to process tld files.
Modified: branches/2.1.x/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- branches/2.1.x/java/org/apache/catalina/core/StandardContext.java 2009-06-08 08:33:17 UTC (rev 1091)
+++ branches/2.1.x/java/org/apache/catalina/core/StandardContext.java 2009-06-08 11:30:55 UTC (rev 1092)
@@ -4304,10 +4304,6 @@
((Lifecycle) pipeline).start();
}
- if(getProcessTlds()) {
- processTlds();
- }
-
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(START_EVENT, null);
@@ -4510,39 +4506,6 @@
}
}
- /**
- * 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 {
@@ -5430,6 +5393,10 @@
return;
}
}
+ if (processTlds) {
+ this.addLifecycleListener(new TldConfig());
+ }
+
super.init();
// Notify our interested LifecycleListeners
Modified: branches/2.1.x/java/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- branches/2.1.x/java/org/apache/catalina/startup/LocalStrings.properties 2009-06-08 08:33:17 UTC (rev 1091)
+++ branches/2.1.x/java/org/apache/catalina/startup/LocalStrings.properties 2009-06-08 11:30:55 UTC (rev 1092)
@@ -72,6 +72,8 @@
hostConfig.undeploy=Undeploying context [{0}]
hostConfig.undeploy.error=Error undeploying web application at context path {0}
hostConfig.undeploying=Undeploying deployed web applications
+tldConfig.cce=Lifecycle event data object {0} is not a Context
+tldConfig.execute=Error processing TLD files for context path {0}
userConfig.database=Exception loading user database
userConfig.deploy=Deploying web application for user {0}
userConfig.deploying=Deploying user web applications
Modified: branches/2.1.x/java/org/apache/catalina/startup/TldConfig.java
===================================================================
--- branches/2.1.x/java/org/apache/catalina/startup/TldConfig.java 2009-06-08 08:33:17 UTC (rev 1091)
+++ branches/2.1.x/java/org/apache/catalina/startup/TldConfig.java 2009-06-08 11:30:55 UTC (rev 1092)
@@ -48,20 +48,24 @@
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.util.digester.Digester;
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.
+ * Startup event listener for a <b>Context</b> that configures application
+ * listeners configured in any TLD files.
*
* @author Craig R. McClanahan
* @author Jean-Francois Arcand
* @author Costin Manolache
*/
-public final class TldConfig {
+public final class TldConfig implements LifecycleListener {
// Names of JARs that are known not to contain any TLDs
private static HashSet<String> noTldJars;
@@ -393,20 +397,6 @@
}
/**
- * Create (if necessary) and return a Digester configured to process a tag
- * library descriptor, looking for additional listener classes to be
- * registered.
- */
- private static Digester createTldDigester() {
-
- return DigesterFactory.newDigester(tldValidation,
- tldNamespaceAware,
- new TldRuleSet());
-
- }
-
-
- /**
* Scan the JAR file at the specified resource path for TLDs in the
* <code>META-INF</code> subdirectory, and scan each TLD for application
* event listeners that need to be registered.
@@ -508,10 +498,6 @@
private void tldScanStream(InputSource resourceStream)
throws Exception {
- if (tldDigester == null){
- tldDigester = createTldDigester();
- }
-
synchronized (tldDigester) {
try {
tldDigester.push(this);
@@ -731,4 +717,51 @@
return jarPathMap;
}
+
+ public void lifecycleEvent(LifecycleEvent event) {
+ // Identify the context we are associated with
+ try {
+ context = (Context) event.getLifecycle();
+ } catch (ClassCastException e) {
+ log.error(sm.getString("tldConfig.cce", event.getLifecycle()), e);
+ return;
+ }
+
+ if (event.getType().equals(Lifecycle.INIT_EVENT)) {
+ init();
+ } else if (event.getType().equals(Lifecycle.START_EVENT)) {
+ try {
+ execute();
+ } catch (Exception e) {
+ log.error(sm.getString(
+ "tldConfig.execute", context.getPath()), e);
+ }
+ } // Ignore the other event types - nothing to do
+ }
+
+ private void init() {
+ if (tldDigester == null){
+ // (1) check if the attribute has been defined
+ // on the context element.
+ setTldValidation(context.getTldValidation());
+ setTldNamespaceAware(context.getTldNamespaceAware());
+
+ // (2) if the attribute wasn't defined on the context
+ // try the host.
+ if (!tldValidation) {
+ setTldValidation(
+ ((StandardHost) context.getParent()).getXmlValidation());
+ }
+
+ if (!tldNamespaceAware) {
+ setTldNamespaceAware(
+ ((StandardHost) context.getParent()).getXmlNamespaceAware());
+ }
+
+ tldDigester = DigesterFactory.newDigester(tldValidation,
+ tldNamespaceAware,
+ new TldRuleSet());
+ tldDigester.getParser();
+ }
+ }
}
15 years, 6 months
JBossWeb SVN: r1091 - in branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina: startup and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-06-08 04:33:17 -0400 (Mon, 08 Jun 2009)
New Revision: 1091
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/StandardContext.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/ContextConfig.java
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/LocalStrings.properties
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/TldConfig.java
Log:
Don't use xml parser from web-app to process tld files
And port r590.
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/StandardContext.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/StandardContext.java 2009-06-06 22:34:44 UTC (rev 1090)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/core/StandardContext.java 2009-06-08 08:33:17 UTC (rev 1091)
@@ -4246,10 +4246,6 @@
((Lifecycle) pipeline).start();
}
- if(getProcessTlds()) {
- processTlds();
- }
-
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(START_EVENT, null);
@@ -4413,39 +4409,6 @@
//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 {
@@ -5308,6 +5271,10 @@
return;
}
}
+ if (processTlds) {
+ this.addLifecycleListener(new TldConfig());
+ }
+
super.init();
// Notify our interested LifecycleListeners
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/ContextConfig.java 2009-06-06 22:34:44 UTC (rev 1090)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/ContextConfig.java 2009-06-08 08:33:17 UTC (rev 1091)
@@ -339,10 +339,6 @@
long t1=System.currentTimeMillis();
- if (webDigester == null){
- webDigester = createWebDigester();
- }
-
URL url=null;
// Process the application web.xml file
synchronized (webDigester) {
@@ -624,10 +620,6 @@
+ " " + defaultWebXml + " " + file , e);
}
- if (webDigester == null){
- webDigester = createWebDigester();
- }
-
if (stream != null) {
processDefaultWebConfig(webDigester, stream, source);
webRuleSet.recycle();
@@ -786,9 +778,6 @@
if (source == null)
return;
- if (contextDigester == null){
- contextDigester = createContextDigester();
- }
synchronized (contextDigester) {
try {
source.setByteStream(stream);
@@ -1002,6 +991,16 @@
protected void init() {
// Called from StandardContext.init()
+ if (webDigester == null){
+ webDigester = createWebDigester();
+ webDigester.getParser();
+ }
+
+ if (contextDigester == null){
+ contextDigester = createContextDigester();
+ contextDigester.getParser();
+ }
+
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.init"));
context.setConfigured(false);
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/LocalStrings.properties 2009-06-06 22:34:44 UTC (rev 1090)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/LocalStrings.properties 2009-06-08 08:33:17 UTC (rev 1091)
@@ -72,6 +72,8 @@
hostConfig.undeploy=Undeploying context [{0}]
hostConfig.undeploy.error=Error undeploying web application at context path {0}
hostConfig.undeploying=Undeploying deployed web applications
+tldConfig.cce=Lifecycle event data object {0} is not a Context
+tldConfig.execute=Error processing TLD files for context path {0}
userConfig.database=Exception loading user database
userConfig.deploy=Deploying web application for user {0}
userConfig.deploying=Deploying user web applications
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/TldConfig.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/TldConfig.java 2009-06-06 22:34:44 UTC (rev 1090)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/startup/TldConfig.java 2009-06-08 08:33:17 UTC (rev 1091)
@@ -47,20 +47,24 @@
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.util.digester.Digester;
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.
+ * Startup event listener for a <b>Context</b> that configures application
+ * listeners configured in any TLD files.
*
* @author Craig R. McClanahan
* @author Jean-Francois Arcand
* @author Costin Manolache
*/
-public final class TldConfig {
+public final class TldConfig implements LifecycleListener {
// Names of JARs that are known not to contain any TLDs
private static HashSet<String> noTldJars;
@@ -392,20 +396,6 @@
}
/**
- * Create (if necessary) and return a Digester configured to process a tag
- * library descriptor, looking for additional listener classes to be
- * registered.
- */
- private static Digester createTldDigester() {
-
- return DigesterFactory.newDigester(tldValidation,
- tldNamespaceAware,
- new TldRuleSet());
-
- }
-
-
- /**
* Scan the JAR file at the specified resource path for TLDs in the
* <code>META-INF</code> subdirectory, and scan each TLD for application
* event listeners that need to be registered.
@@ -497,10 +487,6 @@
private void tldScanStream(InputSource resourceStream)
throws Exception {
- if (tldDigester == null){
- tldDigester = createTldDigester();
- }
-
synchronized (tldDigester) {
try {
tldDigester.push(this);
@@ -712,4 +698,51 @@
return jarPathMap;
}
+
+ public void lifecycleEvent(LifecycleEvent event) {
+ // Identify the context we are associated with
+ try {
+ context = (Context) event.getLifecycle();
+ } catch (ClassCastException e) {
+ log.error(sm.getString("tldConfig.cce", event.getLifecycle()), e);
+ return;
+ }
+
+ if (event.getType().equals(Lifecycle.INIT_EVENT)) {
+ init();
+ } else if (event.getType().equals(Lifecycle.START_EVENT)) {
+ try {
+ execute();
+ } catch (Exception e) {
+ log.error(sm.getString(
+ "tldConfig.execute", context.getPath()), e);
+ }
+ } // Ignore the other event types - nothing to do
+ }
+
+ private void init() {
+ if (tldDigester == null){
+ // (1) check if the attribute has been defined
+ // on the context element.
+ setTldValidation(context.getTldValidation());
+ setTldNamespaceAware(context.getTldNamespaceAware());
+
+ // (2) if the attribute wasn't defined on the context
+ // try the host.
+ if (!tldValidation) {
+ setTldValidation(
+ ((StandardHost) context.getParent()).getXmlValidation());
+ }
+
+ if (!tldNamespaceAware) {
+ setTldNamespaceAware(
+ ((StandardHost) context.getParent()).getXmlNamespaceAware());
+ }
+
+ tldDigester = DigesterFactory.newDigester(tldValidation,
+ tldNamespaceAware,
+ new TldRuleSet());
+ tldDigester.getParser();
+ }
+ }
}
15 years, 6 months
JBossWeb SVN: r1090 - in trunk: java/org/apache/catalina/startup and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 18:34:44 -0400 (Sat, 06 Jun 2009)
New Revision: 1090
Removed:
trunk/java/org/apache/catalina/startup/WarScanner.java
trunk/java/org/apache/tomcat/WarComponents.java
Modified:
trunk/conf/server.xml
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/res/confinstall/server_2.xml
Log:
- Remove dead code.
Modified: trunk/conf/server.xml
===================================================================
--- trunk/conf/server.xml 2009-06-06 22:23:25 UTC (rev 1089)
+++ trunk/conf/server.xml 2009-06-06 22:34:44 UTC (rev 1090)
@@ -66,8 +66,7 @@
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
- unpackWARs="true" autoDeploy="true"
- xmlValidation="false" xmlNamespaceAware="false">
+ unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-06-06 22:23:25 UTC (rev 1089)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-06-06 22:34:44 UTC (rev 1090)
@@ -112,7 +112,6 @@
import org.apache.catalina.util.StringManager;
import org.apache.naming.resources.JARDirContext;
import org.apache.naming.resources.ProxyDirContext;
-import org.apache.tomcat.WarComponents;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
import org.xml.sax.ErrorHandler;
@@ -129,7 +128,7 @@
*/
public class ContextConfig
- implements LifecycleListener, WarComponents {
+ implements LifecycleListener {
protected static org.jboss.logging.Logger log=
org.jboss.logging.Logger.getLogger( ContextConfig.class );
@@ -267,8 +266,8 @@
* Used to speed up scanning for the services interest classes.
*/
protected Class<?>[] handlesTypesArray = null;
- protected Map<Class<?>, ServletContainerInitializerInfoImpl> handlesTypes =
- new HashMap<Class<?>, ServletContainerInitializerInfoImpl>();
+ protected Map<Class<?>, ServletContainerInitializerInfo> handlesTypes =
+ new HashMap<Class<?>, ServletContainerInitializerInfo>();
// ------------------------------------------------------------- Properties
@@ -1332,7 +1331,7 @@
if (handlesTypesArray != null) {
for (int i = 0; i < handlesTypesArray.length; i++) {
if (handlesTypesArray[i].isAssignableFrom(clazz)) {
- ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
+ ServletContainerInitializerInfo jarServletContainerInitializerService =
handlesTypes.get(handlesTypesArray[i]);
jarServletContainerInitializerService.addStartupNotifyClass(clazz);
}
@@ -1437,8 +1436,8 @@
}
}
// Add in jarService map, and add in the local map used to speed up lookups
- ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
- new ServletContainerInitializerInfoImpl(servletContainerInitializerClass, handlesTypesArray);
+ ServletContainerInitializerInfo jarServletContainerInitializerService =
+ new ServletContainerInitializerInfo(servletContainerInitializerClass, handlesTypesArray);
servletContainerInitializerInfos.put(file.getName(), jarServletContainerInitializerService);
if (typesArray != null) {
ArrayList<Class<?>> handlesTypesList = new ArrayList<Class<?>>();
@@ -2186,11 +2185,11 @@
}
- protected class ServletContainerInitializerInfoImpl implements ServletContainerInitializerInfo {
+ protected class ServletContainerInitializerInfo {
protected Class<?> servletContainerInitializer = null;
protected Class<?>[] interestClasses = null;
protected HashSet<Class<?>> startupNotifySet = new HashSet<Class<?>>();
- protected ServletContainerInitializerInfoImpl(Class<?> servletContainerInitializer, Class<?>[] interestClasses) {
+ protected ServletContainerInitializerInfo(Class<?> servletContainerInitializer, Class<?>[] interestClasses) {
this.servletContainerInitializer = servletContainerInitializer;
this.interestClasses = interestClasses;
}
Deleted: trunk/java/org/apache/catalina/startup/WarScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WarScanner.java 2009-06-06 22:23:25 UTC (rev 1089)
+++ trunk/java/org/apache/catalina/startup/WarScanner.java 2009-06-06 22:34:44 UTC (rev 1090)
@@ -1,722 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- *
- * This file incorporates work covered by the following copyright and
- * permission notice:
- *
- * Copyright 1999-2009 The Apache Software Foundation
- *
- * 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.catalina.startup;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.digester.Digester;
-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.
- *
- * @author Craig R. McClanahan
- * @author Jean-Francois Arcand
- * @author Costin Manolache
- * @author Remy Maucherat
- * @deprecated No longer used
- */
-public final class WarScanner {
-
- private static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger(WarScanner.class);
-
- /**
- * Names of JARs that are known not to contain any descriptors.
- */
- private static HashSet<String> noDescriptorsJars;
-
- /**
- * Initializes the set of JARs that are known not to contain any descriptors.
- */
- static {
- noDescriptorsJars = new HashSet<String>();
- // Bootstrap JARs
- noDescriptorsJars.add("bootstrap.jar");
- noDescriptorsJars.add("commons-daemon.jar");
- noDescriptorsJars.add("tomcat-juli.jar");
- // Main JARs
- noDescriptorsJars.add("annotations-api.jar");
- noDescriptorsJars.add("catalina.jar");
- noDescriptorsJars.add("catalina-ant.jar");
- noDescriptorsJars.add("el-api.jar");
- noDescriptorsJars.add("jasper.jar");
- noDescriptorsJars.add("jasper-el.jar");
- noDescriptorsJars.add("jasper-jdt.jar");
- noDescriptorsJars.add("jsp-api.jar");
- noDescriptorsJars.add("servlet-api.jar");
- noDescriptorsJars.add("tomcat-coyote.jar");
- noDescriptorsJars.add("tomcat-dbcp.jar");
- // i18n JARs
- noDescriptorsJars.add("tomcat-i18n-en.jar");
- noDescriptorsJars.add("tomcat-i18n-es.jar");
- noDescriptorsJars.add("tomcat-i18n-fr.jar");
- noDescriptorsJars.add("tomcat-i18n-ja.jar");
- // Misc JARs not included with Tomcat
- noDescriptorsJars.add("ant.jar");
- noDescriptorsJars.add("commons-dbcp.jar");
- noDescriptorsJars.add("commons-beanutils.jar");
- noDescriptorsJars.add("commons-fileupload-1.0.jar");
- noDescriptorsJars.add("commons-pool.jar");
- noDescriptorsJars.add("commons-digester.jar");
- noDescriptorsJars.add("commons-logging.jar");
- noDescriptorsJars.add("commons-collections.jar");
- noDescriptorsJars.add("jmx.jar");
- noDescriptorsJars.add("jmx-tools.jar");
- noDescriptorsJars.add("xercesImpl.jar");
- noDescriptorsJars.add("xmlParserAPIs.jar");
- noDescriptorsJars.add("xml-apis.jar");
- // JARs from J2SE runtime
- noDescriptorsJars.add("sunjce_provider.jar");
- noDescriptorsJars.add("ldapsec.jar");
- noDescriptorsJars.add("localedata.jar");
- noDescriptorsJars.add("dnsns.jar");
- noDescriptorsJars.add("tools.jar");
- noDescriptorsJars.add("sunpkcs11.jar");
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
- /**
- * The Context we are associated with.
- */
- private Context context = null;
-
-
- /**
- * The string resources for this package.
- */
- private static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
- /**
- * The <code>Digester</code> we will use to process tag library
- * descriptor files.
- */
- private static Digester tldDigester = null;
-
-
- /**
- * Attribute value used to turn on/off TLD validation
- */
- private static boolean tldValidation = false;
-
-
- /**
- * Attribute value used to turn on/off TLD namespace awarenes.
- */
- private static boolean tldNamespaceAware = false;
-
- private boolean rescan=true;
-
- private ArrayList<String> listeners = new ArrayList<String>();
-
- // --------------------------------------------------------- Public Methods
-
- /**
- * Sets the list of JARs that are known not to contain any TLDs.
- *
- * @param jarNames List of comma-separated names of JAR files that are
- * known not to contain any TLDs
- */
- public static void setNoTldJars(String jarNames) {
- if (jarNames != null) {
- noDescriptorsJars.clear();
- StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
- while (tokenizer.hasMoreElements()) {
- noDescriptorsJars.add(tokenizer.nextToken());
- }
- }
- }
-
- /**
- * Set the validation feature of the XML parser used when
- * parsing xml instances.
- * @param tldValidation true to enable xml instance validation
- */
- public void setTldValidation(boolean tldValidation){
- WarScanner.tldValidation = tldValidation;
- }
-
- /**
- * Get the server.xml <host> attribute's xmlValidation.
- * @return true if validation is enabled.
- *
- */
- public boolean getTldValidation(){
- return tldValidation;
- }
-
- /**
- * Get the server.xml <host> attribute's xmlNamespaceAware.
- * @return true if namespace awarenes is enabled.
- *
- */
- public boolean getTldNamespaceAware(){
- return tldNamespaceAware;
- }
-
-
- /**
- * Set the namespace aware feature of the XML parser used when
- * parsing xml instances.
- * @param tldNamespaceAware true to enable namespace awareness
- */
- public void setTldNamespaceAware(boolean tldNamespaceAware){
- WarScanner.tldNamespaceAware = tldNamespaceAware;
- }
-
-
- public boolean isRescan() {
- return rescan;
- }
-
- public void setRescan(boolean rescan) {
- this.rescan = rescan;
- }
-
- public Context getContext() {
- return context;
- }
-
- public void setContext(Context context) {
- this.context = context;
- }
-
- public void addApplicationListener( String s ) {
- //if(log.isDebugEnabled())
- log.debug( "Add tld listener " + s);
- listeners.add(s);
- }
-
- public String[] getTldListeners() {
- String result[]=new String[listeners.size()];
- listeners.toArray(result);
- return result;
- }
-
-
- /**
- * Scan for and configure all tag library descriptors found in this
- * web application.
- *
- * @exception Exception if a fatal input/output or parsing error occurs
- */
- public void execute() throws Exception {
- long t1=System.currentTimeMillis();
-
- /*
- * Acquire the list of TLD resource paths, possibly embedded in JAR
- * files, to be processed
- */
- Set resourcePaths = tldScanResourcePaths();
- Map<String, File> jarPaths = getJarPaths();
-
- // Scan each accumulated resource path for TLDs to be processed
- Iterator paths = resourcePaths.iterator();
- while (paths.hasNext()) {
- String path = (String) paths.next();
- if (path.endsWith(".jar")) {
- tldScanJar(path);
- } else {
- tldScanTld(path);
- }
- }
- if (jarPaths != null) {
- paths = jarPaths.values().iterator();
- while (paths.hasNext()) {
- tldScanJar((File) paths.next());
- }
- }
-
- String list[] = getTldListeners();
-
- if( log.isDebugEnabled() )
- log.debug( "Adding tld listeners:" + list.length);
- for( int i=0; list!=null && i<list.length; i++ ) {
- context.addApplicationListener(list[i]);
- }
-
- long t2=System.currentTimeMillis();
- if( context instanceof StandardContext ) {
- ((StandardContext)context).setTldScanTime(t2-t1);
- }
-
- }
-
- // -------------------------------------------------------- Private Methods
-
- /*
- * Returns the last modification date of the given sets of resources.
- *
- * @param resourcePaths
- * @param jarPaths
- *
- * @return Last modification date
- */
- private long getLastModified(Set resourcePaths, Map jarPaths)
- throws Exception {
-
- long lastModified = 0;
-
- Iterator paths = resourcePaths.iterator();
- while (paths.hasNext()) {
- String path = (String) paths.next();
- URL url = context.getServletContext().getResource(path);
- if (url == null) {
- log.debug( "Null url "+ path );
- break;
- }
- long lastM = url.openConnection().getLastModified();
- if (lastM > lastModified) lastModified = lastM;
- if (log.isDebugEnabled()) {
- log.debug( "Last modified " + path + " " + lastM);
- }
- }
-
- if (jarPaths != null) {
- paths = jarPaths.values().iterator();
- while (paths.hasNext()) {
- File jarFile = (File) paths.next();
- long lastM = jarFile.lastModified();
- if (lastM > lastModified) lastModified = lastM;
- if (log.isDebugEnabled()) {
- log.debug("Last modified " + jarFile.getAbsolutePath()
- + " " + lastM);
- }
- }
- }
-
- return lastModified;
- }
-
- private void processCache(File tldCache ) throws IOException {
- // read the cache and return;
- try {
- FileInputStream in=new FileInputStream(tldCache);
- ObjectInputStream ois=new ObjectInputStream( in );
- String list[]=(String [])ois.readObject();
- if( log.isDebugEnabled() )
- log.debug("Reusing tldCache " + tldCache + " " + list.length);
- for( int i=0; list!=null && i<list.length; i++ ) {
- context.addApplicationListener(list[i]);
- }
- ois.close();
- } catch( ClassNotFoundException ex ) {
- ex.printStackTrace();
- }
- }
-
- /**
- * Create (if necessary) and return a Digester configured to process a tag
- * library descriptor, looking for additional listener classes to be
- * registered.
- */
- private static Digester createTldDigester() {
-
- return DigesterFactory.newDigester(tldValidation,
- tldNamespaceAware,
- new TldRuleSet());
-
- }
-
-
- /**
- * Scan the JAR file at the specified resource path for TLDs in the
- * <code>META-INF</code> subdirectory, and scan each TLD for application
- * event listeners that need to be registered.
- *
- * @param resourcePath Resource path of the JAR file to scan
- *
- * @exception Exception if an exception occurs while scanning this JAR
- */
- private void tldScanJar(String resourcePath) throws Exception {
-
- if (log.isDebugEnabled()) {
- log.debug(" Scanning JAR at resource path '" + resourcePath + "'");
- }
-
- URL url = context.getServletContext().getResource(resourcePath);
- if (url == null) {
- throw new IllegalArgumentException
- (sm.getString("contextConfig.tldResourcePath",
- resourcePath));
- }
-
- File file = null;
- try {
- file = new File(url.toURI());
- } catch (URISyntaxException e) {
- // Ignore, probably an unencoded char
- file = new File(url.getFile());
- }
- try {
- file = file.getCanonicalFile();
- } catch (IOException e) {
- // Ignore
- }
- tldScanJar(file);
-
- }
-
- /**
- * Scans all TLD entries in the given JAR for application listeners.
- *
- * @param file JAR file whose TLD entries are scanned for application
- * listeners
- */
- private void tldScanJar(File file) throws Exception {
-
- JarFile jarFile = null;
- String name = null;
-
- String jarPath = file.getAbsolutePath();
-
- try {
- jarFile = new JarFile(file);
- Enumeration entries = jarFile.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = (JarEntry) entries.nextElement();
- name = entry.getName();
- if (!name.startsWith("META-INF/")) {
- continue;
- }
- if (!name.endsWith(".tld")) {
- continue;
- }
- if (log.isTraceEnabled()) {
- log.trace(" Processing TLD at '" + name + "'");
- }
- try {
- tldScanStream(new InputSource(jarFile.getInputStream(entry)));
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.tldEntryException",
- name, jarPath, context.getPath()),
- e);
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.tldJarException",
- jarPath, context.getPath()),
- e);
- } finally {
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (Throwable t) {
- // Ignore
- }
- }
- }
- }
-
- /**
- * Scan the TLD contents in the specified input stream, and register
- * any application event listeners found there. <b>NOTE</b> - It is
- * the responsibility of the caller to close the InputStream after this
- * method returns.
- *
- * @param resourceStream InputStream containing a tag library descriptor
- *
- * @exception Exception if an exception occurs while scanning this TLD
- */
- private void tldScanStream(InputSource resourceStream)
- throws Exception {
-
- if (tldDigester == null){
- tldDigester = createTldDigester();
- }
-
- synchronized (tldDigester) {
- try {
- tldDigester.push(this);
- tldDigester.parse(resourceStream);
- } finally {
- tldDigester.reset();
- }
- }
-
- }
-
- /**
- * Scan the TLD contents at the specified resource path, and register
- * any application event listeners found there.
- *
- * @param resourcePath Resource path being scanned
- *
- * @exception Exception if an exception occurs while scanning this TLD
- */
- private void tldScanTld(String resourcePath) throws Exception {
-
- if (log.isDebugEnabled()) {
- log.debug(" Scanning TLD at resource path '" + resourcePath + "'");
- }
-
- InputSource inputSource = null;
- try {
- InputStream stream =
- context.getServletContext().getResourceAsStream(resourcePath);
- if (stream == null) {
- throw new IllegalArgumentException
- (sm.getString("contextConfig.tldResourcePath",
- resourcePath));
- }
- inputSource = new InputSource(stream);
- if (inputSource == null) {
- throw new IllegalArgumentException
- (sm.getString("contextConfig.tldResourcePath",
- resourcePath));
- }
- tldScanStream(inputSource);
- } catch (Exception e) {
- throw new ServletException
- (sm.getString("contextConfig.tldFileException", resourcePath,
- context.getPath()),
- e);
- }
-
- }
-
- /**
- * Accumulate and return a Set of resource paths to be analyzed for
- * tag library descriptors. Each element of the returned set will be
- * the context-relative path to either a tag library descriptor file,
- * or to a JAR file that may contain tag library descriptors in its
- * <code>META-INF</code> subdirectory.
- *
- * @exception IOException if an input/output error occurs while
- * accumulating the list of resource paths
- */
- private Set<String> tldScanResourcePaths() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(" Accumulating TLD resource paths");
- }
- Set<String> resourcePaths = new HashSet<String>();
-
- // Accumulate resource paths explicitly listed in the web application
- // deployment descriptor
- if (log.isTraceEnabled()) {
- log.trace(" Scanning <taglib> elements in web.xml");
- }
- String taglibs[] = context.findTaglibs();
- for (int i = 0; i < taglibs.length; i++) {
- String resourcePath = context.findTaglib(taglibs[i]);
- // FIXME - Servlet 2.4 DTD implies that the location MUST be
- // a context-relative path starting with '/'?
- if (!resourcePath.startsWith("/")) {
- resourcePath = "/WEB-INF/" + resourcePath;
- }
- if (log.isTraceEnabled()) {
- log.trace(" Adding path '" + resourcePath +
- "' for URI '" + taglibs[i] + "'");
- }
- resourcePaths.add(resourcePath);
- }
-
- DirContext resources = context.getResources();
- if (resources != null) {
- tldScanResourcePathsWebInf(resources, "/WEB-INF", resourcePaths);
- }
-
- // Return the completed set
- return (resourcePaths);
-
- }
-
- /*
- * Scans the web application's subdirectory identified by rootPath,
- * along with its subdirectories, for TLDs.
- *
- * Initially, rootPath equals /WEB-INF. The /WEB-INF/classes and
- * /WEB-INF/lib subdirectories are excluded from the search, as per the
- * JSP 2.0 spec.
- *
- * @param resources The web application's resources
- * @param rootPath The path whose subdirectories are to be searched for
- * TLDs
- * @param tldPaths The set of TLD resource paths to add to
- */
- private void tldScanResourcePathsWebInf(DirContext resources,
- String rootPath,
- Set tldPaths)
- throws IOException {
-
- if (log.isTraceEnabled()) {
- log.trace(" Scanning TLDs in " + rootPath + " subdirectory");
- }
-
- try {
- NamingEnumeration items = resources.list(rootPath);
- while (items.hasMoreElements()) {
- NameClassPair item = (NameClassPair) items.nextElement();
- String resourcePath = rootPath + "/" + item.getName();
- if (!resourcePath.endsWith(".tld")
- && (resourcePath.startsWith("/WEB-INF/classes")
- || resourcePath.startsWith("/WEB-INF/lib"))) {
- continue;
- }
- if (resourcePath.endsWith(".tld")) {
- if (log.isTraceEnabled()) {
- log.trace(" Adding path '" + resourcePath + "'");
- }
- tldPaths.add(resourcePath);
- } else {
- tldScanResourcePathsWebInf(resources, resourcePath,
- tldPaths);
- }
- }
- } catch (NamingException e) {
- ; // Silent catch: it's valid that no /WEB-INF directory exists
- }
- }
-
- /**
- * Returns a map of the paths to all JAR files that are accessible to the
- * webapp and will be scanned for TLDs.
- *
- * The map always includes all the JARs under WEB-INF/lib, as well as
- * shared JARs in the classloader delegation chain of the webapp's
- * classloader.
- *
- * The latter constitutes a Tomcat-specific extension to the TLD search
- * order defined in the JSP spec. It allows tag libraries packaged as JAR
- * files to be shared by web applications by simply dropping them in a
- * location that all web applications have access to (e.g.,
- * <CATALINA_HOME>/common/lib).
- *
- * The set of shared JARs to be scanned for TLDs is narrowed down by
- * the <tt>noTldJars</tt> class variable, which contains the names of JARs
- * that are known not to contain any TLDs.
- *
- * @return Map of JAR file paths
- */
- private Map<String, File> getJarPaths() {
-
- HashMap<String, File> jarPathMap = null;
-
- ClassLoader webappLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader loader = webappLoader;
- while (loader != null) {
- if (loader instanceof URLClassLoader) {
- URL[] urls = ((URLClassLoader) loader).getURLs();
- for (int i=0; i<urls.length; i++) {
- // Expect file URLs, these are %xx encoded or not depending on
- // the class loader
- // This is definitely not as clean as using JAR URLs either
- // over file or the custom jndi handler, but a lot less
- // buggy overall
- File file = null;
- try {
- file = new File(urls[i].toURI());
- } catch (Exception e) {
- // Ignore, probably an unencoded char or non file URL,
- // attempt direct access
- file = new File(urls[i].getFile());
- }
- try {
- file = file.getCanonicalFile();
- } catch (IOException e) {
- // Ignore
- }
- if (!file.exists()) {
- continue;
- }
- String path = file.getAbsolutePath();
- if (!path.endsWith(".jar")) {
- continue;
- }
- /*
- * Scan all JARs from WEB-INF/lib, plus any shared JARs
- * that are not known not to contain any TLDs
- */
- if (loader == webappLoader
- || noDescriptorsJars == null
- || !noDescriptorsJars.contains(file.getName())) {
- if (jarPathMap == null) {
- jarPathMap = new HashMap();
- jarPathMap.put(path, file);
- } else if (!jarPathMap.containsKey(path)) {
- jarPathMap.put(path, file);
- }
- }
- }
- }
- loader = loader.getParent();
- }
-
- return jarPathMap;
- }
-}
Deleted: trunk/java/org/apache/tomcat/WarComponents.java
===================================================================
--- trunk/java/org/apache/tomcat/WarComponents.java 2009-06-06 22:23:25 UTC (rev 1089)
+++ trunk/java/org/apache/tomcat/WarComponents.java 2009-06-06 22:34:44 UTC (rev 1090)
@@ -1,58 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.apache.tomcat;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-public interface WarComponents {
-
- public interface ServletContainerInitializerInfo {
- public Set<Class<?>> getStartupNotifySet();
- public Class<?>[] getInterestClasses();
- public Class<?> getServletContainerInitializer();
- }
-
- /**
- * Find JAR files containing an overlay.
- */
- public Iterator<String> getOverlays();
-
- /**
- * Find JAR files containing a web fragment.
- */
- public Iterator<String> getWebFragments();
-
- /**
- * Find TLDs.
- */
- public Map<String, Set<String>> getTLDs();
-
- /**
- * Find Jar services.
- */
- public Map<String, ServletContainerInitializerInfo> getServletContainerInitializerInfo();
-
-}
Modified: trunk/res/confinstall/server_2.xml
===================================================================
--- trunk/res/confinstall/server_2.xml 2009-06-06 22:23:25 UTC (rev 1089)
+++ trunk/res/confinstall/server_2.xml 2009-06-06 22:34:44 UTC (rev 1090)
@@ -35,8 +35,7 @@
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
- unpackWARs="true" autoDeploy="true"
- xmlValidation="false" xmlNamespaceAware="false">
+ unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
15 years, 6 months
JBossWeb SVN: r1089 - in trunk: java/org/apache/jasper/compiler and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-06-06 18:23:25 -0400 (Sat, 06 Jun 2009)
New Revision: 1089
Modified:
trunk/ROADMAP.txt
trunk/java/org/apache/jasper/compiler/JspConfig.java
trunk/java/org/apache/jasper/compiler/PageInfo.java
trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
Log:
- Migrate JSP config to use the metadata from Catalina.
- The XML parsing code remains for now.
- JSPC will not longer work, of course (duplicating the handling the fragments specifically for such a tool is not
a very nice proposition).
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-06-06 22:18:39 UTC (rev 1088)
+++ trunk/ROADMAP.txt 2009-06-06 22:23:25 UTC (rev 1089)
@@ -1,7 +1,6 @@
Roadmap for JBoss Web 3.0
Standalone:
-- Jasper plugins for TLD metadata and web.xml metadata
- Access control annotations
- Update digester XML parsing rules for web.xml updates (session tracking-mode, cookie-config, servlet enabled,
servlets and filters async-supported, http-method-omission)
Modified: trunk/java/org/apache/jasper/compiler/JspConfig.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/JspConfig.java 2009-06-06 22:18:39 UTC (rev 1088)
+++ trunk/java/org/apache/jasper/compiler/JspConfig.java 2009-06-06 22:23:25 UTC (rev 1089)
@@ -1,34 +1,64 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*
- * 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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.jasper.compiler;
import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
-import java.util.Vector;
-import java.net.URL;
import javax.servlet.ServletContext;
+import org.apache.catalina.Globals;
import org.apache.jasper.JasperException;
import org.apache.jasper.xmlparser.ParserUtils;
import org.apache.jasper.xmlparser.TreeNode;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
import org.xml.sax.InputSource;
/**
@@ -46,7 +76,7 @@
// Logger
private Logger log = Logger.getLogger(JspConfig.class);
- private Vector jspProperties = null;
+ private ArrayList<JspPropertyGroup> jspProperties = null;
private ServletContext ctxt;
private boolean initialized = false;
@@ -100,20 +130,20 @@
return;
}
- jspProperties = new Vector();
+ jspProperties = new ArrayList<JspPropertyGroup>();
Iterator jspPropertyList = jspConfig.findChildren("jsp-property-group");
while (jspPropertyList.hasNext()) {
TreeNode element = (TreeNode) jspPropertyList.next();
Iterator list = element.findChildren();
- Vector urlPatterns = new Vector();
+ ArrayList<String> urlPatterns = new ArrayList<String>();
String pageEncoding = null;
String scriptingInvalid = null;
String elIgnored = null;
String isXml = null;
- Vector includePrelude = new Vector();
- Vector includeCoda = new Vector();
+ ArrayList<String> includePrelude = new ArrayList<String>();
+ ArrayList<String> includeCoda = new ArrayList<String>();
String deferredSyntaxAllowedAsLiteral = null;
String trimDirectiveWhitespaces = null;
@@ -123,7 +153,7 @@
String tname = element.getName();
if ("url-pattern".equals(tname))
- urlPatterns.addElement( element.getBody() );
+ urlPatterns.add( element.getBody() );
else if ("page-encoding".equals(tname))
pageEncoding = element.getBody();
else if ("is-xml".equals(tname))
@@ -133,9 +163,9 @@
else if ("scripting-invalid".equals(tname))
scriptingInvalid = element.getBody();
else if ("include-prelude".equals(tname))
- includePrelude.addElement(element.getBody());
+ includePrelude.add(element.getBody());
else if ("include-coda".equals(tname))
- includeCoda.addElement(element.getBody());
+ includeCoda.add(element.getBody());
else if ("deferred-syntax-allowed-as-literal".equals(tname))
deferredSyntaxAllowedAsLiteral = element.getBody();
else if ("trim-directive-whitespaces".equals(tname))
@@ -149,7 +179,7 @@
// Add one JspPropertyGroup for each URL Pattern. This makes
// the matching logic easier.
for( int p = 0; p < urlPatterns.size(); p++ ) {
- String urlPattern = (String)urlPatterns.elementAt( p );
+ String urlPattern = urlPatterns.get(p);
String path = null;
String extension = null;
@@ -198,7 +228,7 @@
JspPropertyGroup propertyGroup =
new JspPropertyGroup(path, extension, property);
- jspProperties.addElement(propertyGroup);
+ jspProperties.add(propertyGroup);
}
}
} catch (Exception ex) {
@@ -215,7 +245,82 @@
private void init() throws JasperException {
if (!initialized) {
- processWebDotXml(ctxt);
+ //processWebDotXml(ctxt);
+ HashMap<String, org.apache.catalina.deploy.JspPropertyGroup> jspPropertyGroups =
+ (HashMap<String, org.apache.catalina.deploy.JspPropertyGroup>)
+ ctxt.getAttribute(Globals.JSP_PROPERTY_GROUPS);
+
+ String versionString = (String) ctxt.getAttribute(Globals.SERVLET_VERSION);
+ double version = 2.3;
+ if (versionString != null) {
+ try {
+ version = Double.parseDouble(versionString);
+ } catch (NumberFormatException e) {
+ }
+ }
+ if (version < 2.4) {
+ defaultIsELIgnored = "true";
+ }
+
+ jspProperties = new ArrayList<JspPropertyGroup>();
+ Iterator<String> urlPatternIterator = jspPropertyGroups.keySet().iterator();
+ while (urlPatternIterator.hasNext()) {
+ String urlPattern = urlPatternIterator.next();
+ org.apache.catalina.deploy.JspPropertyGroup jspPropertyGroup =
+ jspPropertyGroups.get(urlPattern);
+
+ String path = null;
+ String extension = null;
+
+ if (urlPattern.indexOf('*') < 0) {
+ // Exact match
+ path = urlPattern;
+ } else {
+ int i = urlPattern.lastIndexOf('/');
+ String file;
+ if (i >= 0) {
+ path = urlPattern.substring(0,i+1);
+ file = urlPattern.substring(i+1);
+ } else {
+ file = urlPattern;
+ }
+
+ // pattern must be "*", or of the form "*.jsp"
+ if (file.equals("*")) {
+ extension = "*";
+ } else if (file.startsWith("*.")) {
+ extension = file.substring(file.indexOf('.')+1);
+ }
+
+ // The url patterns are reconstructed as the follwoing:
+ // path != null, extension == null: / or /foo/bar.ext
+ // path == null, extension != null: *.ext
+ // path != null, extension == "*": /foo/*
+ boolean isStar = "*".equals(extension);
+ if ((path == null && (extension == null || isStar))
+ || (path != null && !isStar)) {
+ log.warn(Localizer.getMessage(
+ "jsp.warning.bad.urlpattern.propertygroup",
+ urlPattern));
+ continue;
+ }
+ }
+
+ JspProperty property = new JspProperty(jspPropertyGroup.getIsXml(),
+ jspPropertyGroup.getElIgnored(),
+ jspPropertyGroup.getScriptingInvalid(),
+ jspPropertyGroup.getPageEncoding(),
+ jspPropertyGroup.getIncludePreludes(),
+ jspPropertyGroup.getIncludeCodas(),
+ jspPropertyGroup.getDeferredSyntaxAllowedAsLiteral(),
+ jspPropertyGroup.getTrimDirectiveWhitespaces());
+ JspPropertyGroup propertyGroup =
+ new JspPropertyGroup(path, extension, property);
+
+ jspProperties.add(propertyGroup);
+
+ }
+
defaultJspProperty = new JspProperty(defaultIsXml,
defaultIsELIgnored,
defaultIsScriptingInvalid,
@@ -287,8 +392,8 @@
uriExtension = uri.substring(index+1);
}
- Vector includePreludes = new Vector();
- Vector includeCodas = new Vector();
+ ArrayList<String> includePreludes = new ArrayList<String>();
+ ArrayList<String> includeCodas = new ArrayList<String>();
JspPropertyGroup isXmlMatch = null;
JspPropertyGroup elIgnoredMatch = null;
@@ -297,10 +402,10 @@
JspPropertyGroup deferedSyntaxAllowedAsLiteralMatch = null;
JspPropertyGroup trimDirectiveWhitespacesMatch = null;
- Iterator iter = jspProperties.iterator();
+ Iterator<JspPropertyGroup> iter = jspProperties.iterator();
while (iter.hasNext()) {
- JspPropertyGroup jpg = (JspPropertyGroup) iter.next();
+ JspPropertyGroup jpg = iter.next();
JspProperty jp = jpg.getJspProperty();
// (arrays will be the same length)
@@ -473,14 +578,14 @@
private String elIgnored;
private String scriptingInvalid;
private String pageEncoding;
- private Vector includePrelude;
- private Vector includeCoda;
+ private ArrayList<String> includePrelude;
+ private ArrayList<String> includeCoda;
private String deferedSyntaxAllowedAsLiteral;
private String trimDirectiveWhitespaces;
public JspProperty(String isXml, String elIgnored,
String scriptingInvalid, String pageEncoding,
- Vector includePrelude, Vector includeCoda,
+ ArrayList<String> includePrelude, ArrayList<String> includeCoda,
String deferedSyntaxAllowedAsLiteral,
String trimDirectiveWhitespaces) {
@@ -510,11 +615,11 @@
return pageEncoding;
}
- public Vector getIncludePrelude() {
+ public ArrayList<String> getIncludePrelude() {
return includePrelude;
}
- public Vector getIncludeCoda() {
+ public ArrayList<String> getIncludeCoda() {
return includeCoda;
}
Modified: trunk/java/org/apache/jasper/compiler/PageInfo.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/PageInfo.java 2009-06-06 22:18:39 UTC (rev 1088)
+++ trunk/java/org/apache/jasper/compiler/PageInfo.java 2009-06-06 22:23:25 UTC (rev 1089)
@@ -16,6 +16,7 @@
*/
package org.apache.jasper.compiler;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -23,13 +24,13 @@
import java.util.List;
import java.util.Vector;
+import javax.el.ExpressionFactory;
+import javax.servlet.jsp.tagext.TagLibraryInfo;
+
import org.apache.el.ExpressionFactoryImpl;
import org.apache.jasper.Constants;
import org.apache.jasper.JasperException;
-import javax.el.ExpressionFactory;
-import javax.servlet.jsp.tagext.TagLibraryInfo;
-
/**
* A repository for various info about the translation unit under compilation.
*
@@ -89,8 +90,8 @@
private HashSet prefixes;
private boolean hasJspRoot = false;
- private Vector includePrelude;
- private Vector includeCoda;
+ private ArrayList<String> includePrelude;
+ private ArrayList<String> includeCoda;
private Vector pluginDcls; // Id's for tagplugin declarations
@@ -104,8 +105,8 @@
this.nonCustomTagPrefixMap = new HashMap();
this.imports = new Vector();
this.dependants = new Vector();
- this.includePrelude = new Vector();
- this.includeCoda = new Vector();
+ this.includePrelude = new ArrayList<String>();
+ this.includeCoda = new ArrayList<String>();
this.pluginDcls = new Vector();
this.prefixes = new HashSet();
@@ -175,7 +176,7 @@
return includePrelude;
}
- public void setIncludePrelude(Vector prelude) {
+ public void setIncludePrelude(ArrayList<String> prelude) {
includePrelude = prelude;
}
@@ -183,7 +184,7 @@
return includeCoda;
}
- public void setIncludeCoda(Vector coda) {
+ public void setIncludeCoda(ArrayList<String> coda) {
includeCoda = coda;
}
Modified: trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 22:18:39 UTC (rev 1088)
+++ trunk/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 2009-06-06 22:23:25 UTC (rev 1089)
@@ -1,20 +1,49 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*
- * 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.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.jasper.compiler;
import java.io.FileInputStream;
15 years, 6 months