Author: remy.maucherat(a)jboss.com
Date: 2008-02-21 18:05:58 -0500 (Thu, 21 Feb 2008)
New Revision: 445
Modified:
trunk/java/org/apache/jasper/JspCompilationContext.java
trunk/java/org/apache/jasper/compiler/Compiler.java
trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
trunk/webapps/docs/changelog.xml
Log:
- Optimize handling of tags in JARs.
Modified: trunk/java/org/apache/jasper/JspCompilationContext.java
===================================================================
--- trunk/java/org/apache/jasper/JspCompilationContext.java 2008-02-19 18:49:23 UTC (rev
444)
+++ trunk/java/org/apache/jasper/JspCompilationContext.java 2008-02-21 23:05:58 UTC (rev
445)
@@ -284,7 +284,25 @@
public URL getResource(String res) throws MalformedURLException {
- return context.getResource(canonicalURI(res));
+ URL result = null;
+
+ if (res.startsWith("/META-INF/")) {
+ // This is a tag file packaged in a jar that is being compiled
+ URL jarUrl = tagFileJarUrls.get(res);
+ if (jarUrl == null) {
+ jarUrl = tagFileJarUrl;
+ }
+ if (jarUrl != null) {
+ result = new URL(jarUrl.toExternalForm() + res.substring(1));
+ }
+ } else if (res.startsWith("jar:file:")) {
+ // This is a tag file packaged in a jar that is being checked
+ // for a dependency
+ result = new URL(res);
+ } else {
+ result = context.getResource(canonicalURI(res));
+ }
+ return result;
}
public Set getResourcePaths(String path) {
@@ -559,7 +577,7 @@
public void compile() throws JasperException, FileNotFoundException {
createCompiler();
- if (isPackagedTagFile || jspCompiler.isOutDated()) {
+ if (jspCompiler.isOutDated()) {
try {
jspCompiler.removeGeneratedFiles();
jspLoader = null;
Modified: trunk/java/org/apache/jasper/compiler/Compiler.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/Compiler.java 2008-02-19 18:49:23 UTC (rev 444)
+++ trunk/java/org/apache/jasper/compiler/Compiler.java 2008-02-21 23:05:58 UTC (rev 445)
@@ -23,6 +23,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
+import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Iterator;
@@ -376,7 +377,12 @@
return false;
}
URLConnection uc = jspUrl.openConnection();
- jspRealLastModified = uc.getLastModified();
+ if (uc instanceof JarURLConnection) {
+ jspRealLastModified =
+ ((JarURLConnection) uc).getJarEntry().getTime();
+ } else {
+ jspRealLastModified = uc.getLastModified();
+ }
uc.getInputStream().close();
} catch (Exception e) {
return true;
@@ -427,9 +433,15 @@
return true;
}
- URLConnection includeUconn = includeUrl.openConnection();
- long includeLastModified = includeUconn.getLastModified();
- includeUconn.getInputStream().close();
+ URLConnection iuc = includeUrl.openConnection();
+ long includeLastModified = 0;
+ if (iuc instanceof JarURLConnection) {
+ includeLastModified =
+ ((JarURLConnection) iuc).getJarEntry().getTime();
+ } else {
+ includeLastModified = iuc.getLastModified();
+ }
+ iuc.getInputStream().close();
if (includeLastModified > targetLastModified) {
return true;
Modified: trunk/java/org/apache/jasper/compiler/TagFileProcessor.java
===================================================================
--- trunk/java/org/apache/jasper/compiler/TagFileProcessor.java 2008-02-19 18:49:23 UTC
(rev 444)
+++ trunk/java/org/apache/jasper/compiler/TagFileProcessor.java 2008-02-21 23:05:58 UTC
(rev 445)
@@ -619,9 +619,18 @@
TagFileInfo tagFileInfo = n.getTagFileInfo();
if (tagFileInfo != null) {
String tagFilePath = tagFileInfo.getPath();
- JspCompilationContext ctxt = compiler.getCompilationContext();
- if (ctxt.getTagFileJarUrl(tagFilePath) == null) {
- // Omit tag file dependency info on jar files for now.
+ if (tagFilePath.startsWith("/META-INF/")) {
+ // For tags in JARs, add the TLD and the tag as a dependency
+ String[] location =
+ compiler.getCompilationContext().getTldLocation(
+ tagFileInfo.getTagInfo().getTagLibrary().getURI());
+ // Add TLD
+ pageInfo.addDependant("jar:" + location[0] + "!/"
+
+ location[1]);
+ // Add Tag
+ pageInfo.addDependant("jar:" + location[0] + "!"
+
+ tagFilePath);
+ } else {
pageInfo.addDependant(tagFilePath);
}
Class c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-02-19 18:49:23 UTC (rev 444)
+++ trunk/webapps/docs/changelog.xml 2008-02-21 23:05:58 UTC (rev 445)
@@ -225,6 +225,9 @@
<bug>43925</bug>: Optimize allocation style for bodies (this removes
the no-GC mode, however),
submitted by Brian Remmington. (remm)
</fix>
+ <fix>
+ <bug>43741</bug>: Improve handling of tags inside JARs. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Webapps">
Show replies by date