load an new instance of the client datasource scope

@param cacheName
@param appName
@param pc
@return client datasource scope
@throws PageException
426023
public static Session getInstance(String cacheName, String appName, PageContext pc, Session existing, Log log) throws PageException {
	if (appName != null && appName.startsWith("no-in-memory-cache-")) existing = null;

	synchronized (token) {
	    StorageValue sv = _loadData(pc, cacheName, appName, "session", log);
	    if (sv != null) {
		long time = sv.lastModified();

		if (existing instanceof StorageScopeCache) {
		    if (((StorageScopeCache) existing).lastModified() >= time) {
			return existing;
		    }
		}
		return new SessionCache(pc, cacheName, appName, sv.getValue(), time);
	    }
	    else if (existing != null) {
		return existing;
	    }

	    SessionCache session = new SessionCache(pc, cacheName, appName, new StructImpl(), 0);
	    session.store(pc);
	    return session;
	}
    }
562670
public static Cache getDefault(PageContext pc, int type) throws IOException {
	// get default from application conetxt
	String name = pc != null ? pc.getApplicationContext().getDefaultCacheName(type) : null;
	if (!StringUtil.isEmpty(name)) {
	    Cache cc = getCache(pc, name, null);
	    if (cc != null) return cc;
	}

	// get default from config
	Config config = ThreadLocalPageContext.getConfig(pc);
	CacheConnection cc = ((ConfigImpl) config).getCacheDefaultConnection(type);
	if (cc == null)
	    throw new CacheException("there is no default " + toStringType(type, "") + " cache defined, you need to define this default cache in the Lucee Administrator");
	return cc.getInstance(config);
    }
733469
public static Client getInstance(String name, PageContext pc, Log log) {

	Resource res = _loadResource(pc.getConfig(), SCOPE_CLIENT, name, pc.getCFID());
	Struct data = _loadData(pc, res, log);
	return new ClientFile(pc, res, data);
    }
866901
public static String call(PageContext pc, Object var, boolean serializeQueryByColumns) throws PageException {
	return _call(pc, var, serializeQueryByColumns, pc.getWebCharset());
    }
199398
public DataSource getDataSource(String dataSourceName) throws
      ServiceLocatorException {
    DataSource dataSource = null;
    try {
      if (cache.containsKey(dataSourceName)) {
        dataSource = (DataSource) cache.get(dataSourceName);
      } else {
        dataSource = (DataSource) ic.lookup(dataSourceName);
        cache.put(dataSourceName, dataSource);
      }
    } catch (NamingException ne) {
      throw new ServiceLocatorException(ne);
    } catch (Exception e) {
      throw new ServiceLocatorException(e);
    }
    return dataSource;
  }
376444
protected Object getFromCache(String cacheName, String key) {
        try {
            ICache cache = getCache(cacheName);
            return cache != null ? cache.get(key) : null;
        } catch (CacheException e) {
            LOGGER.warn(e.getMessage(), e);
            return null;
        }
    }
57659
public static Object call(PageContext pc, Object coll, Collection.Key methodName, Object[] args, short[] types, String[] strTypes) throws PageException {

	// look for members
	short type;
	String strType;
	Map<Key, FunctionLibFunction> members = null;
	for (int i = 0; i < types.length; i++) {
	    type = types[i];
	    strType = strTypes[i];
	    members = getMembers(pc, type);
	    FunctionLibFunction member = members.get(methodName);
	    if (member != null) {
		List<FunctionLibFunctionArg> _args = member.getArg();
		if (args.length < _args.size()) {
		    ArrayList<Ref> refs = new ArrayList<Ref>();

		    int pos = member.getMemberPosition();
		    FunctionLibFunctionArg flfa;
		    Iterator<FunctionLibFunctionArg> it = _args.iterator();
		    int glbIndex = 0, argIndex = -1;
		    while (it.hasNext()) {
			glbIndex++;
			flfa = it.next();
			if (glbIndex == pos) {
			    refs.add(new Casting(strType, type, coll));
			}
			else if (args.length > ++argIndex) { // careful, argIndex is only incremented when condition above is false
			    refs.add(new Casting(flfa.getTypeAsString(), flfa.getType(), args[argIndex]));
			}
		    }
		    return new BIFCall(coll, member, refs.toArray(new Ref[refs.size()])).getValue(pc);
		}

	    }
	}

	// do reflection
	if (pc.getConfig().getSecurityManager().getAccess(lucee.runtime.security.SecurityManager.TYPE_DIRECT_JAVA_ACCESS) == lucee.runtime.security.SecurityManager.VALUE_YES) {
	    if (!(coll instanceof Undefined)) {
		Object res = callMethod(coll, methodName, args);
		if (res != DEFAULT) return res;
	    }
	}

	// merge
	if (types.length > 1) {
	    Map<Key, FunctionLibFunction> tmp;
	    members = null;
	    for (int i = 0; i < types.length; i++) {
		tmp = getMembers(pc, types[i]);
		if (members == null) members = tmp;
		else {
		    Iterator<Entry<Key, FunctionLibFunction>> it = tmp.entrySet().iterator();
		    Entry<Key, FunctionLibFunction> e;
		    while (it.hasNext()) {
			e = it.next();
			members.put(e.getKey(), e.getValue());
		    }
		}
	    }
	}
	Set<Key> set = members.keySet();
	String msg = ExceptionUtil.similarKeyMessage(set.toArray(new Key[set.size()]), methodName.getString(), "function", "functions", "Object", true);
	throw new ExpressionException(msg);
	// throw new ExpressionException("No matching function member ["+methodName+"] found, available
	// function members are ["+
	// lucee.runtime.type.util.ListUtil.sort(CollectionUtil.getKeyList(members.keySet().iterator(),
	// ","),"textnocase","asc",",")+"]");
    }
