KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > cache > treecache > TreeCacheListenerWrapper


1 package org.jahia.services.cache.treecache;
2
3 import org.jahia.services.cache.CacheListener;
4 import org.jboss.cache.Fqn;
5 import org.jboss.cache.TreeCache;
6 import org.jboss.cache.TreeCacheListener;
7 import org.jgroups.View;
8
9 public class TreeCacheListenerWrapper implements TreeCacheListener {
10     private CacheListener cacheListener = null;
11
12     /**
13      * @return Returns the cacheListener.
14      */

15     private CacheListener getCacheListener() {
16         return cacheListener;
17     }
18
19     public TreeCacheListenerWrapper(CacheListener listener) {
20         super();
21
22         cacheListener = listener;
23     }
24
25     public void nodeCreated(Fqn arg0) {
26         // cacheListener.onCachePut((String) arg0.get(0), arg0.size() > 1 ?
27
// arg0.get(1) : null, null);
28
}
29
30     public void nodeRemoved(Fqn arg0) {
31         // cacheListener.onCacheFlush((String) arg0.get(0));
32
}
33
34     public void nodeLoaded(Fqn arg0) {
35
36     }
37
38     public void nodeEvicted(Fqn arg0) {
39     }
40
41     public void nodeModified(Fqn arg0) {
42         String JavaDoc cacheName = (String JavaDoc) arg0.get(0);
43         Object JavaDoc entryKey = arg0.size() > 1 ? arg0.get(1) : null;
44         cacheListener.onCachePut(cacheName, entryKey);
45     }
46
47     public void nodeVisited(Fqn arg0) {
48     }
49
50     public void cacheStarted(TreeCache arg0) {
51     }
52
53     public void cacheStopped(TreeCache arg0) {
54     }
55
56     public void viewChange(View arg0) {
57     }
58
59     public int hashCode() {
60         return cacheListener.hashCode();
61     }
62
63     public boolean equals(Object JavaDoc obj) {
64         boolean isEqual = false;
65         if (obj instanceof TreeCacheListenerWrapper) {
66             isEqual = cacheListener.equals(((TreeCacheListenerWrapper) obj).getCacheListener());
67         }
68         return isEqual;
69     }
70 }
71
Popular Tags