use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class TagUtil method addTagMetaData.
private static void addTagMetaData(PageContext pc, TagLib tl, TagLibTag tlt, String filename, boolean isWeb) {
if (pc == null)
return;
try {
ConfigWebImpl config = (ConfigWebImpl) pc.getConfig();
PageSource ps = isWeb ? config.getTagMapping().getPageSource(filename) : config.getServerTagMapping().getPageSource(filename);
// Page p = ps.loadPage(pc);
ComponentImpl c = ComponentLoader.loadComponent(pc, ps, filename, true, true);
ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, c);
Struct meta = Caster.toStruct(cw.get(KeyConstants._metadata, null), null);
// TODO handle all metadata here and make checking at runtime useless
if (meta != null) {
// parse body
boolean rtexprvalue = Caster.toBooleanValue(meta.get(KeyConstants._parsebody, Boolean.FALSE), false);
tlt.setParseBody(rtexprvalue);
// hint
String hint = Caster.toString(meta.get(KeyConstants._hint, null), null);
if (!StringUtil.isEmpty(hint))
tlt.setDescription(hint);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class CFTagCore method createInitFile.
public static InitFile createInitFile(PageContext pageContext, boolean isweb, String filename) {
ConfigWebImpl config = (ConfigWebImpl) pageContext.getConfig();
Mapping mapping = isweb ? config.getTagMapping() : config.getServerTagMapping();
return new InitFile(pageContext, mapping.getPageSource(filename), filename);
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class ChildThreadImpl method execute.
public PageException execute(Config config) {
PageContext oldPc = ThreadLocalPageContext.get();
Page p = page;
PageContextImpl pc = null;
try {
// deamon
if (this.pc != null) {
pc = this.pc;
ThreadLocalPageContext.register(pc);
} else // task
{
ConfigWebImpl cwi;
try {
cwi = (ConfigWebImpl) config;
DevNullOutputStream os = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
pc = ThreadUtil.createPageContext(cwi, os, serverName, requestURI, queryString, SerializableCookie.toCookies(cookies), headers, null, parameters, attributes, true, -1);
pc.setRequestTimeout(requestTimeout);
p = PageSourceImpl.loadPage(pc, cwi.getPageSources(oldPc == null ? pc : oldPc, null, template, false, false, true));
// p=cwi.getPageSources(oldPc,null, template, false,false,true).loadPage(cwi);
} catch (PageException e) {
return e;
}
pc.addPageSource(p.getPageSource(), true);
}
threadScope = pc.getThreadScope(KeyConstants._cfthread, null);
pc.setCurrentThreadScope(new ThreadsImpl(this));
pc.setThread(Thread.currentThread());
// String encodings = pc.getHttpServletRequest().getHeader("Accept-Encoding");
Undefined undefined = pc.us();
Argument newArgs = new ArgumentThreadImpl((Struct) Duplicator.duplicate(attrs, false));
LocalImpl newLocal = pc.getScopeFactory().getLocalInstance();
// Key[] keys = attrs.keys();
Iterator<Entry<Key, Object>> it = attrs.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
newArgs.setEL(e.getKey(), e.getValue());
}
newLocal.setEL(KEY_ATTRIBUTES, newArgs);
Argument oldArgs = pc.argumentsScope();
Local oldLocal = pc.localScope();
int oldMode = undefined.setMode(Undefined.MODE_LOCAL_OR_ARGUMENTS_ALWAYS);
pc.setFunctionScopes(newLocal, newArgs);
try {
p.threadCall(pc, threadIndex);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
if (!Abort.isSilentAbort(t)) {
ConfigWeb c = pc.getConfig();
if (c instanceof ConfigImpl) {
ConfigImpl ci = (ConfigImpl) c;
Log log = ci.getLog("thread");
if (log != null)
LogUtil.log(log, Log.LEVEL_ERROR, this.getName(), t);
}
PageException pe = Caster.toPageException(t);
if (!serializable)
catchBlock = pe.getCatchBlock(pc.getConfig());
return pe;
}
} finally {
completed = true;
pc.setFunctionScopes(oldLocal, oldArgs);
undefined.setMode(oldMode);
// pc.getScopeFactory().recycle(newArgs);
pc.getScopeFactory().recycle(pc, newLocal);
if (pc.getHttpServletResponse() instanceof HttpServletResponseDummy) {
HttpServletResponseDummy rsp = (HttpServletResponseDummy) pc.getHttpServletResponse();
pc.flush();
contentType = rsp.getContentType();
Pair<String, Object>[] _headers = rsp.getHeaders();
if (_headers != null)
for (int i = 0; i < _headers.length; i++) {
if (_headers[i].getName().equalsIgnoreCase("Content-Encoding"))
contentEncoding = Caster.toString(_headers[i].getValue(), null);
}
}
}
} finally {
pc.getConfig().getFactory().releaseLuceePageContext(pc, true);
pc = null;
if (oldPc != null)
ThreadLocalPageContext.register(oldPc);
}
return null;
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class Admin method doStopThread.
private void doStopThread() throws PageException {
String contextId = getString("admin", "stopThread", "contextId");
String threadId = getString("admin", "stopThread", "threadId");
String stopType = getString("stopType", "exception");
if (!(config instanceof ConfigServer))
throw new ApplicationException("invalid context for this action");
ConfigServer cs = (ConfigServer) config;
ConfigWeb[] webs = cs.getConfigWebs();
boolean has = false;
for (int i = 0; i < webs.length; i++) {
ConfigWebImpl cw = (ConfigWebImpl) webs[i];
if (!cw.getIdentification().getId().equals(contextId))
continue;
((CFMLFactoryImpl) cw.getFactory()).stopThread(threadId, stopType);
has = true;
break;
}
if (!has) {
for (int i = 0; i < webs.length; i++) {
ConfigWebImpl cw = (ConfigWebImpl) webs[i];
if (!contextId.equals(cw.getLabel()))
continue;
((CFMLFactoryImpl) cw.getFactory()).stopThread(threadId, stopType);
has = true;
break;
}
}
}
use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.
the class WDDXConverter method _serializeQuery.
/**
* serialize a Query
*
* @param query
* Query to serialize
* @param done
* @return serialized query
* @throws ConverterException
*/
private String _serializeQuery(Query query, Set<Object> done) throws ConverterException {
// fieldnames
PageContext pc = ThreadLocalPageContext.get();
boolean upperCase = false;
if (pc != null)
upperCase = pc.getCurrentTemplateDialect() == CFMLEngine.DIALECT_CFML && !((ConfigWebImpl) pc.getConfig()).preserveCase();
StringBuilder fn = new StringBuilder();
Collection.Key[] keys = CollectionUtil.keys(query);
for (int i = 0; i < keys.length; i++) {
if (i > 0)
fn.append(',');
fn.append(XMLUtil.escapeXMLString(upperCase ? keys[i].getUpperString() : keys[i].getString()));
}
StringBuilder sb = new StringBuilder(goIn() + "<recordset rowCount=" + del + query.getRecordcount() + del + " fieldNames=" + del + fn + del + " type=" + del + "coldfusion.sql.QueryTable" + del + ">");
deep++;
int len = query.getRecordcount();
for (int i = 0; i < keys.length; i++) {
sb.append(goIn() + "<field name=" + del + XMLUtil.escapeXMLString(keys[i].getString()) + del + ">");
for (int y = 1; y <= len; y++) {
try {
sb.append(_serialize(query.getAt(keys[i], y), done));
} catch (PageException e) {
sb.append(_serialize(e.getMessage(), done));
}
}
sb.append(goIn() + "</field>");
}
deep--;
sb.append(goIn() + "</recordset>");
return sb.toString();
}
Aggregations