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            /**
023             * @see railo.commons.io.cache.CacheEventListener#onRemove(railo.commons.io.cache.CacheEntry)
024             */
025            public void onRemove(CacheEntry entry) {
026                    call(ON_REMOVE,entry);
027            }
028    
029            /**
030             * @see railo.commons.io.cache.CacheEventListener#onPut(railo.commons.io.cache.CacheEntry)
031             */
032            public void onPut(CacheEntry entry) {
033                    call(ON_PUT,entry);
034            }
035    
036            /**
037             * @see railo.commons.io.cache.CacheEventListener#onExpires(railo.commons.io.cache.CacheEntry)
038             */
039            public void onExpires(CacheEntry entry) {
040                    call(ON_EXPIRES,entry);
041            }
042    
043            private void call(Key methodName, CacheEntry entry) {
044                    //Struct data = entry.getCustomInfo();
045                    //cfc.callWithNamedValues(pc, methodName, data);
046            }
047    
048            /**
049             * @see railo.commons.io.cache.CacheEventListener#duplicate()
050             */
051            public CacheEventListener duplicate() {
052                    return new ComponentCacheEventListener((Component)cfc.duplicate(false));
053            }
054    
055    }