1 package org.shiftone.cache.decorator.cluster; 2 3 4 5 import org.shiftone.cache.Cache; 6 7 import java.io.Serializable ; 8 9 10 14 public class RemoveNotification implements Notification 15 { 16 17 private final long senderInstanceId; 18 private final Serializable key; 19 private final String cacheName; 20 21 public RemoveNotification(long senderInstanceId, String cacheName, Serializable key) 22 { 23 24 this.senderInstanceId = senderInstanceId; 25 this.cacheName = cacheName; 26 this.key = key; 27 } 28 29 30 public RemoveNotification(long senderInstanceId, String cacheName, Object key) 31 { 32 33 this.senderInstanceId = senderInstanceId; 34 this.cacheName = cacheName; 35 36 if (key instanceof Serializable ) 37 { 38 this.key = (Serializable ) key; 39 } 40 else 41 { 42 throw new ClassCastException ("unable to cast " + key.getClass() + " to Serializable"); 43 } 44 } 45 46 47 public void execute(Cache cache) 48 { 49 cache.remove(key); 50 } 51 52 53 public long getSenderInstanceId() 54 { 55 return senderInstanceId; 56 } 57 58 59 public String getCacheName() 60 { 61 return cacheName; 62 } 63 64 65 public String toString() 66 { 67 return "remove(" + key + ")"; 68 } 69 } 70 | Popular Tags |