public CacheElement createElement(Serializable key, DistributedCacheObject content) { return new EhCacheDistributedElementImpl(key, content); }
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 void putPermission(Long id, Object permission) { permissionCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) permission)); }
public CacheElement get(Serializable key) { Element element = ehcache.get(key); if (element == null) return null; return new EhCacheDistributedElementImpl(element); }
@Override public void putDomain(Long id, Object domain) { domainCache.put(new EhCacheDistributedElementImpl(id, (DistributedCacheObject) domain)); }
@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); } } }
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(); } }