luehe 2002/08/03 16:29:21
Modified: jasper2/src/share/org/apache/jasper
JspCompilationContext.java
jasper2/src/share/org/apache/jasper/compiler Compiler.java
Generator.java JspRuntimeContext.java
TagFileProcessor.java
jasper2/src/share/org/apache/jasper/servlet
JspServletWrapper.java
Log:
Store tag file .java and .class files in standard location
("/tagfiles/org/apache/jsp/"), regardless of the original tag file
path, and add this standard location to the compilation classpath for
JSP pages
Revision Changes Path
1.14 +44 -32 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java
Index: JspCompilationContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- JspCompilationContext.java 1 Aug 2002 23:29:36 -0000 1.13
+++ JspCompilationContext.java 3 Aug 2002 23:29:21 -0000 1.14
@@ -115,16 +115,20 @@
protected boolean reload = true;
protected URLClassLoader jspLoader;
- protected URL [] outUrls = new URL[1];
+ protected URL[] outUrls = new URL[1];
protected Class servletClass;
protected boolean isTagFile;
protected TagInfo tagInfo;
// jspURI _must_ be relative to the context
- public JspCompilationContext(String jspUri, boolean isErrPage, Options options,
- ServletContext context, JspServletWrapper jsw,
+ public JspCompilationContext(String jspUri,
+ boolean isErrPage,
+ Options options,
+ ServletContext context,
+ JspServletWrapper jsw,
JspRuntimeContext rctxt) {
+
this.jspUri = canonicalURI(jspUri);
this.isErrPage = isErrPage;
this.options=options;
@@ -146,9 +150,11 @@
this.rctxt=rctxt;
}
- public JspCompilationContext(String tagfile, TagInfo tagInfo,
+ public JspCompilationContext(String tagfile,
+ TagInfo tagInfo,
Options options,
- ServletContext context, JspServletWrapper jsw,
+ ServletContext context,
+ JspServletWrapper jsw,
JspRuntimeContext rctxt) {
this(tagfile, false, options, context, jsw, rctxt);
@@ -200,8 +206,8 @@
return outputDir;
}
- public void setOutputDir( String s ) {
- this.outputDir=s;
+ public void setOutputDir(String s) {
+ this.outputDir = s;
}
/**
@@ -396,17 +402,23 @@
if (jspPath != null) {
return jspPath;
}
- String dirName = getJspFile();
- int pos = dirName.lastIndexOf('/');
- if (pos > 0) {
- dirName = dirName.substring(0, pos + 1);
- } else {
- dirName = "";
- }
- jspPath = dirName + getServletClassName() + ".java";
- if (jspPath.startsWith("/")) {
- jspPath = jspPath.substring(1);
- }
+
+ if (isTagFile) {
+ jspPath = "tagfiles/org/apache/jsp/" + tagInfo.getTagName() + ".java";
+ } else {
+ String dirName = getJspFile();
+ int pos = dirName.lastIndexOf('/');
+ if (pos > 0) {
+ dirName = dirName.substring(0, pos + 1);
+ } else {
+ dirName = "";
+ }
+ jspPath = dirName + getServletClassName() + ".java";
+ if (jspPath.startsWith("/")) {
+ jspPath = jspPath.substring(1);
+ }
+ }
+
return jspPath;
}
@@ -508,7 +520,7 @@
public void compile() throws JasperException, FileNotFoundException {
createCompiler();
- if (jspCompiler.isOutDated()) {
+ if (jspCompiler.isOutDated()) {
try {
jspCompiler.compile();
reload = true;
@@ -518,7 +530,7 @@
throw new JasperException(
Constants.getString("jsp.error.unable.compile"),ex);
}
- }
+ }
}
/** True if the servlet needs loading
@@ -568,24 +580,24 @@
return servletClass;
}
- public void createOutdir() {
+ public void createOutdir(String dirPath) {
File outDirF = null;
try {
URL outURL = options.getScratchDir().toURL();
- String outURI = outURL.toString();
- if (outURI.endsWith("/")) {
- outURI = outURI
- + jspUri.substring(1,jspUri.lastIndexOf("/")+1);
+ String outUri = outURL.toString();
+ if (outUri.endsWith("/")) {
+ outUri = outUri
+ + dirPath.substring(1, dirPath.lastIndexOf("/") + 1);
} else {
- outURI = outURI
- + jspUri.substring(0,jspUri.lastIndexOf("/")+1);
+ outUri = outUri
+ + dirPath.substring(0, dirPath.lastIndexOf("/") + 1);
}
- outURL = new URL(outURI);
+ outURL = new URL(outUri);
outDirF = new File(outURL.getFile());
if (!outDirF.exists()) {
outDirF.mkdirs();
}
- this.setOutputDir( outDirF.toString() + File.separator );
+ this.outputDir = outDirF.toString() + File.separator;
outUrls[0] = new URL(outDirF.toURL().toString() + File.separator);
} catch (Exception e) {
1.23 +4 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java
Index: Compiler.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Compiler.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Compiler.java 31 Jul 2002 21:42:27 -0000 1.22
+++ Compiler.java 3 Aug 2002 23:29:21 -0000 1.23
@@ -241,7 +241,7 @@
// Collect page info
Collector.collect(this, pageNodes);
- // Compile (if necessar) and load the tag files referenced in
+ // Compile (if necessary) and load the tag files referenced in
// this compilation unit.
TagFileProcessor.loadTagFiles(this, pageNodes);
1.61 +11 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java
Index: Generator.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- Generator.java 2 Aug 2002 21:13:33 -0000 1.60
+++ Generator.java 3 Aug 2002 23:29:21 -0000 1.61
@@ -2753,11 +2753,14 @@
// Generate package declaration
String className = tagInfo.getTagClassName();
- String pkgName = className.substring(0, className.lastIndexOf("."));
- out.printin("package ");
- out.print(pkgName);
- out.println(";");
- out.println();
+ if (className.indexOf('.') != -1) {
+ String pkgName
+ = className.substring(0, className.lastIndexOf("."));
+ out.printin("package ");
+ out.print(pkgName);
+ out.println(";");
+ out.println();
+ }
// Generate class declaration
out.printin("public class ");
1.5 +6 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspRuntimeContext.java
Index: JspRuntimeContext.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspRuntimeContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JspRuntimeContext.java 21 Jun 2002 17:11:32 -0000 1.4
+++ JspRuntimeContext.java 3 Aug 2002 23:29:21 -0000 1.5
@@ -352,6 +352,8 @@
}
}
+ cpath.append(options.getScratchDir() + "/tagfiles" + sep);
+
String cp = (String) context.getAttribute(Constants.SERVLET_CLASSPATH);
if (cp == null || cp.equals("")) {
cp = options.getClassPath();
1.9 +8 -8 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java
Index: TagFileProcessor.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TagFileProcessor.java 2 Aug 2002 19:30:02 -0000 1.8
+++ TagFileProcessor.java 3 Aug 2002 23:29:21 -0000 1.9
@@ -342,19 +342,19 @@
* Compiles and loads a tagfile.
*/
public static Class loadTagFile(JspCompilationContext ctxt,
- String tagFile, TagInfo tagInfo)
+ String tagFilePath, TagInfo tagInfo)
throws JasperException {
JspRuntimeContext rctxt = ctxt.getRuntimeContext();
JspServletWrapper wrapper =
- (JspServletWrapper) rctxt.getWrapper(tagFile);
+ (JspServletWrapper) rctxt.getWrapper(tagFilePath);
if (wrapper == null) {
synchronized(rctxt) {
- wrapper = (JspServletWrapper) rctxt.getWrapper(tagFile);
+ wrapper = (JspServletWrapper) rctxt.getWrapper(tagFilePath);
if (wrapper == null) {
wrapper = new JspServletWrapper(ctxt.getServletContext(),
ctxt.getOptions(),
- tagFile,
+ tagFilePath,
tagInfo,
ctxt.getRuntimeContext());
}
@@ -379,8 +379,8 @@
public void visit(Node.CustomTag n) throws JasperException {
TagFileInfo tagFileInfo = n.getTagFileInfo();
if (tagFileInfo != null) {
- String tagFile = tagFileInfo.getPath();
- Class c = loadTagFile(ctxt, tagFile, n.getTagInfo());
+ String tagFilePath = tagFileInfo.getPath();
+ Class c = loadTagFile(ctxt, tagFilePath, n.getTagInfo());
n.setTagHandlerClass(c);
}
}
1.11 +30 -15 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java
Index: JspServletWrapper.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JspServletWrapper.java 1 Aug 2002 23:29:36 -0000 1.10
+++ JspServletWrapper.java 3 Aug 2002 23:29:21 -0000 1.11
@@ -113,6 +113,9 @@
private ServletConfig config;
private Options options;
+ /*
+ * JspServletWrapper for JSP pages.
+ */
JspServletWrapper(ServletConfig config, Options options, String jspUri,
boolean isErrorPage, JspRuntimeContext rctxt)
throws JasperException {
@@ -120,25 +123,37 @@
this.config = config;
this.options = options;
this.jspUri = jspUri;
- ctxt = new JspCompilationContext( jspUri, isErrorPage,
- options,
- config.getServletContext(),
- this, rctxt);
- ctxt.createOutdir();
+ ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
+ config.getServletContext(),
+ this, rctxt);
+ ctxt.createOutdir(jspUri);
}
+ /*
+ * JspServletWrapper for tag files.
+ */
public JspServletWrapper(ServletContext servletContext, Options options,
- String tagfile, TagInfo tagInfo, JspRuntimeContext rctxt)
+ String tagFilePath, TagInfo tagInfo,
+ JspRuntimeContext rctxt)
throws JasperException {
this.config = null; // not used
this.options = options;
- this.jspUri = tagfile;
- ctxt = new JspCompilationContext( tagfile, tagInfo,
- options,
- servletContext,
- this, rctxt);
- ctxt.createOutdir();
+ this.jspUri = tagFilePath;
+ ctxt = new JspCompilationContext(jspUri, tagInfo, options,
+ servletContext, this, rctxt);
+
+ // Store tag file .java and .class files in standard location
+ // (/tagfiles/org/apache/jsp/), regardless of the original tag file
+ // path
+ String standard = null;
+ if (tagFilePath.indexOf('/') != -1) {
+ standard = "/tagfiles/org/apache/jsp/"
+ + tagFilePath.substring(tagFilePath.lastIndexOf("/") + 1);
+ } else {
+ standard = "/tagfiles/org/apache/jsp/" + tagFilePath;
+ }
+ ctxt.createOutdir(standard);
}
public JspCompilationContext getJspEngineContext() {
--
To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>
|