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.type.scope.storage; 020 021import lucee.commons.io.cache.CacheEntry; 022import lucee.commons.io.cache.CacheEventListener; 023import lucee.commons.lang.ExceptionUtil; 024import lucee.runtime.CFMLFactoryImpl; 025import lucee.runtime.config.Config; 026import lucee.runtime.engine.ThreadLocalPageContext; 027import lucee.runtime.exp.ExceptionHandler; 028import lucee.runtime.listener.ApplicationListener; 029import lucee.runtime.op.Caster; 030 031public class SessionEndCacheEvent implements CacheEventListener { 032 033 public void onExpires(CacheEntry entry) { 034 String key=entry.getKey(); 035 036 // type 037 int index=key.indexOf(':'),last; 038 //String type=key.substring(0,index); 039 040 // cfid 041 last=index+1; 042 index=key.indexOf(':',last); 043 String cfid=key.substring(last,index); 044 045 // appName 046 last=index+1; 047 index=key.indexOf(':',last); 048 String appName=key.substring(last); 049 050 Config config = ThreadLocalPageContext.getConfig(); 051 052 _doEnd((CFMLFactoryImpl) config.getFactory(), appName, cfid); 053 } 054 055 private void _doEnd(CFMLFactoryImpl factory,String appName, String cfid) { 056 ApplicationListener listener = factory.getConfig().getApplicationListener(); 057 try { 058 factory.getScopeContext().info("call onSessionEnd for "+appName+"/"+cfid); 059 listener.onSessionEnd(factory, appName, cfid); 060 } 061 catch (Throwable t) { 062 ExceptionUtil.rethrowIfNecessary(t); 063 ExceptionHandler.log(factory.getConfig(),Caster.toPageException(t)); 064 } 065 } 066 067 @Override 068 public void onRemove(CacheEntry entry) { 069 // TODO Auto-generated method stub 070 071 } 072 073 @Override 074 public void onPut(CacheEntry entry) { 075 // TODO Auto-generated method stub 076 077 } 078 079 080 @Override 081 public CacheEventListener duplicate() { 082 // TODO Auto-generated method stub 083 return null; 084 } 085 086}