use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class Props method call.
@Override
public Object call(PageContext pc) throws PageException {
// remote persistent (only type server is supported)
// Caster.toString(pc.urlFormScope().get(REMOTE_PERSISTENT_ID,null),null);
String strRemotePersisId = Caster.toString(getURLorForm(pc, REMOTE_PERSISTENT_ID, null), null);
if (!StringUtil.isEmpty(strRemotePersisId, true)) {
strRemotePersisId = strRemotePersisId.trim();
} else
strRemotePersisId = null;
HttpServletRequest req = pc.getHttpServletRequest();
// client
String client = Caster.toString(req.getAttribute("client"), null);
// call type (invocation, store-only)
String callType = Caster.toString(req.getAttribute("call-type"), null);
boolean internalCall = "lucee-gateway-1-0".equals(client) || "lucee-listener-1-0".equals(client);
boolean fromRest = "lucee-rest-1-0".equals(client);
Component component;
try {
pc.setSilent();
// load the cfc
try {
if (internalCall && strRemotePersisId != null) {
ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
GatewayEngineImpl engine = config.getGatewayEngine();
component = engine.getPersistentRemoteCFC(strRemotePersisId);
if (component == null) {
component = newInstance(pc, getComponentName(), false, false, true);
if (!internalCall)
component = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_REMOTE, component);
engine.setPersistentRemoteCFC(strRemotePersisId, component);
}
} else {
component = newInstance(pc, getComponentName(), false, false, true);
if (!internalCall)
component = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_REMOTE, component);
}
} finally {
pc.unsetSilent();
}
// Only get the Component, no invocation
if ("store-only".equals(callType)) {
req.setAttribute("component", component);
return null;
}
// METHOD INVOCATION
String qs = ReqRspUtil.getQueryString(pc.getHttpServletRequest());
if (pc.getBasePageSource() == this.getPageSource() && pc.getConfig().debug())
pc.getDebugger().setOutput(false);
boolean isPost = pc.getHttpServletRequest().getMethod().equalsIgnoreCase("POST");
boolean suppressContent = pc.getRequestDialect() == CFMLEngine.DIALECT_LUCEE || ((PageContextImpl) pc).getSuppressContent();
if (suppressContent)
pc.clear();
Object method;
if (fromRest) {
callRest(pc, component, Caster.toString(req.getAttribute("rest-path"), ""), (Result) req.getAttribute("rest-result"), suppressContent);
return null;
}
// POST
if (isPost) {
// Soap
if (isSoap(pc)) {
callWebservice(pc, component);
// close(pc);
return null;
} else // WDDX
if ((method = getURLorForm(pc, KeyConstants._method, null)) != null) {
callWDDX(pc, component, KeyImpl.toKey(method), suppressContent);
// close(pc);
return null;
}
} else // GET
{
// WSDL
if (qs != null && (qs.trim().equalsIgnoreCase("wsdl") || qs.trim().startsWith("wsdl&"))) {
callWSDL(pc, component);
// close(pc);
return null;
} else // WDDX
if ((method = getURLorForm(pc, KeyConstants._method, null)) != null) {
callWDDX(pc, component, KeyImpl.toKey(method), suppressContent);
// close(pc);
return null;
}
if (qs != null) {
int rf = UDFUtil.toReturnFormat(qs.trim(), -1);
if (rf != -1)
callCFCMetaData(pc, component, rf);
// close(pc);
return null;
}
}
// Include MUST
Array path = pc.getTemplatePath();
// if(path.size()>1 ) {
if (path.size() > 1 && !(path.size() == 3 && ListUtil.last(path.getE(2).toString(), "/\\", true).equalsIgnoreCase(pc.getRequestDialect() == CFMLEngine.DIALECT_CFML ? lucee.runtime.config.Constants.CFML_APPLICATION_EVENT_HANDLER : lucee.runtime.config.Constants.LUCEE_APPLICATION_EVENT_HANDLER))) {
// MUSTMUST bad impl -> check with and without application . cfc
ComponentSpecificAccess c = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, component);
Key[] keys = c.keys();
Object el;
Scope var = pc.variablesScope();
for (int i = 0; i < keys.length; i++) {
el = c.get(keys[i], null);
if (el instanceof UDF)
var.set(keys[i], el);
}
return null;
}
// DUMP
// TODO component.setAccess(pc,Component.ACCESS_PUBLIC);
String cdf = pc.getConfig().getComponentDumpTemplate();
if (cdf != null && cdf.trim().length() > 0) {
pc.variablesScope().set(KeyConstants._component, component);
pc.doInclude(cdf, false);
} else
pc.write(pc.getConfig().getDefaultDumpWriter(DumpWriter.DEFAULT_RICH).toString(pc, component.toDumpData(pc, 9999, DumpUtil.toDumpProperties()), true));
} catch (Throwable t) {
// Exception Handler.castAnd Stack(t, this, pc);
throw Caster.toPageException(t);
}
return null;
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class MappingImpl method check.
@Override
public void check() {
// if(config instanceof ConfigServer) return;
// ConfigWebImpl cw=(ConfigWebImpl) config;
ServletContext cs = (config instanceof ConfigWebImpl) ? ((ConfigWebImpl) config).getServletContext() : null;
// Physical
if (getPhysical() == null && strPhysical != null && strPhysical.length() > 0) {
physical = ConfigWebUtil.getExistingResource(cs, strPhysical, null, config.getConfigDir(), FileUtil.TYPE_DIR, config);
}
// Archive
if (getArchive() == null && strArchive != null && strArchive.length() > 0) {
archive = ConfigWebUtil.getExistingResource(cs, strArchive, null, config.getConfigDir(), FileUtil.TYPE_FILE, config);
loadArchive();
hasArchive = archive != null;
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class CFMLEngineImpl method loadJSPFactory.
private CFMLFactoryImpl loadJSPFactory(ConfigServerImpl configServer, ServletConfig sg, int countExistingContextes) throws ServletException {
try {
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("load Context");
// Load Config
RefBoolean isCustomSetting = new RefBooleanImpl();
Resource configDir = getConfigDirectory(sg, configServer, countExistingContextes, isCustomSetting);
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("got context directory");
CFMLFactoryImpl factory = new CFMLFactoryImpl(this, sg);
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("init factory");
ConfigWebImpl config = XMLConfigWebFactory.newInstance(this, factory, configServer, configDir, isCustomSetting.toBooleanValue(), sg);
if (XMLConfigWebFactory.LOG)
SystemOut.printDate("loaded config");
factory.setConfig(config);
return factory;
} catch (Exception e) {
ServletException se = new ServletException(e.getMessage());
se.setStackTrace(e.getStackTrace());
throw se;
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class Renderer method loadClass.
private static Class<? extends Page> loadClass(ConfigWeb config, String className, String cfml, int dialect, boolean ignoreScopes) throws Exception {
ConfigWebImpl cw = (ConfigWebImpl) config;
CFMLCompilerImpl compiler = cw.getCompiler();
// create className based o the content
Class<? extends Page> clazz = null;
if (mcl == null) {
mcl = createMemoryClassLoader(cw);
} else
clazz = ClassUtil.loadClass(mcl, className, null);
if (clazz != null)
return clazz;
SourceCode sc = new SourceCode(cfml, false, dialect);
// compile
lucee.runtime.compiler.CFMLCompilerImpl.Result result = compiler.compile(cw, sc, cw.getTLDs(dialect), cw.getFLDs(dialect), null, className, true, ignoreScopes);
// before we add a new class, we make sure we are still in range
if (mcl.getSize() + result.barr.length > MAX_SIZE) {
mcl = createMemoryClassLoader(cw);
pages.clear();
}
return (Class<? extends Page>) mcl.loadClass(className, result.barr);
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class GetUsageData method call.
public static Struct call(PageContext pc) throws PageException {
ConfigWeb cw = pc.getConfig();
ConfigServer cs = cw.getConfigServer("server");
ConfigWeb[] webs = cs.getConfigWebs();
CFMLEngineFactory.getInstance();
CFMLEngineImpl engine = (CFMLEngineImpl) cs.getCFMLEngine();
Struct sct = new StructImpl();
// Locks
/*LockManager manager = pc.getConfig().getLockManager();
String[] locks = manager.getOpenLockNames();
for(int i=0;i<locks.length;i++){
locks[i].
}
if(!ArrayUtil.isEmpty(locks))
strLocks=" open locks at this time ("+List.arrayToList(locks, ", ")+").";
*/
// Requests
Query req = new QueryImpl(new Collection.Key[] { KeyConstants._web, KeyConstants._uri, START_TIME, KeyConstants._timeout }, 0, "requests");
sct.setEL(KeyConstants._requests, req);
// Template Cache
Query tc = new QueryImpl(new Collection.Key[] { KeyConstants._web, ELEMENTS, KeyConstants._size }, 0, "templateCache");
sct.setEL(KeyImpl.init("templateCache"), tc);
// Scopes
Struct scopes = new StructImpl();
sct.setEL(KeyConstants._scopes, scopes);
Query app = new QueryImpl(new Collection.Key[] { KeyConstants._web, KeyConstants._application, ELEMENTS, KeyConstants._size }, 0, "templateCache");
scopes.setEL(KeyConstants._application, app);
Query sess = new QueryImpl(new Collection.Key[] { KeyConstants._web, KeyConstants._application, USERS, ELEMENTS, KeyConstants._size }, 0, "templateCache");
scopes.setEL(KeyConstants._session, sess);
// Query
Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._web, KeyConstants._application, START_TIME, KeyConstants._sql }, 0, "requests");
sct.setEL(QUERIES, qry);
// Locks
Query lck = new QueryImpl(new Collection.Key[] { KeyConstants._web, KeyConstants._application, KeyConstants._name, START_TIME, KeyConstants._timeout, KeyConstants._type }, 0, "requests");
sct.setEL(LOCKS, lck);
// Loop webs
ConfigWebImpl web;
Map<Integer, PageContextImpl> pcs;
PageContextImpl _pc;
int row, openConnections = 0;
CFMLFactoryImpl factory;
ActiveQuery[] queries;
ActiveQuery aq;
ActiveLock[] locks;
ActiveLock al;
for (int i = 0; i < webs.length; i++) {
// Loop requests
web = (ConfigWebImpl) webs[i];
factory = (CFMLFactoryImpl) web.getFactory();
pcs = factory.getActivePageContexts();
Iterator<PageContextImpl> it = pcs.values().iterator();
while (it.hasNext()) {
_pc = it.next();
if (_pc.isGatewayContext())
continue;
// Request
row = req.addRow();
req.setAt(KeyConstants._web, row, web.getLabel());
req.setAt(KeyConstants._uri, row, getPath(_pc.getHttpServletRequest()));
req.setAt(START_TIME, row, new DateTimeImpl(pc.getStartTime(), false));
req.setAt(KeyConstants._timeout, row, new Double(pc.getRequestTimeout()));
// Query
queries = _pc.getActiveQueries();
if (queries != null) {
for (int y = 0; y < queries.length; y++) {
aq = queries[y];
row = qry.addRow();
qry.setAt(KeyConstants._web, row, web.getLabel());
qry.setAt(KeyConstants._application, row, _pc.getApplicationContext().getName());
qry.setAt(START_TIME, row, new DateTimeImpl(web, aq.startTime, true));
qry.setAt(KeyConstants._sql, row, aq.sql);
}
}
// Lock
locks = _pc.getActiveLocks();
if (locks != null) {
for (int y = 0; y < locks.length; y++) {
al = locks[y];
row = lck.addRow();
lck.setAt(KeyConstants._web, row, web.getLabel());
lck.setAt(KeyConstants._application, row, _pc.getApplicationContext().getName());
lck.setAt(KeyConstants._name, row, al.name);
lck.setAt(START_TIME, row, new DateTimeImpl(web, al.startTime, true));
lck.setAt(KeyConstants._timeout, row, Caster.toDouble(al.timeoutInMillis / 1000));
lck.setAt(KeyConstants._type, row, al.type == LockManager.TYPE_EXCLUSIVE ? "exclusive" : "readonly");
}
}
}
Iterator<Integer> _it = web.getDatasourceConnectionPool().openConnections().values().iterator();
while (_it.hasNext()) {
openConnections += _it.next().intValue();
}
// Template Cache
Mapping[] mappings = ConfigWebUtil.getAllMappings(web);
long[] tce = templateCacheElements(mappings);
row = tc.addRow();
tc.setAt(KeyConstants._web, row, web.getLabel());
tc.setAt(KeyConstants._size, row, new Double(tce[1]));
tc.setAt(ELEMENTS, row, new Double(tce[0]));
// Scope Application
getAllApplicationScopes(web, factory.getScopeContext(), app);
getAllCFSessionScopes(web, factory.getScopeContext(), sess);
}
// Datasource
Struct ds = new StructImpl();
sct.setEL(KeyConstants._datasources, ds);
// there is only one cache for all contexts
ds.setEL(CACHED_QUERIES, Caster.toDouble(pc.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_QUERY, null).size(pc)));
// ds.setEL(CACHED_QUERIES, Caster.toDouble(pc.getQueryCache().size(pc))); // there is only one cache for all contexts
ds.setEL(OPEN_CONNECTIONS, Caster.toDouble(openConnections));
// Memory
Struct mem = new StructImpl();
sct.setEL(KeyConstants._memory, mem);
mem.setEL("heap", SystemUtil.getMemoryUsageAsStruct(SystemUtil.MEMORY_TYPE_HEAP));
mem.setEL("nonheap", SystemUtil.getMemoryUsageAsStruct(SystemUtil.MEMORY_TYPE_NON_HEAP));
// uptime
sct.set("uptime", new DateTimeImpl(engine.uptime(), true));
// now
sct.set("now", new DateTimeImpl(pc));
return sct;
}
Aggregations