01: package org.shiftone.cache.decorator.cluster;
02:
03: import org.shiftone.cache.Cache;
04:
05: import java.io.Serializable;
06:
07: /**
08: * @version $Revision: 1.4 $
09: * @author <a href="mailto:jeff@shiftone.org">Jeff Drost</a>
10: */
11: public class RemoveNotification implements Notification {
12:
13: private final long senderInstanceId;
14: private final Serializable key;
15: private final String cacheName;
16:
17: public RemoveNotification(long senderInstanceId, String cacheName,
18: Serializable key) {
19:
20: this .senderInstanceId = senderInstanceId;
21: this .cacheName = cacheName;
22: this .key = key;
23: }
24:
25: public RemoveNotification(long senderInstanceId, String cacheName,
26: Object key) {
27:
28: this .senderInstanceId = senderInstanceId;
29: this .cacheName = cacheName;
30:
31: if (key instanceof Serializable) {
32: this .key = (Serializable) key;
33: } else {
34: throw new ClassCastException("unable to cast "
35: + key.getClass() + " to Serializable");
36: }
37: }
38:
39: public void execute(Cache cache) {
40: cache.remove(key);
41: }
42:
43: public long getSenderInstanceId() {
44: return senderInstanceId;
45: }
46:
47: public String getCacheName() {
48: return cacheName;
49: }
50:
51: public String toString() {
52: return "remove(" + key + ")";
53: }
54: }
|