1   package org.apache.jcs.auxiliary.remote;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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          // TODO Auto-generated method stub
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          // TODO Auto-generated method stub
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         // TODO Auto-generated method stub
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         // TODO Auto-generated method stub
128 
129     }
130 
131 }