📄 contentcache.java
字号:
/*
*/
package com.sslexplorer.replacementproxy;
import java.io.File;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import org.apache.commons.cache.SimpleCache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.security.User;
public class ContentCache extends SimpleCache implements HttpSessionBindingListener {
final static Log log = LogFactory.getLog(ContentCache.class);
ContentStash contentStash;
User user;
File cacheDir;
public ContentCache(User user, File cacheDir, int maxMB, int maxObjects) {
this(user, new ContentStash(1024 * 1024 * maxMB, maxObjects, cacheDir, 20, true));
this.cacheDir = cacheDir;
if (log.isInfoEnabled())
log.info("Created new cache at " + cacheDir.getAbsolutePath() + " for " + user.getPrincipalName() + " of capacity "
+ contentStash.capacity() + ".");
}
private ContentCache(User user, ContentStash stash) {
super(stash);
contentStash = (ContentStash) stash;
this.user = user;
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent)
*/
public void valueBound(HttpSessionBindingEvent arg0) {
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSessionBindingListener#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)
*/
public void valueUnbound(HttpSessionBindingEvent arg0) {
try {
if (!"true".equals(CoreServlet.getServlet().getPropertyDatabase().getProperty(0, null,
"webForwards.cache.clearOnLogout"))) {
return;
}
} catch (Exception e) {
}
if (log.isInfoEnabled())
log.info("Clearing content cache for " + user.getPrincipalName());
contentStash.clear();
if (log.isInfoEnabled())
log.info("Cleared content cache for " + user.getPrincipalName());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -