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