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.StorageScopeDatasource;
011    
012    public class ClientDatasource extends StorageScopeDatasource implements Client {
013            
014            private ClientDatasource(PageContext pc,String datasourceName, Struct sct) { 
015                    super(pc,datasourceName,"client",SCOPE_CLIENT, sct);
016            }
017    
018            /**
019             * Constructor of the class, clone existing
020             * @param other
021             */
022            private ClientDatasource(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 log 
032             * @return client datasource scope
033             * @throws PageException
034             */
035            public static Client getInstance(String datasourceName, PageContext pc, Log log) throws PageException {
036                            
037                            Struct _sct = _loadData(pc, datasourceName,"client",SCOPE_CLIENT,log, false);
038                            if(_sct==null) _sct=new StructImpl();
039                            
040                    return new ClientDatasource(pc,datasourceName,_sct);
041            }
042            
043            public static Client getInstance(String datasourceName, PageContext pc,Log log, Client defaultValue) {
044                    try {
045                            return getInstance(datasourceName, pc,log);
046                    }
047                    catch (PageException e) {}
048                    return defaultValue;
049            }
050            
051    
052            @Override
053            public Collection duplicate(boolean deepCopy) {
054            return new ClientDatasource(this,deepCopy);
055            }
056    
057    
058    }