001    package railo.runtime.type.scope.session;
002    
003    import railo.commons.io.log.Log;
004    import railo.commons.io.res.Resource;
005    import railo.runtime.PageContext;
006    import railo.runtime.type.Collection;
007    import railo.runtime.type.Struct;
008    import railo.runtime.type.scope.SessionPlus;
009    import railo.runtime.type.scope.storage.StorageScopeFile;
010    
011    public class SessionFile extends StorageScopeFile implements SessionPlus {
012    
013            private static final long serialVersionUID = 3896214476118229640L;
014    
015            
016            /**
017             * Constructor of the class
018             * @param pc
019             * @param name
020             * @param sct
021             */
022            private SessionFile(PageContext pc,Resource res,Struct sct) {
023                    super(pc,res,"session",SCOPE_SESSION,sct);
024            }
025            
026    
027            /**
028             * Constructor of the class, clone existing
029             * @param other
030             */
031            private SessionFile(SessionFile other,boolean deepCopy) {
032                    super(other,deepCopy);
033            }
034    
035            /**
036             * load new instance of the class
037             * @param name
038             * @param pc
039             * @param checkExpires 
040             * @return
041             */
042            public static SessionPlus getInstance(String name, PageContext pc,Log log) {
043    
044                    Resource res=_loadResource(pc.getConfig(),SCOPE_SESSION,name,pc.getCFID());
045                    Struct data=_loadData(pc,res,log);
046                    return new SessionFile(pc,res,data);
047            }
048            
049    
050            public static boolean hasInstance(String name, PageContext pc) {
051                    Resource res=_loadResource(pc.getConfig(),SCOPE_SESSION,name,pc.getCFID());
052                    Struct data=_loadData(pc,res,null);
053                    return data!=null;
054            }
055            
056    
057            /**
058             *
059             * @see railo.runtime.type.Collection#duplicate(boolean)
060             */
061            public Collection duplicate(boolean deepCopy) {
062            return new SessionFile(this,deepCopy);
063            }
064    }