001 package railo.runtime.type.scope; 002 003 import java.util.Map; 004 005 import railo.runtime.PageContext; 006 import railo.runtime.engine.ThreadLocalPageContext; 007 import railo.runtime.functions.system.GetApplicationSettings; 008 import railo.runtime.type.Collection; 009 import railo.runtime.type.KeyImpl; 010 import railo.runtime.type.SharedScope; 011 import railo.runtime.util.ApplicationContext; 012 013 014 015 /** 016 * Session Scope 017 */ 018 public final class ApplicationImpl extends ScopeSupport implements Application,SharedScope { 019 020 private static final long serialVersionUID = 700830188207594563L; 021 022 private static final Collection.Key APPLICATION_NAME = KeyImpl.intern("applicationname"); 023 private long lastAccess; 024 private long timeSpan; 025 026 /** 027 * default constructor of the session scope 028 */ 029 public ApplicationImpl() { 030 super(true,"application",SCOPE_APPLICATION); 031 } 032 033 /** 034 * @see railo.runtime.type.scope.Application#getLastAccess() 035 */ 036 public long getLastAccess() { 037 return lastAccess; 038 } 039 040 /** 041 * @see railo.runtime.type.scope.Application#getTimeSpan() 042 */ 043 public long getTimeSpan() { 044 return timeSpan; 045 } 046 047 /** 048 * @see railo.runtime.type.Scope#initialize(railo.runtime.PageContext) 049 */ 050 public void touchBeforeRequest(PageContext pc){ 051 ApplicationContext appContext = pc.getApplicationContext(); 052 setEL(APPLICATION_NAME,appContext.getName()); 053 timeSpan=appContext.getApplicationTimeout().getMillis(); 054 lastAccess=System.currentTimeMillis(); 055 } 056 057 public void touchAfterRequest(PageContext pc) { 058 // do nothing 059 } 060 061 /** 062 * @see railo.runtime.type.scope.Application#isExpired() 063 */ 064 public boolean isExpired() { 065 return (lastAccess+timeSpan)<System.currentTimeMillis(); 066 } 067 068 /** 069 * @param lastAccess the lastAccess to set 070 */ 071 public void setLastAccess(long lastAccess) { 072 this.lastAccess = lastAccess; 073 } 074 075 /** 076 * 077 * @see railo.runtime.type.scope.Application#touch() 078 */ 079 public void touch() { 080 lastAccess=System.currentTimeMillis(); 081 } 082 083 /** 084 * undocumented Feature in ACF 085 * @return 086 */ 087 public Map getApplicationSettings(){ 088 return GetApplicationSettings.call(ThreadLocalPageContext.get()); 089 } 090 }