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.Client;
010    import railo.runtime.type.scope.storage.StorageScopeCache;
011    
012    public final class ClientCache extends StorageScopeCache implements Client {
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            @Override
031            public Collection duplicate(boolean deepCopy) {
032            return new ClientCache(this,deepCopy);
033            }
034            
035            /**
036             * load an new instance of the client datasource scope
037             * @param cacheName 
038             * @param appName
039             * @param pc
040             * @param log 
041             * @return client datasource scope
042             * @throws PageException
043             */
044            public static Client getInstance(String cacheName, String appName, PageContext pc, Log log) throws PageException {
045                            Struct _sct = _loadData(pc, cacheName, appName,"client",log);
046                            //structOk=true;
047                            if(_sct==null) _sct=new StructImpl();
048                            
049                    return new ClientCache(pc,cacheName,appName,_sct);
050            }
051            
052    
053            public static Client getInstance(String cacheName, String appName, PageContext pc, Log log,Client defaultValue) {
054                    try {
055                            return getInstance(cacheName, appName, pc,log);
056                    }
057                    catch (PageException e) {}
058                    return defaultValue;
059            }
060    
061    }