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; 020 021import lucee.commons.io.cache.CacheEntry; 022import lucee.commons.io.cache.CacheEventListener; 023import lucee.runtime.Component; 024import lucee.runtime.type.Collection; 025import lucee.runtime.type.Collection.Key; 026import lucee.runtime.type.KeyImpl; 027 028public class ComponentCacheEventListener implements CacheEventListener { 029 030 private static final long serialVersionUID = 6271280246677734153L; 031 private static final Collection.Key ON_EXPIRES = KeyImpl.intern("onExpires"); 032 private static final Collection.Key ON_PUT = KeyImpl.intern("onPut"); 033 private static final Collection.Key ON_REMOVE = KeyImpl.intern("onRemove"); 034 private Component cfc; 035 036 public ComponentCacheEventListener(Component cfc) { 037 this.cfc=cfc; 038 } 039 040 @Override 041 public void onRemove(CacheEntry entry) { 042 call(ON_REMOVE,entry); 043 } 044 045 @Override 046 public void onPut(CacheEntry entry) { 047 call(ON_PUT,entry); 048 } 049 050 @Override 051 public void onExpires(CacheEntry entry) { 052 call(ON_EXPIRES,entry); 053 } 054 055 private void call(Key methodName, CacheEntry entry) { 056 //Struct data = entry.getCustomInfo(); 057 //cfc.callWithNamedValues(pc, methodName, data); 058 } 059 060 @Override 061 public CacheEventListener duplicate() { 062 return new ComponentCacheEventListener((Component)cfc.duplicate(false)); 063 } 064 065}