001    /*
002     @license.text@ 
003     */
004    package biz.hammurapi.cache;
005    
006    import java.util.ArrayList;
007    import java.util.Collection;
008    import java.util.Iterator;
009    
010    /**
011     * Implements remove event propagation to caches.
012     * @author Pavel Vlasov
013     * @version $Revision: 1.1 $
014     */
015    public abstract class AbstractProducer implements Producer {
016            private Collection caches=new ArrayList();
017            
018            protected void onRemove(Object key) {
019                    synchronized (caches) {
020                            Iterator it=caches.iterator();
021                            while (it.hasNext()) {
022                                    ((Cache) it.next()).remove(key);
023                            }
024                    }
025            }
026            
027            public void addCache(Cache cache) {
028                    synchronized (caches) {
029                            caches.add(cache);
030                    }
031            }
032    
033    }