428573
function loadTemplates(appName) {

    let appConfig = AmorphicContext.applicationConfig[appName] || {};
    let applicationSource = AmorphicContext.applicationSource;
    let applicationSourceMap = AmorphicContext.applicationSourceMap;
    let controllerPath = (appConfig.appConfig.controller || 'controller.js');
    let matches = controllerPath.match(/(.*?)([0-9A-Za-z_]*)\.js$/);
    let prop = matches[2];
    let baseTemplate = buildBaseTemplate(appConfig);

    applicationSource[appName] = '';
    applicationSourceMap[appName] = '';

    // Inject into it any db or persist attributes needed for application
    if (appConfig.initObjectTemplate && typeof appConfig.initObjectTemplate === 'function') {
        appConfig.initObjectTemplate(baseTemplate);
    }

    return [
        baseTemplate,
        getTemplates(baseTemplate, appConfig.appPath, [prop + '.js'], appConfig, appName)
    ];
}
979915
public static Server getServerScope(PageContext pc, boolean jsr223) {
	if (server == null) {
	    server = new ServerImpl(pc, jsr223);
	}
	return server;
    }
1229224
private void doUpdateScope() throws PageException {

	admin.updateScopeCascadingType(getString("admin", action, "scopeCascadingType"));
	admin.updateAllowImplicidQueryCall(getBoolObject("admin", action, "allowImplicidQueryCall"));
	admin.updateMergeFormAndUrl(getBoolObject("admin", action, "mergeFormAndUrl"));
	admin.updateSessionManagement(getBoolObject("admin", action, "sessionManagement"));
	admin.updateClientManagement(getBoolObject("admin", action, "clientManagement"));
	admin.updateDomaincookies(getBoolObject("admin", action, "domainCookies"));
	admin.updateClientCookies(getBoolObject("admin", action, "clientCookies"));
	// admin.updateRequestTimeout(getTimespan("admin",action,"requestTimeout"));
	admin.updateClientTimeout(getTimespan("admin", action, "clientTimeout"));
	admin.updateSessionTimeout(getTimespan("admin", action, "sessionTimeout"));
	admin.updateClientStorage(getString("admin", action, "clientStorage"));
	admin.updateSessionStorage(getString("admin", action, "sessionStorage"));
	admin.updateApplicationTimeout(getTimespan("admin", action, "applicationTimeout"));
	admin.updateSessionType(getString("admin", action, "sessionType"));
	admin.updateLocalMode(getString("admin", action, "localMode"));
	admin.updateCGIReadonly(getBoolObject("admin", action, "cgiReadonly"));
	store();
	adminSync.broadcast(attributes, config);
    }
