01: package ri.cache.util;
02:
03: import javax.cache.CacheListener;
04:
05: /**
06: * DebugCacheListener
07: *
08: * @author Brian Goetz
09: */
10: public class DebugCacheListener implements CacheListener {
11: private String cacheName;
12:
13: public DebugCacheListener(String cacheName) {
14: this .cacheName = cacheName;
15: }
16:
17: public void onLoad(Object key) {
18: System.out.println("Cache(" + cacheName + "): load " + key);
19: }
20:
21: public void onEvict(Object key) {
22: System.out.println("Cache(" + cacheName + "): evict " + key);
23: }
24:
25: public void onPut(Object key) {
26: System.out.println("Cache(" + cacheName + "): put " + key);
27: }
28:
29: public void onRemove(Object key) {
30: System.out.println("Cache(" + cacheName + "): remove " + key);
31: }
32:
33: public void onClear() {
34: System.out.println("Cache(" + cacheName + "): clear");
35: }
36:
37: public void onUpdate(Object key) {
38: System.out.println("Cache(" + cacheName + "): update " + key);
39: }
40:
41: public void onExpiry(Object key) {
42: System.out.println("Cache(" + cacheName + "): expire " + key);
43: }
44:
45: public void onLoadException(Object key, Exception e) {
46: System.out.println("Cache(" + cacheName + "): load exception "
47: + key);
48: e.printStackTrace(System.out);
49: }
50:
51: public void onShutdown() {
52: System.out.println("Cache(" + cacheName + "): shutdown ");
53: }
54: }
|