public void invalidate() { policy.flush(); } }
synchronized public Object get(Object key) { return delegate.get(key); }
/** * Create cache policy. * * @return the cache policy */ protected CachePolicy createCachePolicy() { try { CachePolicy policy = factory.createCachePolicy(); policy.create(); policy.start(); policies.add(policy); return policy; } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException)e; else throw new RuntimeException(e); } }
/** An accessor method that synchronizes access on the domainCache to avoid a race condition that can occur when the cache entry expires in the presence of multi-threaded access. The allowRefresh flag should be true for authentication accesses and false for other accesses. Previously the other accesses included authorization and caller principal mapping. Now the only use of the @param principal - the caller identity whose cached credentials are to be accessed. @param allowRefresh - a flag indicating if the cache access should flush any expired entries. */ private DomainInfo getCacheInfo(Principal principal, boolean allowRefresh) { if( domainCache == null ) return null; DomainInfo cacheInfo = null; synchronized( domainCache ) { if( allowRefresh == true ) cacheInfo = (DomainInfo) domainCache.get(principal); else cacheInfo = (DomainInfo) domainCache.peek(principal); if( cacheInfo != null ) cacheInfo.acquire(); } return cacheInfo; }
synchronized public void remove(Object key) { delegate.remove(key); }
synchronized public void insert(Object key, Object object) { delegate.insert(key, object); }
synchronized public void start() throws Exception { delegate.start(); }
synchronized public void create() throws Exception { delegate.create(); }
synchronized public void destroy() { delegate.destroy(); } }
synchronized public void stop() { delegate.stop(); }
synchronized public Object peek(Object key) { return delegate.get(key); }
public CtClassCache createCache() { CachePolicy policy = null; if (policyClass == TimedCachePolicy.class) policy = new TimedCachePolicy(lifetime, true, resolution); else if (policyClass == LRUCachePolicy.class) policy = new LRUCachePolicy(min, max); else { try { policy = policyClass.newInstance(); } catch(Exception e) { throw new IllegalStateException("Could not instantiate " + policyClass.getName(), e); } } try { policy.create(); policy.start(); } catch(Exception e) { throw new IllegalStateException("Error starting domain cache", e); } return new CtClassCache(policy); }
/** An accessor method that synchronizes access on the domainCache to avoid a race condition that can occur when the cache entry expires in the presence of multi-threaded access. The allowRefresh flag should be true for authentication accesses and false for other accesses. Previously the other accesses included authorization and caller principal mapping. Now the only use of the @param principal - the caller identity whose cached credentials are to be accessed. @param allowRefresh - a flag indicating if the cache access should flush any expired entries. */ private DomainInfo getCacheInfo(Principal principal, boolean allowRefresh) { if (domainCache == null) return null; DomainInfo cacheInfo = null; synchronized (domainCache) { if (allowRefresh == true) cacheInfo = (DomainInfo) domainCache.get(principal); else cacheInfo = (DomainInfo) domainCache.peek(principal); if (cacheInfo != null) cacheInfo.acquire(); } return cacheInfo; }