use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.
the class Controler method control.
private void control(CFMLFactoryImpl cfmlFactory, boolean do10Seconds, boolean doMinute, boolean doHour, boolean firstRun) {
try {
boolean isRunning = cfmlFactory.getUsedPageContextLength() > 0;
if (isRunning) {
cfmlFactory.checkTimeout();
}
ConfigWeb config = null;
if (firstRun) {
config = cfmlFactory.getConfig();
ThreadLocalConfig.register(config);
config.reloadTimeServerOffset();
checkOldClientFile(config);
// try{checkStorageScopeFile(config,Session.SCOPE_SESSION);}catch(Throwable t) {ExceptionUtil.rethrowIfNecessary(t);}
try {
config.reloadTimeServerOffset();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
try {
checkTempDirectorySize(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
try {
checkCacheFileSize(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
try {
cfmlFactory.getScopeContext().clearUnused();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
if (config == null) {
config = cfmlFactory.getConfig();
}
ThreadLocalConfig.register(config);
if (do10Seconds) {
// try{DeployHandler.deploy(config);}catch(Throwable t){ExceptionUtil.rethrowIfNecessary(t);}
}
// every Minute
if (doMinute) {
if (config == null) {
config = cfmlFactory.getConfig();
}
ThreadLocalConfig.register(config);
// double check templates
try {
((ConfigWebImpl) config).getCompiler().checkWatched();
} catch (Exception e) {
SystemOut.printDate(e);
}
// deploy extensions, archives ...
try {
DeployHandler.deploy(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// clear unused DB Connections
try {
((ConfigImpl) config).getDatasourceConnectionPool().clear(false);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// clear all unused scopes
try {
cfmlFactory.getScopeContext().clearUnused();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// try{checkPermGenSpace((ConfigWebImpl) config);}catch(Throwable t) {ExceptionUtil.rethrowIfNecessary(t);}
try {
doCheckMappings(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
try {
doClearMailConnections();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// clean LockManager
if (cfmlFactory.getUsedPageContextLength() == 0)
try {
((LockManagerImpl) config.getLockManager()).clean();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
try {
XMLConfigAdmin.checkForChangesInConfigFile(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
// every hour
if (doHour) {
if (config == null) {
config = cfmlFactory.getConfig();
}
ThreadLocalConfig.register(config);
// time server offset
try {
config.reloadTimeServerOffset();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// check temp directory
try {
checkTempDirectorySize(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
// check cache directory
try {
checkCacheFileSize(config);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
try {
configServer.checkPermGenSpace(true);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
} finally {
ThreadLocalConfig.release();
}
}
use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.
the class PageExceptionImpl method _getTagContext.
private static void _getTagContext(Config config, Array tagContext, StackTraceElement[] traces, LinkedList<PageSource> sources) {
// StackTraceElement[] traces = getStackTraceElements(t);
int line = 0;
String template = "", tlast;
Struct item;
StackTraceElement trace = null;
int index = -1;
PageSource ps;
PageContextImpl pc = null;
if (config instanceof ConfigWeb)
pc = (PageContextImpl) ThreadLocalPageContext.get();
for (int i = 0; i < traces.length; i++) {
trace = traces[i];
tlast = template;
template = trace.getFileName();
if (trace.getLineNumber() <= 0 || template == null || ResourceUtil.getExtension(template, "").equals("java"))
continue;
// content
if (!StringUtil.emptyIfNull(tlast).equals(template))
index++;
String[] content = null;
String dspPath = template;
try {
Resource res = config.getResource(template);
if (!res.exists()) {
PageSource _ps = pc == null ? null : pc.getPageSource(template);
res = _ps == null ? null : _ps.getPhyscalFile();
if (res == null || !res.exists()) {
res = config.getResource(_ps.getDisplayPath());
if (res != null && res.exists())
dspPath = res.getAbsolutePath();
} else
dspPath = res.getAbsolutePath();
} else
dspPath = res.getAbsolutePath();
// class was not build on the local filesystem
if (!res.exists()) {
SourceInfo si = pc != null ? MappingUtil.getMatch(pc, trace) : MappingUtil.getMatch(config, trace);
if (si != null && si.relativePath != null) {
dspPath = si.relativePath;
res = ResourceUtil.toResourceNotExisting(ThreadLocalPageContext.get(), si.relativePath, true, true);
if (!res.exists()) {
PageSource _ps = PageSourceImpl.best(config.getPageSources(ThreadLocalPageContext.get(), null, si.relativePath, false, false, true));
if (_ps != null && _ps.exists()) {
res = _ps.getResource();
if (res != null && res.exists())
dspPath = res.getAbsolutePath();
} else
dspPath = res.getAbsolutePath();
} else
dspPath = res.getAbsolutePath();
}
}
if (res.exists()) {
InputStream is = res.getInputStream();
if (ClassUtil.isBytecode(is)) {
// empty code array to show ??
content = new String[] {};
} else
content = IOUtil.toStringArray(IOUtil.getReader(res, config.getTemplateCharset()));
IOUtil.closeEL(is);
} else {
if (sources.size() > index)
ps = sources.get(index);
else
ps = null;
if (ps != null && trace.getClassName().equals(ps.getClassName())) {
if (ps.physcalExists())
content = IOUtil.toStringArray(IOUtil.getReader(ps.getPhyscalFile(), config.getTemplateCharset()));
template = ps.getDisplayPath();
}
}
} catch (Throwable th) {
}
// check last
if (tagContext.size() > 0) {
try {
Struct last = (Struct) tagContext.getE(tagContext.size());
if (last.get(KeyConstants._Raw_Trace).equals(trace.toString()))
continue;
} catch (Exception e) {
}
}
item = new StructImpl();
line = trace.getLineNumber();
item.setEL(KeyConstants._template, dspPath);
item.setEL(KeyConstants._line, new Double(line));
item.setEL(KeyConstants._id, "??");
item.setEL(KeyConstants._Raw_Trace, trace.toString());
item.setEL(KeyConstants._type, "cfml");
item.setEL(KeyConstants._column, new Double(0));
if (content != null) {
if (content.length > 0) {
item.setEL(KeyConstants._codePrintHTML, getCodePrint(content, line, true));
item.setEL(KeyConstants._codePrintPlain, getCodePrint(content, line, false));
} else {
item.setEL(KeyConstants._codePrintHTML, "??");
item.setEL(KeyConstants._codePrintPlain, "??");
}
} else {
item.setEL(KeyConstants._codePrintHTML, "");
item.setEL(KeyConstants._codePrintPlain, "");
}
// FUTURE id
tagContext.appendEL(item);
}
}
use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.
the class RHExtension method readManifestConfig.
private void readManifestConfig(Manifest manifest, String label, String _img) throws ApplicationException {
boolean isWeb = config instanceof ConfigWeb;
type = isWeb ? "web" : "server";
Log logger = ((ConfigImpl) config).getLog("deploy");
Info info = ConfigWebUtil.getEngine(config).getInfo();
Attributes attr = manifest.getMainAttributes();
readName(label, StringUtil.unwrap(attr.getValue("name")));
label = name;
readVersion(label, StringUtil.unwrap(attr.getValue("version")));
label += " : " + version;
readId(label, StringUtil.unwrap(attr.getValue("id")));
readReleaseType(label, StringUtil.unwrap(attr.getValue("release-type")), isWeb);
description = StringUtil.unwrap(attr.getValue("description"));
trial = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("trial")), false);
if (_img == null)
_img = StringUtil.unwrap(attr.getValue("image"));
image = _img;
String cat = StringUtil.unwrap(attr.getValue("category"));
if (StringUtil.isEmpty(cat, true))
cat = StringUtil.unwrap(attr.getValue("categories"));
readCategories(label, cat);
readCoreVersion(label, StringUtil.unwrap(attr.getValue("lucee-core-version")), info);
readLoaderVersion(label, StringUtil.unwrap(attr.getValue("lucee-loader-version")));
startBundles = Caster.toBooleanValue(StringUtil.unwrap(attr.getValue("start-bundles")), true);
readAMF(label, StringUtil.unwrap(attr.getValue("amf")), logger);
readResource(label, StringUtil.unwrap(attr.getValue("resource")), logger);
readSearch(label, StringUtil.unwrap(attr.getValue("search")), logger);
readORM(label, StringUtil.unwrap(attr.getValue("orm")), logger);
readMonitor(label, StringUtil.unwrap(attr.getValue("monitor")), logger);
readCache(label, StringUtil.unwrap(attr.getValue("cache")), logger);
readCacheHandler(label, StringUtil.unwrap(attr.getValue("cache-handler")), logger);
readJDBC(label, StringUtil.unwrap(attr.getValue("jdbc")), logger);
readMapping(label, StringUtil.unwrap(attr.getValue("mapping")), logger);
readEventGatewayInstances(label, StringUtil.unwrap(attr.getValue("event-gateway-instance")), logger);
}
use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.
the class CustomTagUtil method loadInitFile.
public static InitFile loadInitFile(PageContext pc, String name) throws PageException {
InitFile initFile = loadInitFile(pc, name, null);
if (initFile != null) {
return initFile;
}
// EXCEPTION
ConfigWeb config = pc.getConfig();
// message
StringBuilder msg = new StringBuilder("Custom tag \"").append(getDisplayName(config, name)).append("\" was not found.");
List<String> dirs = new ArrayList();
if (config.doLocalCustomTag()) {
dirs.add(ResourceUtil.getResource(pc, pc.getCurrentPageSource()).getParent());
}
Mapping[] actms = pc.getApplicationContext().getCustomTagMappings();
Mapping[] cctms = config.getCustomTagMappings();
Resource r;
if (actms != null) {
for (Mapping m : actms) {
r = m.getPhysical();
if (r != null)
dirs.add(r.toString());
}
}
if (cctms != null) {
for (Mapping m : cctms) {
r = m.getPhysical();
if (r != null)
dirs.add(r.toString());
}
}
if (!dirs.isEmpty()) {
msg.append(" Directories searched: ");
Iterator<String> it = dirs.iterator();
while (it.hasNext()) {
msg.append('"').append(it.next()).append('"');
if (it.hasNext())
msg.append(", ");
}
}
throw new ExpressionException(msg.toString());
}
use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.
the class DatasourceStorageScopeCleaner method _clean.
@Override
protected void _clean() {
ConfigWeb config = engine.getFactory().getConfig();
DataSource[] datasources = config.getDataSources();
for (int i = 0; i < datasources.length; i++) {
if (datasources[i].isStorage()) {
try {
clean(config, datasources[i]);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
error(t);
}
}
}
}
Aggregations