/*
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.jboss.cache;

import java.util.Map;

/**
 * Cache notification interface. We can register with a cache ({@link
 * Cache#addListener(CacheListener)}) to receive notifications when
 * modifications are made to the cache.
 *
 * @author <a href="mailto:bela@jboss.org">Bela Ban</a>.
 * @version $Revision: 1.7.2.4 $
 */

public interface CacheListener {

   /**
    * Called after the entire contents of the map have been set. This is more
    * efficient than calling {@link #entrySet(Object,Object,Object)} on each
    * value
    *
    * @param m The new map. Its entries will overwrite whatever is already in
    *          the map.
    */
   void contentsInitialized(Map m);

   /**
    * Called after the entire contents of the map have been deleted
    */
   void contentsCleared();

   /**
    * Called after an entry has been set. This could be the addition of a new
    * entry, or the modification of an existing entry.
    *
    * @param key       The new key
    * @param value     The new value
    * @param old_value The value previously associated with <code>key</code>
    */
   void entrySet(Object key, Object value, Object old_value);

   /**
    * Called after an entry has been removed.
    *
    * @param key       The key identifying the entry
    * @param old_value The old value associated with <code>key</code>
    */
   void entryRemoved(Object key, Object old_value);
}
