glenn 01/02/03 17:03:04
Modified: jasper/src/share/org/apache/jasper CommandLineContext.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.5 +17 -58
jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java
Index: CommandLineContext.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CommandLineContext.java 2000/11/06 20:52:18 1.4
+++ CommandLineContext.java 2001/02/04 01:03:04 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java,v
1.4 2000/11/06 20:52:18 pierred Exp $
- * $Revision: 1.4 $
- * $Date: 2000/11/06 20:52:18 $
+ * $Header:
/home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/CommandLineContext.java,v
1.5 2001/02/04 01:03:04 glenn Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/02/04 01:03:04 $
*
* ====================================================================
*
@@ -73,10 +73,8 @@
import org.apache.jasper.compiler.CommandLineCompiler;
import org.apache.jasper.compiler.Compiler;
-//import org.apache.jasper.runtime.JspLoader;
-// Use the jasper loader - the only function used is to add a jar
-import org.apache.jasper.servlet.JasperLoader;
import java.net.URL;
+import java.net.URLClassLoader;
import java.net.MalformedURLException;
/**
@@ -92,7 +90,7 @@
String classPath;
JspReader reader;
ServletWriter writer;
- JasperLoader loader;
+ URLClassLoader loader;
boolean errPage;
String jspFile;
String servletClassName;
@@ -104,17 +102,14 @@
String uriBase;
File uriRoot;
- boolean packageNameLocked;
- boolean classNameLocked;
boolean outputInDirs;
- public CommandLineContext(JasperLoader newLoader, String newClassPath,
+ public CommandLineContext(String newClassPath,
String newJspFile, String newUriBase,
String newUriRoot, boolean newErrPage,
Options newOptions)
throws JasperException
{
- loader = newLoader;
classPath = newClassPath;
uriBase = newUriBase;
String tUriRoot = newUriRoot;
@@ -175,10 +170,6 @@
return loader;
}
- public void addJar( String jar ) throws IOException {
- loader.addJar( jar );
- }
-
/**
* Are we processing something that has been declared as an
* errorpage?
@@ -213,37 +204,18 @@
}
/**
- * The package name into which the servlet class is generated.
+ * The package name for the generated class.
*/
public String getServletPackageName() {
return servletPackageName;
}
/**
- * Utility method to get the full class name from the package and
- * class name.
- */
- public String getFullClassName() {
- String pkg = getServletPackageName();
- if (pkg != null) {
- pkg += ".";
- } else {
- pkg = "";
- }
- return pkg + getServletClassName();
- }
-
- /**
* Full path name of the Java file into which the servlet is being
* generated.
*/
public String getServletJavaFileName() {
- if (outputInDirs) {
- return getServletPackageName().replace('.', File.separatorChar)
- + servletJavaFileName;
- } else {
- return servletJavaFileName;
- }
+ return servletJavaFileName;
}
/**
@@ -268,6 +240,10 @@
return options;
}
+ public void setClassLoader(URLClassLoader loader) {
+ this.loader = loader;
+ }
+
public void setContentType(String contentType) {
this.contentType = contentType;
}
@@ -281,19 +257,11 @@
}
public void setServletClassName(String servletClassName) {
- if (classNameLocked) {
- //System.out.println("Did not change clazz to " + servletClassName);
- } else {
- this.servletClassName = servletClassName;
- }
+ this.servletClassName = servletClassName;
}
-
+
public void setServletPackageName(String servletPackageName) {
- if (packageNameLocked) {
- //System.out.println("Did not change pkg to " + servletPackageName);
- } else {
- this.servletPackageName = servletPackageName;
- }
+ this.servletPackageName = servletPackageName;
}
public void setServletJavaFileName(String servletJavaFileName) {
@@ -304,14 +272,6 @@
errPage = isErrPage;
}
- public void lockPackageName() {
- packageNameLocked = true;
- }
-
- public void lockClassName() {
- classNameLocked = true;
- }
-
public void setOutputInDirs(boolean newValue) {
outputInDirs = true;
}
@@ -372,11 +332,10 @@
return in;
}
- public java.net.URL getResource(String res)
+ public URL getResource(String res)
throws MalformedURLException
{
- // FIXME @@@
- return null;
+ return loader.getResource(res);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]