001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.type.scope.client; 020 021import lucee.commons.io.log.Log; 022import lucee.runtime.PageContext; 023import lucee.runtime.exp.PageException; 024import lucee.runtime.type.Collection; 025import lucee.runtime.type.Struct; 026import lucee.runtime.type.StructImpl; 027import lucee.runtime.type.scope.Client; 028import lucee.runtime.type.scope.storage.StorageScopeDatasource; 029 030public class ClientDatasource extends StorageScopeDatasource implements Client { 031 032 private ClientDatasource(PageContext pc,String datasourceName, Struct sct) { 033 super(pc,datasourceName,"client",SCOPE_CLIENT, sct); 034 } 035 036 /** 037 * Constructor of the class, clone existing 038 * @param other 039 */ 040 private ClientDatasource(StorageScopeDatasource other,boolean deepCopy) { 041 super(other,deepCopy); 042 } 043 044 /** 045 * load an new instance of the client datasource scope 046 * @param datasourceName 047 * @param appName 048 * @param pc 049 * @param log 050 * @return client datasource scope 051 * @throws PageException 052 */ 053 public static Client getInstance(String datasourceName, PageContext pc, Log log) throws PageException { 054 055 Struct _sct = _loadData(pc, datasourceName,"client",SCOPE_CLIENT,log, false); 056 if(_sct==null) _sct=new StructImpl(); 057 058 return new ClientDatasource(pc,datasourceName,_sct); 059 } 060 061 public static Client getInstance(String datasourceName, PageContext pc,Log log, Client defaultValue) { 062 try { 063 return getInstance(datasourceName, pc,log); 064 } 065 catch (PageException e) {} 066 return defaultValue; 067 } 068 069 070 @Override 071 public Collection duplicate(boolean deepCopy) { 072 return new ClientDatasource(this,deepCopy); 073 } 074 075 076}