View Javadoc
1   package org.apache.commons.jcs.engine.behavior;
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  
24  /**
25   * Used to receive a cache event notification.
26   * <p>
27   * Note: objects which implement this interface are local listeners to cache changes, whereas
28   * objects which implement IRmiCacheListener are remote listeners to cache changes.
29   */
30  public interface ICacheListener<K, V>
31  {
32      /**
33       * Notifies the subscribers for a cache entry update.
34       * <p>
35       * @param item
36       * @throws IOException
37       */
38      void handlePut( ICacheElement<K, V> item )
39          throws IOException;
40  
41      /**
42       * Notifies the subscribers for a cache entry removal.
43       * <p>
44       * @param cacheName
45       * @param key
46       * @throws IOException
47       */
48      void handleRemove( String cacheName, K key )
49          throws IOException;
50  
51      /**
52       * Notifies the subscribers for a cache remove-all.
53       * <p>
54       * @param cacheName
55       * @throws IOException
56       */
57      void handleRemoveAll( String cacheName )
58          throws IOException;
59  
60      /**
61       * Notifies the subscribers for freeing up the named cache.
62       * <p>
63       * @param cacheName
64       * @throws IOException
65       */
66      void handleDispose( String cacheName )
67          throws IOException;
68  
69      /**
70       * sets unique identifier of listener home
71       * <p>
72       * @param id The new listenerId value
73       * @throws IOException
74       */
75      void setListenerId( long id )
76          throws IOException;
77  
78      /**
79       * Gets the listenerId attribute of the ICacheListener object
80       * <p>
81       * @return The listenerId value
82       * @throws IOException
83       */
84      long getListenerId()
85          throws IOException;
86  }