1086614
public static Object call(PageContext pc, String sql, Object params, Struct options, String name) throws PageException {
	PageContextImpl pci = (PageContextImpl) pc;
	lucee.runtime.tag.Query qry = (lucee.runtime.tag.Query) pci.use(lucee.runtime.tag.Query.class.getName(), "cfquery", TagLibTag.ATTRIBUTE_TYPE_FIXED);

	try {
	    try {
		qry.hasBody(true);
		// set attributes
		qry.setReturnVariable(true);
		qry.setName(StringUtil.isEmpty(name) ? "QueryExecute" : name);
		if (options != null) TagUtil.setAttributeCollection(pc, qry, null, options, TagLibTag.ATTRIBUTE_TYPE_FIXED);
		qry.setParams(params);

		int res = qry.doStartTag();
		pc.initBody(qry, res);
		pc.forceWrite(sql);
		qry.doAfterBody();
	    }
	    catch (Throwable t) {
		ExceptionUtil.rethrowIfNecessary(t);
		try {
		    qry.doCatch(t);
		}
		catch (Throwable t2) {
		    ExceptionUtil.rethrowIfNecessary(t);
		    throw Caster.toPageException(t2);
		}
	    }
	    finally {
		pc.popBody();
		qry.doFinally();
	    }
	    qry.doEndTag();
	    return qry.getReturnVariable();
	}
	finally {
	    pci.reuse(qry);
	}

    }
861822
public PageSource getPageSource(String key, boolean updateAccesTime) { // DO NOT CHANGE INTERFACE (used by Argus Monitor)
	PageSource ps = pageSources.get(key.toLowerCase());
	if (ps == null) return null;
	if (updateAccesTime) ps.setLastAccessTime();
	return ps;
    }
1264088
private void doVerifyDatasource() throws PageException {
	ClassDefinition cd = new ClassDefinitionImpl(Caster.toString(attributes.get("classname", null), null), Caster.toString(attributes.get("bundleName", null), null),
		Caster.toString(attributes.get("bundleVersion", null), null), config.getIdentification());

	String connStr = (String) attributes.get("connStr", null);
	if (StringUtil.isEmpty(connStr)) connStr = (String) attributes.get("dsn", null);
	if (cd.hasClass() && connStr != null) {
	    _doVerifyDatasource(cd, connStr, getString("admin", action, "dbusername"), getString("admin", action, "dbpassword"));
	}
	else {
	    _doVerifyDatasource(getString("admin", action, "name"), getString("admin", action, "dbusername"), getString("admin", action, "dbpassword"));
	}
    }
648810
public static Session getInstance(String name, PageContext pc, Log log) {
	if (!StringUtil.isEmpty(name)) name = StringUtil.toUpperCase(StringUtil.toVariableName(name));
	String cookieName = "CF_" + TYPE + "_" + name;
	return new SessionCookie(pc, cookieName, _loadData(pc, cookieName, SCOPE_SESSION, "session", log));
    }
773344
public static JSPCache getJspCache(String cacheName) {
        final String methodName = "getJspCache()";
        JSPCache cacheOut = null;
        if (servletCacheEnabled == false) {
            // DYNA1059W=DYNA1059W: WebSphere Dynamic Cache instance named {0} cannot be used because of Dynamic Servlet
            // cache service has not be started.
            Tr.error(tc, "DYNA1059W", new Object[] { cacheName });
        } else {
            if (cacheName != null) {
                try {
                    cacheOut = cacheUnit.getJSPCache(cacheName);
                } catch (Exception e) {
                    // DYNA1003E=DYNA1003E: WebSphere Dynamic Cache instance named {0} can not be initialized because of
                    // error {1}.
                    Tr.error(tc, "DYNA1003E", new Object[] { cacheName, e });
                }
            } else {
                cacheOut = ServerCache.jspCache;
            }
        }
        if (cacheOut == null && TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, methodName + " could not find JSPCache for cacheName=" + cacheName);
        }
        return cacheOut;
    }
383225
public static BIF use(PageContext pc, String className, String bundleName, String bundleVersion) throws PageException {
	String id = toId(className, bundleName, bundleVersion);
	BIF bif = map.get(id);
	if (bif != null) return bif;

	try {
	    Class<?> clazz;
	    // OSGi bundle
	    if (!StringUtil.isEmpty(bundleName)) clazz = ClassUtil.loadClassByBundle(className, bundleName, bundleVersion, pc.getConfig().getIdentification());
	    // JAR
	    else clazz = ClassUtil.loadClass(className);

	    if (Reflector.isInstaneOf(clazz, BIF.class)) bif = (BIF) clazz.newInstance();
	    else bif = new BIFProxy(clazz);
	}
	catch (Exception e) {
	    throw Caster.toPageException(e);
	}
	map.put(id, bif);
	return bif;
    }
699840
public Object get(int access, String name) throws PageException {
	return get(access, KeyImpl.init(name));
    }