luehe 2002/10/21 11:44:01 Modified: jasper2/src/share/org/apache/jasper JspC.java JspCompilationContext.java jasper2/src/share/org/apache/jasper/servlet JasperLoader.java Log: Reduced visibility of fields/methods where appropriate Revision Changes Path 1.16 +3 -4 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- JspC.java 10 Oct 2002 00:49:21 -0000 1.15 +++ JspC.java 21 Oct 2002 18:44:00 -0000 1.16 @@ -69,7 +69,6 @@ import org.apache.jasper.compiler.Compiler; import org.apache.jasper.compiler.TldLocationsCache; -import org.apache.jasper.servlet.JasperLoader; import org.apache.jasper.servlet.JspCServletContext; import org.apache.jasper.logging.Logger; 1.23 +38 -36 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- JspCompilationContext.java 10 Oct 2002 00:49:21 -0000 1.22 +++ JspCompilationContext.java 21 Oct 2002 18:44:00 -0000 1.23 @@ -91,38 +91,38 @@ private Hashtable tagFileJars; private boolean isPackagedTagFile; - protected String servletClassName; - protected String jspUri; + private String servletClassName; + private String jspUri; private boolean isErrPage; - protected String servletPackageName = Constants.JSP_PACKAGE_NAME; - protected String servletJavaFileName; - protected String jspPath; - protected String classFileName; - protected String contentType; - protected ServletWriter writer; - protected Options options; - protected JspServletWrapper jsw; - protected Compiler jspCompiler; - protected String classPath; - - protected String baseURI; - protected String outputDir; - protected ServletContext context; - protected URLClassLoader loader; + private String servletPackageName; + private String servletJavaFileName; + private String jspPath; + private String classFileName; + private String contentType; + private ServletWriter writer; + private Options options; + private JspServletWrapper jsw; + private Compiler jspCompiler; + private String classPath; + + private String baseURI; + private String outputDir; + private ServletContext context; + private URLClassLoader loader; - protected JspRuntimeContext rctxt; + private JspRuntimeContext rctxt; - protected int removed = 0; - protected boolean reload = true; + private int removed = 0; + private boolean reload = true; - protected URLClassLoader jspLoader; - protected URL[] outUrls = new URL[2]; - protected Class servletClass; - - protected boolean isTagFile; - protected boolean protoTypeMode; - protected TagInfo tagInfo; - protected TagData tagData; + private URLClassLoader jspLoader; + private URL[] outUrls; + private Class servletClass; + + private boolean isTagFile; + private boolean protoTypeMode; + private TagInfo tagInfo; + private TagData tagData; // jspURI _must_ be relative to the context public JspCompilationContext(String jspUri, @@ -134,10 +134,10 @@ this.jspUri = canonicalURI(jspUri); this.isErrPage = isErrPage; - this.options=options; - this.jsw=jsw; - this.context=context; - + this.options = options; + this.jsw = jsw; + this.context = context; + this.baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1); // hack fix for resolveRelativeURI if (baseURI == null) { @@ -150,9 +150,11 @@ if (baseURI.charAt(baseURI.length() - 1) != '/') { baseURI += '/'; } - this.rctxt=rctxt; + this.rctxt = rctxt; this.tagFileJars = new Hashtable(); + this.servletPackageName = Constants.JSP_PACKAGE_NAME; + this.outUrls = new URL[2]; } public JspCompilationContext(String tagfile, 1.5 +28 -40 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java Index: JasperLoader.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/servlet/JasperLoader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JasperLoader.java 6 Aug 2002 00:11:36 -0000 1.4 +++ JasperLoader.java 21 Oct 2002 18:44:00 -0000 1.5 @@ -68,46 +68,30 @@ import java.security.PrivilegedAction; import java.security.ProtectionDomain; +import javax.servlet.http.*; + import org.apache.jasper.JasperException; import org.apache.jasper.Constants; -import org.apache.jasper.JspCompilationContext; -import org.apache.jasper.Options; -import org.apache.jasper.compiler.Compiler; -import org.apache.jasper.logging.Logger; -import javax.servlet.http.*; /** - * This is a class loader that loads JSP files as though they were - * Java classes. It calls the compiler to compile the JSP file into a - * servlet and then loads the generated class. + * Class loader for loading servlet class files (corresponding to JSP files) + * and tag handler class files (corresponding to tag files). * * @author Anil K. Vijendran * @author Harish Prabandham */ public class JasperLoader extends URLClassLoader { - protected class PrivilegedLoadClass - implements PrivilegedAction { - - PrivilegedLoadClass() { - } - - public Object run() { - return Thread.currentThread().getContextClassLoader(); - } - - } - - private PermissionCollection permissionCollection = null; - private CodeSource codeSource = null; - private String className = null; - private ClassLoader parent = null; - private SecurityManager securityManager = null; - private PrivilegedLoadClass privLoadClass = null; + private PermissionCollection permissionCollection; + private CodeSource codeSource; + private String className; + private ClassLoader parent; + private SecurityManager securityManager; + private PrivilegedLoadClass privLoadClass; public JasperLoader(URL [] urls, String className, ClassLoader parent, - PermissionCollection permissionCollection, - CodeSource codeSource) { + PermissionCollection permissionCollection, + CodeSource codeSource) { super(urls,parent); this.permissionCollection = permissionCollection; this.codeSource = codeSource; @@ -129,10 +113,8 @@ public Class loadClass(String name) throws ClassNotFoundException { return (loadClass(name, false)); - } - /** * Load the class with the specified name, searching using the following * algorithm until it finds and returns the class. If the class cannot @@ -173,7 +155,7 @@ // (.5) Permission to access this class when using a SecurityManager int dot = name.lastIndexOf('.'); - if (System.getSecurityManager() != null) { + if (securityManager != null) { if (dot >= 0) { try { securityManager.checkPackageAccess(name.substring(0,dot)); @@ -189,7 +171,7 @@ // Class is in a package, delegate to thread context class loader if( !name.startsWith(Constants.JSP_PACKAGE_NAME) ) { ClassLoader classLoader = null; - if (System.getSecurityManager() != null) { + if (securityManager != null) { classLoader = (ClassLoader)AccessController.doPrivileged(privLoadClass); } else { classLoader = Thread.currentThread().getContextClassLoader(); @@ -200,8 +182,8 @@ return clazz; } - // Only load classes for this JSP page - // (including tag handlers generated from tag files) + // Only load classes for this JSP page (including any tag handlers + // generated from tag files) if (name.startsWith(className)) { String classFile = name.substring(Constants.JSP_PACKAGE_NAME.length() + 1) @@ -210,7 +192,7 @@ if (cdata == null) { throw new ClassNotFoundException(name); } - if (System.getSecurityManager() != null) { + if (securityManager != null) { ProtectionDomain pd = new ProtectionDomain(codeSource, permissionCollection); clazz = defineClass(name, cdata, 0, cdata.length, pd); @@ -239,15 +221,14 @@ * @param CodeSource where the code was loaded from * @return PermissionCollection for CodeSource */ - protected final PermissionCollection getPermissions(CodeSource codeSource) { + public final PermissionCollection getPermissions(CodeSource codeSource) { return permissionCollection; } - - /** + /* * Load JSP class data from file. */ - protected byte[] loadClassDataFromFile(String fileName) { + private byte[] loadClassDataFromFile(String fileName) { byte[] classBytes = null; try { InputStream in = getResourceAsStream(fileName); @@ -256,8 +237,9 @@ } ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte buf[] = new byte[1024]; - for(int i = 0; (i = in.read(buf)) != -1; ) + for (int i = 0; (i = in.read(buf)) != -1; ) { baos.write(buf, 0, i); + } in.close(); baos.close(); classBytes = baos.toByteArray(); @@ -268,4 +250,10 @@ return classBytes; } + private class PrivilegedLoadClass implements PrivilegedAction { + + public Object run() { + return Thread.currentThread().getContextClassLoader(); + } + } }
-- To unsubscribe, e-mail: <mailto:tomcat-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:tomcat-dev-help@;jakarta.apache.org>