if (!options.getDevelopment()
&& appBase != null
&& options.getCheckInterval() > 0) {
- lastCheck = System.currentTimeMillis();
+ lastCompileCheck = System.currentTimeMillis();
}
if (options.getMaxLoadedJsps() > 0) {
private final PermissionCollection permissionCollection;
private final CodeSource codeSource;
private final String classpath;
- private volatile long lastCheck = -1L;
+ private volatile long lastCompileCheck = -1L;
+ private volatile long lastJspQueueUpdate = System.currentTimeMillis();
/**
* Maps JSP pages to their JspServletWrapper's
* execution of jsp. Destroy any JSP the has been replaced in the queue.
*
* @param jsw Servlet wrapper for jsp.
- * @return a ticket that can be pushed to front of queue at later execution times.
+ * @return an unloadHandle that can be pushed to front of queue at later execution times.
* */
public FastRemovalDequeue<JspServletWrapper>.Entry push(JspServletWrapper jsw) {
FastRemovalDequeue<JspServletWrapper>.Entry entry = jspQueue.push(jsw);
}
/**
- * Push ticket for JspServletWrapper to front of the queue.
+ * Push unloadHandle for JspServletWrapper to front of the queue.
*
- * @param ticket the ticket for the jsp.
+ * @param unloadHandle the unloadHandle for the jsp.
* */
- public void makeYoungest(FastRemovalDequeue<JspServletWrapper>.Entry ticket) {
- jspQueue.moveFirst(ticket);
+ public void makeYoungest(FastRemovalDequeue<JspServletWrapper>.Entry unloadHandle) {
+ jspQueue.moveFirst(unloadHandle);
}
/**
*/
public void checkCompile() {
- if (lastCheck < 0) {
+ if (lastCompileCheck < 0) {
// Checking was disabled
return;
}
long now = System.currentTimeMillis();
- if (now > (lastCheck + (options.getCheckInterval() * 1000L))) {
- lastCheck = now;
+ if (now > (lastCompileCheck + (options.getCheckInterval() * 1000L))) {
+ lastCompileCheck = now;
} else {
return;
}
return classpath;
}
+ /**
+ * Last time the update background task has run
+ */
+ public long getLastJspQueueUpdate() {
+ return lastJspQueueUpdate;
+ }
+
// -------------------------------------------------------- Private Methods
}
}
+
/**
- * 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.
- * Uses the lastCheck time from background compiler to determine if it is time to unload JSP's.
+ * Method used by background thread to check if any JSP's should be unloaded.
*/
public void checkUnload() {
- if (options.getMaxLoadedJsps() > 0) {
- while (unloadJsp()) {}
- }
- }
-
- /**
- * Checks whether there is a jsp to unload, if one is found, it is destroyed.
- * */
- public boolean unloadJsp() {
- JspServletWrapper jsw = null;
- synchronized(jspQueue) {
- if(jspQueue.getSize() > options.getMaxLoadedJsps()) {
- jsw = jspQueue.pop();
- }
- }
- if (jsw != null) {
- unloadJspServletWrapper(jsw);
- return true;
- }
- return false;
+
+ lastJspQueueUpdate = System.currentTimeMillis();
}
}
/** Timestamp of last time servlet resource was modified */
private volatile long servletClassLastModifiedTime;
private long lastModificationTest = 0L;
- private FastRemovalDequeue<JspServletWrapper>.Entry ticket;
+ private long lastUsageTime = System.currentTimeMillis();
+ private FastRemovalDequeue<JspServletWrapper>.Entry unloadHandle;
+ private final boolean unloadByCount;
/*
* JspServletWrapper for JSP pages.
this.config = config;
this.options = options;
this.jspUri = jspUri;
+ unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
config.getServletContext(),
this, rctxt);
this.options = options;
this.jspUri = tagFilePath;
this.tripCount = 0;
+ unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
ctxt = new JspCompilationContext(jspUri, tagInfo, options,
servletContext, this, rctxt,
tagJarResource);
/*
* (3) Handle limitation of number of loaded Jsps
*/
- if (options.getMaxLoadedJsps() > 0) {
+ if (unloadByCount) {
synchronized(this) {
- if (ticket == null) {
- ticket = ctxt.getRuntimeContext().push(this);
- } else {
- ctxt.getRuntimeContext().makeYoungest(ticket);
+ if (unloadHandle == null) {
+ unloadHandle = ctxt.getRuntimeContext().push(this);
+ } else if (lastUsageTime < ctxt.getRuntimeContext().getLastJspQueueUpdate()) {
+ ctxt.getRuntimeContext().makeYoungest(unloadHandle);
+ lastUsageTime = System.currentTimeMillis();
}
}
}