public CacheElement get(Object key) { return get((Serializable)key); }
/** * Evict with notification from distributed instance cache. * Notification is sent even if instance is not in the cache * so that eviction is done in distributed peers. * * @param cache distributed instance cache * @param id instance id to evict and notify */ private static void evictFromDistributedCache(EhCacheDistributedImpl cache, Long id) { // force remove to notify local and remote listeners if (!cache.remove(id)) { cache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) CACHE_NULL)); cache.remove(id); } } }
@Override public boolean isDistributed() { // return distributed status for instance caches return (principalCache.isDistributed() && permissionCache.isDistributed() && domainCache.isDistributed()); }
public boolean remove(Object key) { return remove ((Serializable) key); }
public void clear() { // invoke removeAll with local flag set synchronized (refList) { removeAllLocal = true; super.clear(); removeAllLocal = false; } notifyListeners(true, CacheElement.ActionRemoved,null,null); }
public void notifyElementRemoved(Ehcache cache, Element arg1) throws CacheException { notifyElement(cache, false, arg1,CacheElement.ActionRemoved); }
@Override public void putDomain(Long id, Object domain) { domainCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) domain)); }
/** * Terminate caches and listeners. */ public void terminate() { // distributed cache listeners principalCache.removeEventListener(principalCacheListener, false); principalCache.removeEventListener(principalCacheListener, true); permissionCache.removeEventListener(permissionCacheListener, false); permissionCache.removeEventListener(permissionCacheListener, true); domainCache.removeEventListener(domainCacheListener, false); domainCache.removeEventListener(domainCacheListener, true); // clear caches clear(); }
principalCache.addEventListener(principalCacheListener, false); permissionCache.addEventListener(permissionCacheListener, false); domainCache.addEventListener(domainCacheListener, false);
@Override public int size() { // compute size from sum of all cache sizes int size = 0; size += principalCache.getSize(); size += permissionCache.getSize(); size += domainCache.getSize(); size += principalQueryCache.getSize(); size += associationQueryCache.getSize(); size += passwordCredentialQueryCache.getSize(); size += permissionQueryCache.getSize(); size += domainQueryCache.getSize(); return size; }
public boolean remove(Serializable key) { Element element = ehcache.get(key); refList.remove(key); if (element == null) return false; boolean isRemoved = ehcache.remove(key); if (isRemoved) notifyListeners(true, CacheElement.ActionRemoved,key,null); return isRemoved; }
public void notifyElementUpdated(Ehcache cache, Element arg1) throws CacheException { notifyElement(cache, false,arg1,CacheElement.ActionChanged); } public void notifyRemoveAll(Ehcache cache)
@Override public void putPermission(Long id, Object permission) { permissionCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) permission)); }
@Override public Object getPermission(Long id) { EhCacheDistributedElementImpl cacheElementImpl = (EhCacheDistributedElementImpl)permissionCache.get(id); return ((cacheElementImpl != null) ? cacheElementImpl.getContent() : null); }
notifyListeners(removeAllLocal, CacheElement.ActionRemoved,e.getKey(),e.getContent()); e.notifyChange(CacheElement.ActionRemoved);
public void notifyElementExpired(Ehcache cache, Element arg1) { notifyElement(cache, false, arg1,CacheElement.ActionExpired); }
@Override public void putPrincipal(Long id, Object principal) { principalCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) principal)); }
@Override public Object getDomain(Long id) { EhCacheDistributedElementImpl cacheElementImpl = (EhCacheDistributedElementImpl)domainCache.get(id); return ((cacheElementImpl != null) ? cacheElementImpl.getContent() : null); }
public void put(CacheElement element) { EhCacheDistributedElementImpl impl = (EhCacheDistributedElementImpl) element; ehcache.put(impl.getImplElement()); refList.put(impl.getKey(), impl); notifyListeners(true, CacheElement.ActionAdded,impl.getKey(),impl.getContent()); }