001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.cache.eh;
020
021import java.io.Serializable;
022
023import lucee.commons.io.cache.CacheEventListener;
024import net.sf.ehcache.CacheException;
025import net.sf.ehcache.Ehcache;
026import net.sf.ehcache.Element;
027
028
029public class EHCacheEventListener implements net.sf.ehcache.event.CacheEventListener,Serializable {
030
031        private static final long serialVersionUID = 5931737203770901097L;
032
033        private CacheEventListener listener;
034
035        public EHCacheEventListener(CacheEventListener listener) {
036                this.listener=listener;
037        }
038        
039
040        @Override
041        public void notifyElementExpired(Ehcache cache, Element element) {
042                listener.onExpires(new EHCacheEntry(element));
043        }
044
045        @Override
046        public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
047                listener.onPut(new EHCacheEntry(element));
048        }
049
050        @Override
051        public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException {
052                listener.onRemove(new EHCacheEntry(element));
053        }
054        
055        
056        
057        @Override
058        public void dispose() {
059                // TODO Auto-generated method stub
060                
061        }
062
063        @Override
064        public void notifyElementEvicted(Ehcache arg0, Element arg1) {
065                // TODO Auto-generated method stub
066                
067        }
068
069        
070
071        @Override
072        public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
073                listener.onPut(new EHCacheEntry(element));
074        }
075
076        @Override
077        public void notifyRemoveAll(Ehcache arg0) {
078                // TODO Auto-generated method stub
079                
080        }
081
082        @Override
083        public Object clone(){
084                return new EHCacheEventListener(listener.duplicate()); 
085        }
086}