KickJava   Java API By Example, From Geeks To Geeks.

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


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

13 public class ClusterCache implements Cache
14 {
15
16     private final Log LOG = new Log(ClusterCache.class);
17     private final ClusterCacheFactory factory;
18     private final Cache cache;
19     private final String JavaDoc name;
20
21     public ClusterCache(String JavaDoc name, Cache cache, ClusterCacheFactory factory)
22     {
23
24         this.factory = factory;
25         this.cache = cache;
26         this.name = name;
27     }
28
29
30     public void addObject(Object JavaDoc userKey, Object JavaDoc cacheObject)
31     {
32
33         // remove(userKey);
34
cache.addObject(userKey, cacheObject);
35     }
36
37
38     public Object JavaDoc getObject(Object JavaDoc key)
39     {
40         return cache.getObject(key);
41     }
42
43
44     public int size()
45     {
46         return cache.size();
47     }
48
49
50     public void remove(Object JavaDoc key)
51     {
52         cache.remove(key);
53         factory.sendRemoveNotification(name, key);
54     }
55
56
57     public void clear()
58     {
59         cache.clear();
60         factory.sendClearNotification(name);
61     }
62
63
64     //-----------------------------------------------------------
65
public Cache getCache()
66     {
67         return cache;
68     }
69
70
71     public String JavaDoc getName()
72     {
73         return name;
74     }
75
76
77     //-----------------------------------------------------------
78
public final String JavaDoc toString()
79     {
80         return "ClusterCache->" + cache;
81     }
82 }
83
Popular Tags