001package org.apache.commons.jcs.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;
023
024/**
025 * Used to register interest in receiving cache changes. <br>
026 * <br>
027 * Note: server which implements this interface provides a local cache event
028 * notification service, whereas server which implements IRmiCacheWatch provides
029 * a remote cache event notification service.
030 *
031 */
032public interface ICacheObserver
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    //, CacheNotFoundException;
047
048    /**
049     * Subscribes to all caches.
050     *
051     * @param obj
052     *            object to notify for all cache changes.
053     * @throws IOException
054     */
055    <K, V> void addCacheListener( ICacheListener<K, V> obj )
056        throws IOException;
057
058    /**
059     * Unsubscribes from the specified cache.
060     * @param cacheName
061     *
062     * @param obj
063     *            existing subscriber.
064     * @throws IOException
065     */
066    <K, V> void removeCacheListener( String cacheName, ICacheListener<K, V> obj )
067        throws IOException;
068
069    /**
070     * Unsubscribes from all caches.
071     *
072     * @param obj
073     *            existing subscriber.
074     * @throws IOException
075     */
076    <K, V> void removeCacheListener( ICacheListener<K, V> obj )
077        throws IOException;
078}