001    package railo.runtime.cache;
002    
003    import railo.commons.io.cache.CacheEntry;
004    import railo.commons.io.cache.CacheEventListener;
005    import railo.runtime.Component;
006    import railo.runtime.type.Collection;
007    import railo.runtime.type.Collection.Key;
008    import railo.runtime.type.KeyImpl;
009    
010    public class ComponentCacheEventListener implements CacheEventListener {
011    
012            private static final long serialVersionUID = 6271280246677734153L;
013            private static final Collection.Key ON_EXPIRES = KeyImpl.intern("onExpires");
014            private static final Collection.Key ON_PUT = KeyImpl.intern("onPut");
015            private static final Collection.Key ON_REMOVE = KeyImpl.intern("onRemove");
016            private Component cfc;
017    
018            public ComponentCacheEventListener(Component cfc) {
019                    this.cfc=cfc;
020            }
021            
022            @Override
023            public void onRemove(CacheEntry entry) {
024                    call(ON_REMOVE,entry);
025            }
026    
027            @Override
028            public void onPut(CacheEntry entry) {
029                    call(ON_PUT,entry);
030            }
031    
032            @Override
033            public void onExpires(CacheEntry entry) {
034                    call(ON_EXPIRES,entry);
035            }
036    
037            private void call(Key methodName, CacheEntry entry) {
038                    //Struct data = entry.getCustomInfo();
039                    //cfc.callWithNamedValues(pc, methodName, data);
040            }
041    
042            @Override
043            public CacheEventListener duplicate() {
044                    return new ComponentCacheEventListener((Component)cfc.duplicate(false));
045            }
046    
047    }