1 package org.apache.commons.jcs.engine;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Iterator;
23 import java.util.Map;
24 import java.util.concurrent.ConcurrentHashMap;
25 import java.util.concurrent.ConcurrentMap;
26
27 import org.apache.commons.jcs.engine.behavior.ICache;
28 import org.apache.commons.jcs.engine.behavior.ICacheEventQueue;
29
30
31
32
33
34 public class CacheListeners<K, V>
35 {
36
37 public final ICache<K, V> cache;
38
39
40 public final ConcurrentMap<Long, ICacheEventQueue<K, V>> eventQMap =
41 new ConcurrentHashMap<Long, ICacheEventQueue<K, V>>();
42
43
44
45
46
47
48 public CacheListeners( ICache<K, V> cache )
49 {
50 if ( cache == null )
51 {
52 throw new IllegalArgumentException( "cache must not be null" );
53 }
54 this.cache = cache;
55 }
56
57
58 @Override
59 public String toString()
60 {
61 StringBuilder buffer = new StringBuilder();
62 buffer.append( "\n CacheListeners" );
63 if ( cache != null )
64 {
65 buffer.append( "\n Region = " + cache.getCacheName() );
66 }
67 if ( eventQMap != null )
68 {
69 buffer.append( "\n Event Queue Map " );
70 buffer.append( "\n size = " + eventQMap.size() );
71 Iterator<Map.Entry<Long, ICacheEventQueue<K, V>>> it = eventQMap.entrySet().iterator();
72 while ( it.hasNext() )
73 {
74 buffer.append( "\n Entry: " + it.next() );
75 }
76 }
77 else
78 {
79 buffer.append( "\n No Listeners. " );
80 }
81 return buffer.toString();
82 }
83 }