Author: rjung Date: Fri Oct 29 17:54:27 2010 New Revision: 1028863 URL: http://svn.apache.org/viewvc?rev=1028863&view=rev Log: Simplify JSP limiter:
- inline getJspForUnload It is only used privately and only in one place plus the code gets easier to understand. - remove compilation interval check from background method checkUnload(). Better to run on every iteration of the background job. - Do not check JSP count against the size of the wrapper list (jsps). Instead check against the queue length. Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java?rev=1028863&r1=1028862&r2=1028863&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java Fri Oct 29 17:54:27 2010 @@ -500,23 +500,6 @@ public final class JspRuntimeContext { return new SecurityHolder(source, permissions); } - /** Returns a JspServletWrapper that should be destroyed. Default strategy: Least recently used. */ - public JspServletWrapper getJspForUnload(final int maxLoadedJsps) { - if( jsps.size() > maxLoadedJsps ) { - synchronized( jsps ) { - JspServletWrapper oldest; - synchronized(jspQueue) { - oldest = jspQueue.pop(); - } - if (oldest != null) { - removeWrapper(oldest.getJspUri()); - return oldest; - } - } - } - return null; - } - /** * Method used by background thread to check if any JSP's should be destroyed. * If JSP's to be unloaded are found, they will be destroyed. @@ -524,10 +507,7 @@ public final class JspRuntimeContext { */ public void checkUnload() { if (options.getMaxLoadedJsps() > 0) { - long now = System.currentTimeMillis(); - if (now > (lastCheck + (options.getCheckInterval() * 1000L))) { - while (unloadJsp()); - } + while (unloadJsp()) {} } } @@ -535,8 +515,14 @@ public final class JspRuntimeContext { * Checks whether there is a jsp to unload, if one is found, it is destroyed. * */ public boolean unloadJsp() { - JspServletWrapper jsw = getJspForUnload(options.getMaxLoadedJsps()); - if( null != jsw ) { + JspServletWrapper jsw = null; + synchronized(jspQueue) { + if(jspQueue.getSize() > options.getMaxLoadedJsps()) { + jsw = jspQueue.pop(); + } + } + if (jsw != null) { + removeWrapper(jsw.getJspUri()); synchronized(jsw) { jsw.destroy(); return true; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org