You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by gl...@apache.org on 2001/02/04 02:07:12 UTC
cvs commit: jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime JspRuntimeLibrary.java
glenn 01/02/03 17:07:12
Modified: jasper/src/share/org/apache/jasper/runtime
JspRuntimeLibrary.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 +56 -3 jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java
Index: JspRuntimeLibrary.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JspRuntimeLibrary.java 2000/11/20 23:49:08 1.4
+++ JspRuntimeLibrary.java 2001/02/04 01:07:12 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java,v 1.4 2000/11/20 23:49:08 pierred Exp $
- * $Revision: 1.4 $
- * $Date: 2000/11/20 23:49:08 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/runtime/JspRuntimeLibrary.java,v 1.5 2001/02/04 01:07:12 glenn Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/02/04 01:07:12 $
*
* ====================================================================
*
@@ -77,6 +77,10 @@
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
+
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletContext;
@@ -100,6 +104,34 @@
*/
public class JspRuntimeLibrary {
+ protected static class PrivilegedIntrospectHelper
+ implements PrivilegedExceptionAction {
+
+ private Object bean;
+ private String prop;
+ private String value;
+ private ServletRequest request;
+ private String param;
+ private boolean ignoreMethodNF;
+
+ PrivilegedIntrospectHelper(Object bean, String prop,
+ String value, ServletRequest request,
+ String param, boolean ignoreMethodNF)
+ {
+ this.bean = bean;
+ this.prop = prop;
+ this.value = value;
+ this.request = request;
+ this.param = param;
+ this.ignoreMethodNF = ignoreMethodNF;
+ }
+
+ public Object run() throws JasperException {
+ internalIntrospecthelper(
+ bean,prop,value,request,param,ignoreMethodNF);
+ return null;
+ }
+ }
// __begin convertMethod
public static Object convert(String propertyName, String s, Class t, Class propertyEditorClass)
@@ -164,6 +196,27 @@
// __begin introspecthelperMethod
public static void introspecthelper(Object bean, String prop,
+ String value, ServletRequest request,
+ String param, boolean ignoreMethodNF)
+ throws JasperException
+ {
+ if( System.getSecurityManager() != null ) {
+ try {
+ PrivilegedIntrospectHelper dp =
+ new PrivilegedIntrospectHelper(
+ bean,prop,value,request,param,ignoreMethodNF);
+ AccessController.doPrivileged(dp);
+ } catch( PrivilegedActionException pe) {
+ Exception e = pe.getException();
+ throw (JasperException)e;
+ }
+ } else {
+ internalIntrospecthelper(
+ bean,prop,value,request,param,ignoreMethodNF);
+ }
+ }
+
+ private static void internalIntrospecthelper(Object bean, String prop,
String value, ServletRequest request,
String param, boolean ignoreMethodNF)
throws JasperException