1 package org.apache.commons.jcs.auxiliary.remote;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.IOException;
23 import java.util.LinkedList;
24 import java.util.List;
25
26 import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
27 import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType;
28 import org.apache.commons.jcs.engine.behavior.ICacheElement;
29
30
31
32
33
34
35 public class MockRemoteCacheListener<K, V>
36 implements IRemoteCacheListener<K, V>
37 {
38
39 private long listenerId;
40
41
42 public String localAddress;
43
44
45 public int putCount;
46
47
48 public List<ICacheElement<K, V>> putItems = new LinkedList<ICacheElement<K,V>>();
49
50
51 public List<K> removedKeys = new LinkedList<K>();
52
53
54 public int removeCount;
55
56
57 public RemoteType remoteType = RemoteType.LOCAL;
58
59
60
61
62 @Override
63 public void dispose()
64 throws IOException
65 {
66
67 }
68
69
70
71
72
73
74 @Override
75 public long getListenerId()
76 throws IOException
77 {
78 return listenerId;
79 }
80
81
82
83
84
85 @Override
86 public String getLocalHostAddress()
87 throws IOException
88 {
89 return localAddress;
90 }
91
92
93
94
95
96
97 @Override
98 public RemoteType getRemoteType()
99 throws IOException
100 {
101 return remoteType;
102 }
103
104
105
106
107
108
109
110 @Override
111 public void setListenerId( long id )
112 throws IOException
113 {
114 listenerId = id;
115 }
116
117
118
119
120
121 @Override
122 public void handleDispose( String cacheName )
123 throws IOException
124 {
125
126
127 }
128
129
130
131
132
133
134
135 @Override
136 public void handlePut( ICacheElement<K, V> item )
137 throws IOException
138 {
139 putCount++;
140 this.putItems.add( item );
141 }
142
143
144
145
146
147
148
149
150 @Override
151 public void handleRemove( String cacheName, K key )
152 throws IOException
153 {
154 removeCount++;
155 removedKeys.add( key );
156 }
157
158
159
160
161
162 @Override
163 public void handleRemoveAll( String cacheName )
164 throws IOException
165 {
166
167 }
168 }