public CacheElement createElement(Serializable key, DistributedCacheObject content) { return new EhCacheDistributedElementImpl(key, content); }
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()); }
notifyListeners(removeAllLocal, CacheElement.ActionRemoved,e.getKey(),e.getContent()); e.notifyChange(CacheElement.ActionRemoved);
@Override public Object getPermission(Long id) { EhCacheDistributedElementImpl cacheElementImpl = (EhCacheDistributedElementImpl)permissionCache.get(id); return ((cacheElementImpl != null) ? cacheElementImpl.getContent() : null); }
public void notifyElement( Ehcache cache, boolean local,Element arg1, int action) { if (cache != this.ehcache) { System.out.println ("Cache=" + cache.getName() + " is not my cache=" + this.ehcache.getName()); return; } try { EhCacheDistributedElementImpl e = (EhCacheDistributedElementImpl) refList .get(arg1.getKey()); if (e != null) { if (action < 0) refList.remove(arg1.getKey()); else if (action == CacheElement.ActionAdded) refList.put(arg1.getKey(), new EhCacheDistributedElementImpl(arg1)); e.notifyChange(action); notifyListeners(local, action, arg1.getKey(), arg1.getObjectValue()); } else { notifyListeners(local, action, arg1.getKey(), null); } } catch (Exception e) { e.printStackTrace(); } }
@Override public Object getDomain(Long id) { EhCacheDistributedElementImpl cacheElementImpl = (EhCacheDistributedElementImpl)domainCache.get(id); return ((cacheElementImpl != null) ? cacheElementImpl.getContent() : null); }
public CacheElement createElement(Object key, Object content) { if (!(key instanceof Serializable)) { throw new IllegalArgumentException("The cache key must be serializable."); } if (!(content instanceof DistributedCacheObject)) { throw new IllegalArgumentException("The cache content must be a distributed cache object."); } return new EhCacheDistributedElementImpl((Serializable)key, (DistributedCacheObject)content); }
@Override public Object getPrincipal(Long id) { EhCacheDistributedElementImpl cacheElementImpl = (EhCacheDistributedElementImpl)principalCache.get(id); return ((cacheElementImpl != null) ? cacheElementImpl.getContent() : null); }
public CacheElement get(Serializable key) { Element element = ehcache.get(key); if (element == null) return null; return new EhCacheDistributedElementImpl(element); }
public void notifyChange(int action) { ((DistributedCacheObject)getContent()).notifyChange(action); }
@Override public void putDomain(Long id, Object domain) { domainCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) domain)); }
@Override public void putPermission(Long id, Object permission) { permissionCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) permission)); }
@Override public void putPrincipal(Long id, Object principal) { principalCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) principal)); }
/** * 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); } } }