001    package railo.runtime.type.scope.client;
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.ClientPlus;
010    import railo.runtime.type.scope.storage.StorageScopeCache;
011    
012    public final class ClientCache extends StorageScopeCache implements ClientPlus {
013            
014            private static final long serialVersionUID = -875719423763891692L;
015            
016            private ClientCache(PageContext pc,String cacheName, String appName,Struct sct) { 
017                    super(pc,cacheName,appName,"client",SCOPE_CLIENT,sct);
018            }
019    
020            /**
021             * Constructor of the class, clone existing
022             * @param other
023             */
024            private ClientCache(StorageScopeCache other,boolean deepCopy) {
025                    super(other,deepCopy);
026            }
027            
028    
029            
030            /**
031             * @see railo.runtime.type.Collection#duplicate(boolean)
032             */
033            public Collection duplicate(boolean deepCopy) {
034            return new ClientCache(this,deepCopy);
035            }
036            
037            /**
038             * load an new instance of the client datasource scope
039             * @param cacheName 
040             * @param appName
041             * @param pc
042             * @param log 
043             * @return client datasource scope
044             * @throws PageException
045             */
046            public static ClientPlus getInstance(String cacheName, String appName, PageContext pc, Log log) throws PageException {
047                            Struct _sct = _loadData(pc, cacheName, appName,"client",log);
048                            //structOk=true;
049                            if(_sct==null) _sct=new StructImpl();
050                            
051                    return new ClientCache(pc,cacheName,appName,_sct);
052            }
053            
054    
055            public static ClientPlus getInstance(String cacheName, String appName, PageContext pc, Log log,ClientPlus defaultValue) {
056                    try {
057                            return getInstance(cacheName, appName, pc,log);
058                    }
059                    catch (PageException e) {}
060                    return defaultValue;
061            }
062    
063    }