KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > shiftone > cache > decorator > cluster > RemoveNotification


1 package org.shiftone.cache.decorator.cluster;
2
3
4
5 import org.shiftone.cache.Cache;
6
7 import java.io.Serializable JavaDoc;
8
9
10 /**
11  * @version $Revision: 1.4 $
12  * @author <a HREF="mailto:jeff@shiftone.org">Jeff Drost</a>
13  */

14 public class RemoveNotification implements Notification
15 {
16
17     private final long senderInstanceId;
18     private final Serializable JavaDoc key;
19     private final String JavaDoc cacheName;
20
21     public RemoveNotification(long senderInstanceId, String JavaDoc cacheName, Serializable JavaDoc key)
22     {
23
24         this.senderInstanceId = senderInstanceId;
25         this.cacheName = cacheName;
26         this.key = key;
27     }
28
29
30     public RemoveNotification(long senderInstanceId, String JavaDoc cacheName, Object JavaDoc key)
31     {
32
33         this.senderInstanceId = senderInstanceId;
34         this.cacheName = cacheName;
35
36         if (key instanceof Serializable JavaDoc)
37         {
38             this.key = (Serializable JavaDoc) key;
39         }
40         else
41         {
42             throw new ClassCastException JavaDoc("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 JavaDoc getCacheName()
60     {
61         return cacheName;
62     }
63
64
65     public String JavaDoc toString()
66     {
67         return "remove(" + key + ")";
68     }
69 }
70
Popular Tags