1 package org.apache.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.io.Serializable;
24 import java.util.LinkedList;
25 import java.util.List;
26
27 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
28 import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
29 import org.apache.jcs.engine.behavior.ICacheElement;
30
31 /***
32 * For testing.
33 * <p>
34 * @author Aaron Smuts
35 */
36 public class RemoteCacheListenerMockImpl
37 implements IRemoteCacheListener
38 {
39 /*** Setup the listener id that this will return. */
40 private long listenerId;
41
42 /*** Number of times handlePut was called. */
43 public int putCount;
44
45 /*** List of ICacheElements passed to handlePut. */
46 public List putItems = new LinkedList();
47
48 /*** List of Serializable objects passed to handleRemove. */
49 public List removedKeys = new LinkedList();
50
51 /*** Number of times handleRemote was called. */
52 public int removeCount;
53
54 /*** The type of remote listener */
55 public int remoteType = IRemoteCacheAttributes.LOCAL;
56
57 public void dispose()
58 throws IOException
59 {
60
61 }
62
63 /***
64 * returns the listener id, which can be setup.
65 */
66 public long getListenerId()
67 throws IOException
68 {
69 return listenerId;
70 }
71
72 public String getLocalHostAddress()
73 throws IOException
74 {
75
76 return null;
77 }
78
79 /***
80 * Return the setup remoteType.
81 */
82 public int getRemoteType()
83 throws IOException
84 {
85 return remoteType;
86 }
87
88 /***
89 * Allows you to setup the listener id.
90 */
91 public void setListenerId( long id )
92 throws IOException
93 {
94 listenerId = id;
95 }
96
97 public void handleDispose( String cacheName )
98 throws IOException
99 {
100
101
102 }
103
104 /***
105 * This increments the put count and adds the item to the putItem list.
106 */
107 public void handlePut( ICacheElement item )
108 throws IOException
109 {
110 putCount++;
111 this.putItems.add( item );
112 }
113
114 /***
115 * Increments the remove count and adds the key to the removedKeys list.
116 */
117 public void handleRemove( String cacheName, Serializable key )
118 throws IOException
119 {
120 removeCount++;
121 removedKeys.add( key );
122 }
123
124 public void handleRemoveAll( String cacheName )
125 throws IOException
126 {
127
128
129 }
130
131 }