1 package org.apache.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.Hashtable;
23 import java.util.Iterator;
24 import java.util.Map;
25
26 import org.apache.jcs.engine.behavior.ICache;
27
28 /***
29 * Used to associates a set of [cache listener to cache event queue] for a
30 * cache.
31 */
32 public class CacheListeners
33 {
34 /*** The cache using the queue. */
35 public final ICache cache;
36
37 /*** Map ICacheListener to ICacheEventQueue */
38 public final Map eventQMap = new Hashtable();
39
40 /***
41 * Constructs with the given cache.
42 * <p>
43 * @param cache
44 */
45 public CacheListeners( ICache cache )
46 {
47 if ( cache == null )
48 {
49 throw new IllegalArgumentException( "cache must not be null" );
50 }
51 this.cache = cache;
52 }
53
54 /*** @return info on the listeners */
55 public String toString()
56 {
57 StringBuffer buffer = new StringBuffer();
58 buffer.append( "\n CacheListeners" );
59 if ( cache != null )
60 {
61 buffer.append( "\n Region = " + cache.getCacheName() );
62 }
63 if ( eventQMap != null )
64 {
65 buffer.append( "\n Event Queue Map " );
66 buffer.append( "\n size = " + eventQMap.size() );
67 Iterator it = eventQMap.entrySet().iterator();
68 while ( it.hasNext() )
69 {
70 buffer.append( "\n Entry: " + it.next() );
71 }
72 }
73 else
74 {
75 buffer.append( "\n No Listeners. " );
76 }
77 return buffer.toString();
78 }
79 }