From: markt Date: Sat, 29 Dec 2007 19:28:41 +0000 (+0000) Subject: Fix bug 43878. When development mode isn't being used, use a single JasperLoader... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5fb475e26a2c09060976824b4711286a4dbf890e;p=tomcat7.0 Fix bug 43878. When development mode isn't being used, use a single JasperLoader. The main benefit is a reduction in the use of perm gen space when there are many JSPs all using the same few tags since the tags are loaded once rather than once per JSP. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@607464 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/JspCompilationContext.java b/java/org/apache/jasper/JspCompilationContext.java index b98e6fe35..0fe40f3db 100644 --- a/java/org/apache/jasper/JspCompilationContext.java +++ b/java/org/apache/jasper/JspCompilationContext.java @@ -34,7 +34,6 @@ import org.apache.jasper.compiler.JspRuntimeContext; import org.apache.jasper.compiler.JspUtil; import org.apache.jasper.compiler.Localizer; import org.apache.jasper.compiler.ServletWriter; -import org.apache.jasper.servlet.JasperLoader; import org.apache.jasper.servlet.JspServletWrapper; /** @@ -176,11 +175,7 @@ public class JspCompilationContext { public ClassLoader getJspLoader() { if( jspLoader == null ) { - jspLoader = new JasperLoader - (new URL[] {baseUrl}, - getClassLoader(), - rctxt.getPermissionCollection(), - rctxt.getCodeSource()); + jspLoader = rctxt.getJspLoader(baseUrl, getClassLoader()); } return jspLoader; } diff --git a/java/org/apache/jasper/compiler/JspRuntimeContext.java b/java/org/apache/jasper/compiler/JspRuntimeContext.java index 6e4fe069b..2a739875a 100644 --- a/java/org/apache/jasper/compiler/JspRuntimeContext.java +++ b/java/org/apache/jasper/compiler/JspRuntimeContext.java @@ -38,6 +38,7 @@ import org.apache.jasper.JspCompilationContext; import org.apache.jasper.Options; import org.apache.jasper.runtime.JspFactoryImpl; import org.apache.jasper.security.SecurityClassLoad; +import org.apache.jasper.servlet.JasperLoader; import org.apache.jasper.servlet.JspServletWrapper; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; @@ -155,6 +156,7 @@ public final class JspRuntimeContext { private ServletContext context; private Options options; private URLClassLoader parentClassLoader; + private JasperLoader jspLoader; private PermissionCollection permissionCollection; private CodeSource codeSource; private String classpath; @@ -317,6 +319,29 @@ public final class JspRuntimeContext { } + /** + * Obtain the classloader to use when loading JSP resources. In development + * mode, each JSP has a separate classloader to enable easy re-loading of + * modified JSPs. If not in development mode, a single loader is used to + * reduce perm gen usage when many JSPs all use the same handful of tags. + */ + public URLClassLoader getJspLoader(URL baseUrl, ClassLoader parent) { + if (jspLoader == null) { + if (options.getDevelopment()) { + jspLoader = new JasperLoader + (new URL[] {baseUrl}, + parent, + permissionCollection, + codeSource); + } else { + jspLoader = new JasperLoader(new URL[] {baseUrl}, + parent, permissionCollection, codeSource); + } + } + return jspLoader; + } + + // -------------------------------------------------------- Private Methods