use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class DatasourceStorageScopeCleaner method clean.
private void clean(ConfigWeb config, DataSource dataSource) throws PageException, SQLException {
ConfigWebImpl cwi = (ConfigWebImpl) config;
DatasourceConnection dc = null;
DatasourceConnectionPool pool = cwi.getDatasourceConnectionPool();
try {
dc = pool.getDatasourceConnection(null, dataSource, null, null);
Log log = ((ConfigImpl) config).getLog("scope");
SQLExecutor executor = SQLExecutionFactory.getInstance(dc);
executor.clean(config, dc, type, engine, this, listener, log);
} finally {
if (dc != null)
pool.releaseDatasourceConnection(dc);
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class FileStorageScopeCleaner method _clean.
@Override
protected void _clean() {
ConfigWebImpl cwi = (ConfigWebImpl) engine.getFactory().getConfig();
Resource dir = type == Scope.SCOPE_CLIENT ? cwi.getClientScopeDir() : cwi.getSessionScopeDir();
// for old files only the defintion from admin can be used
long timeout = type == Scope.SCOPE_CLIENT ? cwi.getClientTimeout().getMillis() : cwi.getSessionTimeout().getMillis();
long time = new DateTimeImpl(cwi).getTime() - timeout;
try {
// delete files that has expired
AndResourceFilter andFilter = new AndResourceFilter(new ResourceFilter[] { EXT_FILTER, new ExpiresFilter(time, true) });
String appName, cfid2, cfid;
Resource[] apps = dir.listResources(DIR_FILTER), cfidDir, files;
if (apps != null)
for (int a = 0; a < apps.length; a++) {
appName = StorageScopeImpl.decode(apps[a].getName());
cfidDir = apps[a].listResources(DIR_FILTER);
if (cfidDir != null)
for (int b = 0; b < cfidDir.length; b++) {
cfid2 = cfidDir[b].getName();
files = cfidDir[b].listResources(andFilter);
if (files != null) {
for (int c = 0; c < files.length; c++) {
cfid = files[c].getName();
cfid = cfid2 + cfid.substring(0, cfid.length() - 5);
if (listener != null)
listener.doEnd(engine, this, appName, cfid);
// info("remove from memory "+appName+"/"+cfid);
engine.remove(type, appName, cfid);
info("remove file " + files[c]);
files[c].delete();
}
}
}
}
ResourceUtil.deleteEmptyFolders(dir);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
error(t);
}
// long maxSize = type==Scope.SCOPE_CLIENT?cwi.getClientScopeDirSize():cwi.getSessionScopeDirSize();
// checkSize(config,dir,maxSize,extfilter);
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class MemberUtil method getMembers.
public static Map<Collection.Key, FunctionLibFunction> getMembers(PageContext pc, short type) {
Map<Short, Map<Key, FunctionLibFunction>> matches = pc.getCurrentTemplateDialect() == CFMLEngine.DIALECT_LUCEE ? matchesLucee : matchesCFML;
Map<Key, FunctionLibFunction> match = matches.get(type);
if (match != null)
return match;
FunctionLib[] flds = ((ConfigWebImpl) pc.getConfig()).getFLDs(pc.getCurrentTemplateDialect());
Iterator<FunctionLibFunction> it;
FunctionLibFunction f;
match = new HashMap<Collection.Key, FunctionLibFunction>();
String[] names;
for (int i = 0; i < flds.length; i++) {
it = flds[i].getFunctions().values().iterator();
while (it.hasNext()) {
f = it.next();
names = f.getMemberNames();
if (!ArrayUtil.isEmpty(names) && f.getMemberType() == type && f.getArgType() == FunctionLibFunction.ARG_FIX) {
for (int y = 0; y < names.length; y++) match.put(KeyImpl.getInstance(names[y]), f);
}
}
}
matches.put(type, match);
return match;
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class CFFunction method loadUDF.
public static UDF loadUDF(PageContext pc, String filename, Collection.Key name, boolean isweb) throws PageException {
ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
String key = isweb ? name.getString() + config.getIdentification().getId() : name.getString();
UDF udf = config.getFromFunctionCache(key);
if (udf != null)
return udf;
Mapping mapping = isweb ? config.getFunctionMapping() : config.getServerFunctionMapping();
Page p = mapping.getPageSource(filename).loadPage(pc, false);
// execute page
Variables old = pc.variablesScope();
pc.setVariablesScope(VAR);
boolean wasSilent = pc.setSilent();
try {
p.call(pc);
Object o = pc.variablesScope().get(name, null);
if (o instanceof UDF) {
udf = (UDF) o;
config.putToFunctionCache(key, udf);
return udf;
}
throw new ExpressionException("there is no Function defined with name [" + name + "] in template [" + mapping.getStrPhysical() + File.separator + filename + "]");
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
} finally {
pc.setVariablesScope(old);
if (!wasSilent)
pc.unsetSilent();
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class ExpandPath method call.
public static String call(PageContext pc, String relPath) throws PageException {
ConfigWeb config = pc.getConfig();
relPath = prettifyPath(pc, relPath);
String contextPath = pc.getHttpServletRequest().getContextPath();
if (!StringUtil.isEmpty(contextPath) && relPath.startsWith(contextPath + "/")) {
boolean sws = StringUtil.startsWith(relPath, '/');
relPath = relPath.substring(contextPath.length());
if (sws && !StringUtil.startsWith(relPath, '/'))
relPath = "/" + relPath;
}
Resource res;
if (StringUtil.startsWith(relPath, '/')) {
PageContextImpl pci = (PageContextImpl) pc;
ConfigWebImpl cwi = (ConfigWebImpl) config;
PageSource[] sources = cwi.getPageSources(pci, pc.getApplicationContext().getMappings(), relPath, false, pci.useSpecialMappings(), true);
if (!ArrayUtil.isEmpty(sources)) {
// first check for existing
for (int i = 0; i < sources.length; i++) {
if (sources[i].exists()) {
return toReturnValue(relPath, sources[i].getResource());
}
}
// no expand needed
if (!SystemUtil.isWindows() && !sources[0].exists()) {
res = pc.getConfig().getResource(relPath);
if (res.exists()) {
return toReturnValue(relPath, res);
}
}
for (int i = 0; i < sources.length; i++) {
res = sources[i].getResource();
if (res != null) {
return toReturnValue(relPath, res);
}
}
} else // no expand needed
if (!SystemUtil.isWindows()) {
res = pc.getConfig().getResource(relPath);
if (res.exists()) {
return toReturnValue(relPath, res);
}
}
// Resource[] reses = cwi.getPhysicalResources(pc,pc.getApplicationContext().getMappings(),realPath,false,pci.useSpecialMappings(),true);
}
relPath = ConfigWebUtil.replacePlaceholder(relPath, config);
res = pc.getConfig().getResource(relPath);
if (res.isAbsolute())
return toReturnValue(relPath, res);
PageSource ps = pc.getBasePageSource();
res = ps == null ? ResourceUtil.getCanonicalResourceEL(ResourceUtil.toResourceExisting(pc.getConfig(), ReqRspUtil.getRootPath(pc.getServletContext()))) : ResourceUtil.getResource(pc, ps);
if (!res.isDirectory())
res = res.getParentResource();
res = res.getRealResource(relPath);
return toReturnValue(relPath, res);
}
Aggregations