glenn 01/02/03 17:03:43
Modified: jasper/src/share/org/apache/jasper JspC.java
Log:
- Implemented Java SecurityManager
- Switched to using URLClassLoader
Jasper now creates a URLClassLoader for each JSP page and defers any other
class loading to the web app context class loader. Using a single class
loader per JSP allowed me to remove all the code that increments the
class version number, i.e. the work directory no longer has multiple
*.java and *.class files for the same JSP page. These changes also made
it easy for me to put the java source and class files in the same directory
tree as found in the web app context. When Jasper is run in a servlet
container it no longer puts the class files in a package, they are now
in the default package.
Revision Changes Path
1.8 +14 -18 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspC.java
Index: JspC.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspC.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- JspC.java 2000/12/22 01:27:37 1.7
+++ JspC.java 2001/02/04 01:03:42 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspC.java,v 1.7
2000/12/22 01:27:37 pierred Exp $
- * $Revision: 1.7 $
- * $Date: 2000/12/22 01:27:37 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/JspC.java,v 1.8
2001/02/04 01:03:42 glenn Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/02/04 01:03:42 $
*
* ====================================================================
*
@@ -62,6 +62,7 @@
package org.apache.jasper;
import java.io.*;
+import java.net.*;
import java.util.*;
import org.apache.jasper.compiler.JspReader;
@@ -71,7 +72,6 @@
import org.apache.jasper.compiler.CommandLineCompiler;
import org.apache.jasper.compiler.TldLocationsCache;
-//import org.apache.jasper.runtime.JspLoader;
import org.apache.jasper.servlet.JasperLoader;
import org.apache.jasper.logging.Logger;
@@ -145,8 +145,6 @@
static int die; // I realize it is duplication, but this is for
// the static main catch
- //JspLoader loader;
-
boolean dirset;
Vector extensions;
@@ -194,10 +192,6 @@
return scratchDir;
}
- //public String getClassPath() {
- // return classpath;
- //}
-
public Class getJspCompilerPlugin() {
// we don't compile, so this is meanlingless
return null;
@@ -339,28 +333,25 @@
public boolean parseFile(PrintStream log, String file, Writer servletout,
Writer mappingout)
{
try {
- JasperLoader loader = new JasperLoader();
- loader.setParentClassLoader(getClass().getClassLoader());
- loader.setOptions( this);
CommandLineContext clctxt = new CommandLineContext(
- loader, getClassPath(), file, uriBase, uriRoot, false,
+ getClassPath(), file, uriBase, uriRoot, false,
this);
if ((targetClassName != null) && (targetClassName.length() > 0)) {
clctxt.setServletClassName(targetClassName);
- clctxt.lockClassName();
}
if (targetPackage != null) {
clctxt.setServletPackageName(targetPackage);
- clctxt.lockPackageName();
}
if (dirset) {
clctxt.setOutputInDirs(true);
}
+ ArrayList urls = new ArrayList();
+
if (new File(clctxt.getRealPath("/")).exists()) {
File classes = new File(clctxt.getRealPath("/WEB-INF/classes"));
try {
if (classes.exists()) {
- loader.addJar(classes.getCanonicalPath());
+ urls.add(classes.toURL());
}
} catch (IOException ioe) {
// failing a toCanonicalPath on a file that
@@ -373,9 +364,10 @@
String[] libs = lib.list();
for (int i = 0; i < libs.length; i++) {
try {
- loader.addJar(lib.getCanonicalPath()
+ File libFile = new File(lib.toString()
+ File.separator
+ libs[i]);
+ urls.add(libFile.toURL());
} catch (IOException ioe) {
// failing a toCanonicalPath on a file that
// exists() should be a JVM regression test,
@@ -385,6 +377,9 @@
}
}
}
+ URLClassLoader loader = new URLClassLoader(
+ (URL[])(urls.toArray(new URL[urls.size()])),null);
+ clctxt.setClassLoader(loader);
CommandLineCompiler clc = new CommandLineCompiler(clctxt);
clc.compile();
@@ -425,6 +420,7 @@
} catch (Exception e) {
Constants.message("jspc.error.generalException",
new Object[] {file, e}, Logger.ERROR);
+ e.printStackTrace();
if (dieLevel != NO_DIE_LEVEL) {
dieOnExit = true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]