List of usage examples for org.apache.commons.cache MemoryStash MemoryStash
public MemoryStash(int maxobjs)
From source file:com.adito.webforwards.JDBCWebForwardDatabase.java
/** * Constructor/* ww w. j av a2 s . co m*/ */ public JDBCWebForwardDatabase() { int maxObjects = 1000; try { maxObjects = Integer .parseInt(SystemProperties.get("adito.jdbcSystemDatabase.replacementsCache", "10000")); } catch (Exception e) { } replacementsCache = new SimpleCache(new MemoryStash(maxObjects)); }
From source file:com.adito.policyframework.PrincipalCache.java
protected final Cache createCache(String messageBundle, String cacheFullText) { File cacheDirectory = new File(ContextHolder.getContext().getTempDirectory(), "cache"); File cacheTypeDirectory = new File(cacheDirectory, cacheType); Stash stash = inMemoryCache ? new MemoryStash(cacheSize) : new FileStash(Long.MAX_VALUE, cacheSize, new File[] { cacheTypeDirectory }, true); // eviction can't be used in testing as the policy creates a thread // which is only stopped on JVM exit, hence breaking the tests boolean isTestMode = "true".equals(SystemProperties.get("adito.testing", "false")); EvictionPolicy evictionPolicy = isTestMode ? null : new LRUEvictionPolicy(); SimpleCache cache = new SimpleCache(stash, evictionPolicy, null, new GroupMapImpl()); cache.registerStorageListener(getStorageListener(messageBundle, cacheFullText)); return cache; }
From source file:com.sslexplorer.policyframework.PrincipalCache.java
protected final Cache createCache(String messageBundle, String cacheFullText) { File cacheDirectory = new File(ContextHolder.getContext().getTempDirectory(), "cache"); File cacheTypeDirectory = new File(cacheDirectory, cacheType); Stash stash = inMemoryCache ? new MemoryStash(cacheSize) : new FileStash(Long.MAX_VALUE, cacheSize, new File[] { cacheTypeDirectory }, true); // eviction can't be used in testing as the policy creates a thread // which is only stopped on JVM exit, hence breaking the tests boolean isTestMode = "true".equals(SystemProperties.get("sslexplorer.testing", "false")); EvictionPolicy evictionPolicy = isTestMode ? null : new LRUEvictionPolicy(); SimpleCache cache = new SimpleCache(stash, evictionPolicy, null, new GroupMapImpl()); cache.registerStorageListener(getStorageListener(messageBundle, cacheFullText)); return cache; }
From source file:com.adito.jdbc.JDBCPolicyDatabase.java
public void open(CoreServlet controllingServlet) throws Exception { String dbName = SystemProperties.get("adito.policyDatabase.jdbc.dbName", "explorer_configuration"); controllingServlet.addDatabase(dbName, ContextHolder.getContext().getDBDirectory()); String jdbcUser = SystemProperties.get("adito.jdbc.username", "sa"); String jdbcPassword = SystemProperties.get("adito.jdbc.password", ""); String vendorDB = SystemProperties.get("adito.jdbc.vendorClass", "com.adito.jdbc.hsqldb.HSQLDBDatabaseEngine"); if (log.isInfoEnabled()) { log.info("Policy database is being opened..."); log.info("JDBC vendor class implementation is " + vendorDB); }/*from w w w. j ava 2 s . com*/ File upgradeDir = new File("install/upgrade"); db = (JDBCDatabaseEngine) Class.forName(vendorDB).newInstance(); db.init("policyDatabase", dbName, jdbcUser, jdbcPassword, null); DBUpgrader upgrader = new DBUpgrader(ContextHolder.getContext().getVersion(), db, ContextHolder.getContext().getDBDirectory(), upgradeDir); upgrader.upgrade(); policyCache = new SimpleCache(new MemoryStash(CACHE_MAXOBJS.intValue())); CoreServlet.getServlet().addCoreListener(new CoreListener() { public void coreEvent(CoreEvent evt) { if (evt.getId() == CoreEventConstants.USER_CREATED || evt.getId() == CoreEventConstants.USER_EDITED || evt.getId() == CoreEventConstants.USER_REMOVED || evt.getId() == CoreEventConstants.GROUP_CREATED || evt.getId() == CoreEventConstants.GROUP_REMOVED) { policyCache.clear(); } } }); }
From source file:com.sslexplorer.jdbc.JDBCPolicyDatabase.java
public void open(CoreServlet controllingServlet) throws Exception { String dbName = SystemProperties.get("sslexplorer.policyDatabase.jdbc.dbName", "explorer_configuration"); controllingServlet.addDatabase(dbName, ContextHolder.getContext().getDBDirectory()); String jdbcUser = SystemProperties.get("sslexplorer.jdbc.username", "sa"); String jdbcPassword = SystemProperties.get("sslexplorer.jdbc.password", ""); String vendorDB = SystemProperties.get("sslexplorer.jdbc.vendorClass", "com.sslexplorer.jdbc.hsqldb.HSQLDBDatabaseEngine"); if (log.isInfoEnabled()) { log.info("Policy database is being opened..."); log.info("JDBC vendor class implementation is " + vendorDB); }/* w w w . j a v a 2s. com*/ File upgradeDir = new File("install/upgrade"); db = (JDBCDatabaseEngine) Class.forName(vendorDB).newInstance(); db.init("policyDatabase", dbName, jdbcUser, jdbcPassword, null); DBUpgrader upgrader = new DBUpgrader(ContextHolder.getContext().getVersion(), db, ContextHolder.getContext().getDBDirectory(), upgradeDir); upgrader.upgrade(); policyCache = new SimpleCache(new MemoryStash(CACHE_MAXOBJS.intValue())); CoreServlet.getServlet().addCoreListener(new CoreListener() { public void coreEvent(CoreEvent evt) { if (evt.getId() == CoreEventConstants.USER_CREATED || evt.getId() == CoreEventConstants.USER_EDITED || evt.getId() == CoreEventConstants.USER_REMOVED || evt.getId() == CoreEventConstants.GROUP_CREATED || evt.getId() == CoreEventConstants.GROUP_REMOVED) { policyCache.clear(); } } }); }