1 19 package org.fjank.jcache.distribution; 20 21 import java.io.Serializable ; 22 import java.util.Enumeration ; 23 import javax.util.jcache.CacheException; 24 import org.fjank.jcache.CacheImpl; 25 26 33 public abstract class DistributionEngine 34 { 35 public static DistributionEngine getInstance(CacheImpl cache) 36 { 37 return JGroupsDistributionEngine.instanceOf(cache); 40 } 41 42 public abstract Enumeration getCacheAddr(); 43 44 public void cacheObjectUpdated(String region, 45 String group, 46 Serializable key, 47 Serializable data) 48 { 49 sendNotification(new ClusterNotification(region, 50 group, 51 ClusterNotification.OBJECT_UPDATED, 52 new SerializableCacheObject(key, data))); 53 } 54 55 56 public void cacheObjectAdded(String region, 57 String group, 58 Serializable key, 59 Serializable data) throws CacheException 60 { 61 sendNotification(new ClusterNotification(region, 62 group, 63 ClusterNotification.OBJECT_ADDED, 64 new SerializableCacheObject(key, data))); 65 66 } 67 68 69 public void cacheObjectInvalidated(String region, 70 Serializable key) 71 { 72 sendNotification(new ClusterNotification(region, 73 null, 74 ClusterNotification.OBJECT_INVALIDATED, 75 key)); 76 } 77 78 protected void handleClusterNotification(ClusterNotification clusterNotification) 79 { 80 } 138 139 public abstract void sendNotification(ClusterNotification clusterNotification); 140 141 142 protected CacheImpl cache; 143 } 144 | Popular Tags |