use of lucee.runtime.PageContext 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();
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class ThreadLocalPageContext method getTimeZone.
public static TimeZone getTimeZone(Config config) {
PageContext pc = get();
if (pc != null && pc.getTimeZone() != null)
return pc.getTimeZone();
config = getConfig(config);
if (config != null && config.getTimeZone() != null) {
return config.getTimeZone();
}
return DEFAULT_TIMEZONE;
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class ScopeContext method clear.
/**
* remove all scope objects
*/
public void clear() {
try {
Scope scope;
// Map.Entry entry,e;
// Map context;
// release all session scopes
Iterator<Entry<String, Map<String, Scope>>> sit = cfSessionContexts.entrySet().iterator();
Entry<String, Map<String, Scope>> sentry;
Map<String, Scope> context;
Iterator<Entry<String, Scope>> itt;
Entry<String, Scope> e;
PageContext pc = ThreadLocalPageContext.get();
while (sit.hasNext()) {
sentry = sit.next();
context = sentry.getValue();
itt = context.entrySet().iterator();
while (itt.hasNext()) {
e = itt.next();
scope = e.getValue();
scope.release(pc);
}
}
cfSessionContexts.clear();
// release all application scopes
Iterator<Entry<String, Application>> ait = applicationContexts.entrySet().iterator();
Entry<String, Application> aentry;
while (ait.hasNext()) {
aentry = ait.next();
scope = aentry.getValue();
scope.release(pc);
}
applicationContexts.clear();
// release server scope
if (server != null) {
server.release(pc);
server = null;
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class DevNullOutputStream method _invoke.
private Object _invoke(final String methodName, final Object[] args, HttpServletRequest req, HttpServletResponse rsp, OutputStream out) throws PageException {
final CFMLEngine engine = CFMLEngineFactory.getInstance();
final Creation creator = engine.getCreationUtil();
final PageContext originalPC = engine.getThreadPageContext();
// no OutputStream
if (out == null)
out = DevNullOutputStream.DEV_NULL_OUTPUT_STREAM;
// no Request
if (req == null)
// TODO new File
req = creator.createHttpServletRequest(new File("."), "Lucee", "/", "", null, null, null, null, null);
// noRespone
if (rsp == null)
rsp = creator.createHttpServletResponse(out);
final PageContext pc = creator.createPageContext(req, rsp, out);
try {
engine.registerThreadPageContext(pc);
initCFC(pc);
return cfc.call(pc, methodName, args);
} finally {
if (autoFlush)
try {
pc.getRootWriter().flush();
} catch (final Throwable t) {
}
engine.registerThreadPageContext(originalPC);
}
}
use of lucee.runtime.PageContext in project Lucee by lucee.
the class ScriptEngineImpl method put.
@Override
public void put(String key, Object value) {
PageContext oldPC = ThreadLocalPageContext.get();
PageContext pc = getPageContext(getContext());
try {
pc.undefinedScope().set(KeyImpl.init(key), value);
} catch (PageException e) {
// ignored
} finally {
releasePageContext(pc, oldPC);
}
}
Aggregations