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 receive a cache event notification. 026 * <p> 027 * Note: objects which implement this interface are local listeners to cache changes, whereas 028 * objects which implement IRmiCacheListener are remote listeners to cache changes. 029 */ 030public interface ICacheListener<K, V> 031{ 032 /** 033 * Notifies the subscribers for a cache entry update. 034 * <p> 035 * @param item 036 * @throws IOException 037 */ 038 void handlePut( ICacheElement<K, V> item ) 039 throws IOException; 040 041 /** 042 * Notifies the subscribers for a cache entry removal. 043 * <p> 044 * @param cacheName 045 * @param key 046 * @throws IOException 047 */ 048 void handleRemove( String cacheName, K key ) 049 throws IOException; 050 051 /** 052 * Notifies the subscribers for a cache remove-all. 053 * <p> 054 * @param cacheName 055 * @throws IOException 056 */ 057 void handleRemoveAll( String cacheName ) 058 throws IOException; 059 060 /** 061 * Notifies the subscribers for freeing up the named cache. 062 * <p> 063 * @param cacheName 064 * @throws IOException 065 */ 066 void handleDispose( String cacheName ) 067 throws IOException; 068 069 /** 070 * sets unique identifier of listener home 071 * <p> 072 * @param id The new listenerId value 073 * @throws IOException 074 */ 075 void setListenerId( long id ) 076 throws IOException; 077 078 /** 079 * Gets the listenerId attribute of the ICacheListener object 080 * <p> 081 * @return The listenerId value 082 * @throws IOException 083 */ 084 long getListenerId() 085 throws IOException; 086}