001package org.apache.commons.jcs3.engine.behavior;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.IOException;
023import java.rmi.Remote;
024
025/**
026 * Used to register interest in receiving cache changes. <br>
027 * <br>
028 * Note: server which implements this interface provides a local cache event
029 * notification service, whereas server which implements IRmiCacheWatch provides
030 * a remote cache event notification service.
031 */
032public interface ICacheObserver extends Remote
033{
034    /**
035     * Subscribes to the specified cache.
036     *
037     * @param cacheName
038     *            the specified cache.
039     * @param obj
040     *            object to notify for cache changes.
041     * @throws IOException
042     */
043    <K, V> void addCacheListener( String cacheName, ICacheListener<K, V> obj )
044        throws IOException;
045
046    /**
047     * Subscribes to all caches.
048     *
049     * @param obj
050     *            object to notify for all cache changes.
051     * @throws IOException
052     */
053    <K, V> void addCacheListener( ICacheListener<K, V> obj )
054        throws IOException;
055
056    /**
057     * Unsubscribes from the specified cache.
058     * @param cacheName
059     *
060     * @param obj
061     *            existing subscriber.
062     * @throws IOException
063     */
064    <K, V> void removeCacheListener( String cacheName, ICacheListener<K, V> obj )
065        throws IOException;
066
067    /**
068     * Unsubscribes from all caches.
069     *
070     * @param obj
071     *            existing subscriber.
072     * @throws IOException
073     */
074    <K, V> void removeCacheListener( ICacheListener<K, V> obj )
075        throws IOException;
076}