001 package railo.runtime.type.scope.session; 002 003 import railo.commons.io.log.Log; 004 import railo.runtime.PageContext; 005 import railo.runtime.exp.PageException; 006 import railo.runtime.type.Collection; 007 import railo.runtime.type.Struct; 008 import railo.runtime.type.StructImpl; 009 import railo.runtime.type.scope.Session; 010 import railo.runtime.type.scope.storage.StorageScopeDatasource; 011 012 public class SessionDatasource extends StorageScopeDatasource implements Session { 013 014 private SessionDatasource(PageContext pc,String datasourceName, Struct sct) { 015 super(pc,datasourceName,"session",SCOPE_SESSION, sct); 016 } 017 018 /** 019 * Constructor of the class, clone existing 020 * @param other 021 */ 022 private SessionDatasource(StorageScopeDatasource other,boolean deepCopy) { 023 super(other,deepCopy); 024 } 025 026 /** 027 * load an new instance of the client datasource scope 028 * @param datasourceName 029 * @param appName 030 * @param pc 031 * @param checkExpires 032 * @return client datasource scope 033 * @throws PageException 034 */ 035 public static Session getInstance(String datasourceName, PageContext pc,Log log) throws PageException { 036 037 Struct _sct = _loadData(pc, datasourceName,"session",SCOPE_SESSION, log,false); 038 if(_sct==null) _sct=new StructImpl(); 039 040 return new SessionDatasource(pc,datasourceName,_sct); 041 } 042 043 public static Session getInstance(String datasourceName, PageContext pc, Log log,Session defaultValue) { 044 try { 045 return getInstance(datasourceName, pc,log); 046 } 047 catch (PageException e) {} 048 return defaultValue; 049 } 050 public static boolean hasInstance(String datasourceName, PageContext pc) { 051 try { 052 return _loadData(pc, datasourceName,"session",SCOPE_SESSION, null,false)!=null; 053 } 054 catch (PageException e) { 055 return false; 056 } 057 } 058 059 060 @Override 061 public Collection duplicate(boolean deepCopy) { 062 return new SessionDatasource(this,deepCopy); 063 } 064 }