View Javadoc
1   package org.apache.commons.jcs3.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  import java.rmi.Remote;
24  
25  /**
26   * Used to register interest in receiving cache changes. <br>
27   * <br>
28   * Note: server which implements this interface provides a local cache event
29   * notification service, whereas server which implements IRmiCacheWatch provides
30   * a remote cache event notification service.
31   */
32  public interface ICacheObserver extends Remote
33  {
34      /**
35       * Subscribes to the specified cache.
36       *
37       * @param cacheName
38       *            the specified cache.
39       * @param obj
40       *            object to notify for cache changes.
41       * @throws IOException
42       */
43      <K, V> void addCacheListener( String cacheName, ICacheListener<K, V> obj )
44          throws IOException;
45  
46      /**
47       * Subscribes to all caches.
48       *
49       * @param obj
50       *            object to notify for all cache changes.
51       * @throws IOException
52       */
53      <K, V> void addCacheListener( ICacheListener<K, V> obj )
54          throws IOException;
55  
56      /**
57       * Unsubscribes from the specified cache.
58       * @param cacheName
59       *
60       * @param obj
61       *            existing subscriber.
62       * @throws IOException
63       */
64      <K, V> void removeCacheListener( String cacheName, ICacheListener<K, V> obj )
65          throws IOException;
66  
67      /**
68       * Unsubscribes from all caches.
69       *
70       * @param obj
71       *            existing subscriber.
72       * @throws IOException
73       */
74      <K, V> void removeCacheListener( ICacheListener<K, V> obj )
75          throws IOException;
76  }