use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class CacheStorageScopeCleaner method _clean.
@Override
protected void _clean() {
ConfigWebImpl config = (ConfigWebImpl) engine.getFactory().getConfig();
Map<String, CacheConnection> connections = config.getCacheConnections();
CacheConnection cc;
if (connections != null) {
Map.Entry<String, CacheConnection> entry;
Iterator<Entry<String, CacheConnection>> it = connections.entrySet().iterator();
while (it.hasNext()) {
entry = it.next();
cc = entry.getValue();
if (cc.isStorage()) {
try {
clean(cc, config);
} catch (IOException e) {
error(e);
}
}
}
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class _GetElement method toResourceExisting.
public static Resource toResourceExisting(Config config, ApplicationContext ac, Object obj, boolean onlyDir) {
// Resource root = config.getRootDirectory();
String path = Caster.toString(obj, null);
if (StringUtil.isEmpty(path, true))
return null;
path = path.trim();
Resource res;
PageContext pc = ThreadLocalPageContext.get();
// first check relative to application . cfc
if (pc != null) {
if (ac == null)
ac = pc.getApplicationContext();
// abs path
if (path.startsWith("/")) {
ConfigWebImpl cwi = (ConfigWebImpl) config;
PageSource ps = cwi.getPageSourceExisting(pc, ac == null ? null : ac.getMappings(), path, false, false, true, false);
if (ps != null) {
res = ps.getResource();
if (res != null && (!onlyDir || res.isDirectory()))
return res;
}
} else // real path
{
Resource src = ac != null ? ac.getSource() : null;
if (src != null) {
res = src.getParentResource().getRealResource(path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
} else // happens when this is called from within the application . cfc (init)
{
res = ResourceUtil.toResourceNotExisting(pc, path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
}
}
}
// then in the webroot
res = config.getRootDirectory().getRealResource(path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
// then absolute
res = ResourceUtil.toResourceNotExisting(config, path);
if (res != null && (!onlyDir || res.isDirectory()))
return res;
return null;
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class Admin method doGetInfo.
private void doGetInfo() throws PageException {
Struct sct = new StructImpl();
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
if (config instanceof ConfigWebImpl) {
ConfigWebImpl cw = (ConfigWebImpl) config;
sct.setEL(KeyConstants._id, cw.getIdentification().getId());
sct.setEL(KeyConstants._label, cw.getLabel());
sct.setEL(KeyConstants._hash, cw.getHash());
sct.setEL(KeyConstants._root, cw.getRootDirectory().getAbsolutePath());
sct.setEL("configServerDir", cw.getConfigServerDir().getAbsolutePath());
sct.setEL("configWebDir", cw.getConfigDir().getAbsolutePath());
} else {
sct.setEL("configServerDir", config.getConfigDir().getAbsolutePath());
sct.setEL("configWebDir", pageContext.getConfig().getConfigDir().getAbsolutePath());
}
sct.setEL(KeyConstants._config, config.getConfigFile().getAbsolutePath());
// Servlets
if (config instanceof ConfigServer) {
ConfigServer cs = (ConfigServer) config;
CFMLEngineImpl engine = (CFMLEngineImpl) cs.getCFMLEngine();
Struct srv = new StructImpl(), params;
ServletConfig[] configs = engine.getServletConfigs();
ServletConfig sc;
Enumeration e;
String name, value;
for (int i = 0; i < configs.length; i++) {
sc = configs[i];
e = sc.getInitParameterNames();
params = new StructImpl();
while (e.hasMoreElements()) {
name = (String) e.nextElement();
value = sc.getInitParameter(name);
params.set(name, value);
}
srv.set(sc.getServletName(), params);
}
sct.set("servlets", srv);
}
// sct.setEL("javaAgentSupported", Caster.toBoolean(InstrumentationUtil.isSupported()));
sct.setEL("javaAgentSupported", Boolean.TRUE);
// sct.setEL("javaAgentPath", ClassUtil.getSourcePathForClass("lucee.runtime.instrumentation.Agent", ""));
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class Admin method doGetContexts.
/**
* @throws PageException
*/
private void doGetContexts() throws PageException {
CFMLFactory[] factories;
if (config instanceof ConfigServerImpl) {
ConfigServerImpl cs = (ConfigServerImpl) config;
factories = cs.getJSPFactories();
} else {
ConfigWebImpl cw = (ConfigWebImpl) config;
factories = new CFMLFactory[] { cw.getFactory() };
}
lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._path, KeyConstants._id, KeyConstants._hash, KeyConstants._label, HAS_OWN_SEC_CONTEXT, KeyConstants._url, CONFIG_FILE, CLIENT_SIZE, CLIENT_ELEMENTS, SESSION_SIZE, SESSION_ELEMENTS }, factories.length, getString("admin", action, "returnVariable"));
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
ConfigWebImpl cw;
for (int i = 0; i < factories.length; i++) {
int row = i + 1;
CFMLFactoryImpl factory = (CFMLFactoryImpl) factories[i];
cw = (ConfigWebImpl) factory.getConfig();
qry.setAtEL(KeyConstants._path, row, ReqRspUtil.getRootPath(factory.getConfigWebImpl().getServletContext()));
qry.setAtEL(CONFIG_FILE, row, factory.getConfigWebImpl().getConfigFile().getAbsolutePath());
if (factory.getURL() != null)
qry.setAtEL(KeyConstants._url, row, factory.getURL().toExternalForm());
qry.setAtEL(KeyConstants._id, row, factory.getConfig().getIdentification().getId());
qry.setAtEL(KeyConstants._hash, row, SystemUtil.hash(factory.getConfigWebImpl().getServletContext()));
qry.setAtEL(KeyConstants._label, row, factory.getLabel());
qry.setAtEL(HAS_OWN_SEC_CONTEXT, row, Caster.toBoolean(cw.hasIndividualSecurityManager()));
setScopeDirInfo(qry, row, CLIENT_SIZE, CLIENT_ELEMENTS, cw.getClientScopeDir());
setScopeDirInfo(qry, row, SESSION_SIZE, SESSION_ELEMENTS, cw.getSessionScopeDir());
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class Admin method doGateway.
private void doGateway() throws PageException {
String id = getString("admin", action, "id");
String act = getString("admin", action, "gatewayAction").trim().toLowerCase();
if ("restart".equals(act))
((ConfigWebImpl) config).getGatewayEngine().restart(id);
else if ("start".equals(act))
((ConfigWebImpl) config).getGatewayEngine().start(id);
else if ("stop".equals(act))
((ConfigWebImpl) config).getGatewayEngine().stop(id);
else
throw new ApplicationException("invalid gateway action [" + act + "], valid actions are [start,stop,restart]");
}
Aggregations