use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class QueryExecute method call.
// name is set by evaluator
public static Object call(PageContext pc, String sql, Object params, Struct options, String name) throws PageException {
PageContextImpl pci = (PageContextImpl) pc;
lucee.runtime.tag.Query qry = (lucee.runtime.tag.Query) pci.use(lucee.runtime.tag.Query.class.getName(), "cfquery", TagLibTag.ATTRIBUTE_TYPE_FIXED);
try {
try {
// set attributes
qry.setReturnVariable(true);
qry.setName(StringUtil.isEmpty(name) ? "QueryExecute" : name);
if (options != null)
TagUtil.setAttributeCollection(pc, qry, null, options, TagLibTag.ATTRIBUTE_TYPE_FIXED);
qry.setParams(params);
int res = qry.doStartTag();
pc.initBody(qry, res);
pc.forceWrite(sql);
qry.doAfterBody();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
try {
qry.doCatch(t);
} catch (Throwable t2) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t2);
}
} finally {
pc.popBody();
qry.doFinally();
}
qry.doEndTag();
return qry.getReturnVariable();
} finally {
pci.reuse(qry);
}
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class ResourceLockImpl method _read.
private void _read(String path) {
long start = -1, now;
Thread t;
do {
if ((t = resources.get(path)) == null) {
// print.ln("read ok");
return;
}
if (t == Thread.currentThread()) {
// aprint.err(path);
Config config = ThreadLocalPageContext.getConfig();
if (config != null)
SystemOut.printDate(config.getErrWriter(), "conflict in same thread: on " + path);
// SystemOut.printDate(config.getErrWriter(),"conflict in same thread: on "+path+"\nStacktrace:\n"+StringUtil.replace(ExceptionUtil.getStacktrace(new Throwable(), false),"java.lang.Throwable\n","",true));
return;
}
// bugfix when lock von totem thread, wird es ignoriert
if (!t.isAlive()) {
resources.remove(path);
return;
}
if (start == -1)
start = System.currentTimeMillis();
try {
token.wait(lockTimeout);
now = System.currentTimeMillis();
if ((start + lockTimeout) <= now) {
Config config = ThreadLocalPageContext.getConfig();
if (config != null) {
PageContextImpl pc = null;
String add = "";
if (config instanceof ConfigWeb) {
CFMLFactory factory = ((ConfigWeb) config).getFactory();
if (factory instanceof CFMLFactoryImpl) {
Map<Integer, PageContextImpl> pcs = ((CFMLFactoryImpl) factory).getActivePageContexts();
Iterator<PageContextImpl> it = pcs.values().iterator();
PageContextImpl tmp;
while (it.hasNext()) {
tmp = it.next();
if (t == tmp.getThread()) {
pc = tmp;
break;
}
}
}
}
if (pc != null) {
add = " The file is locked by a request on the following URL " + ReqRspUtil.getRequestURL(pc.getHttpServletRequest(), true) + ", that request started " + (System.currentTimeMillis() - pc.getStartTime()) + "ms ago.";
}
SystemOut.printDate(config.getErrWriter(), "timeout after " + (now - start) + " ms (" + (lockTimeout) + " ms) occured while accessing file [" + path + "]." + add);
} else
SystemOut.printDate("timeout (" + (lockTimeout) + " ms) occured while accessing file [" + path + "].");
return;
}
} catch (InterruptedException e) {
}
} while (true);
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class LocaleCalendarThreadLocal method toString.
@Override
public String toString(PageContext pc, DateTime dt, TimeZone tz, Boolean addTimeZoneOffset) {
Calendar c = _getThreadCalendar(pc, tz);
c.setTimeInMillis(dt.getTime());
// "HH:mm:ss"
StringBuilder sb = new StringBuilder();
sb.append("{ts '");
toString(sb, c.get(Calendar.YEAR), 4);
sb.append("-");
toString(sb, c.get(Calendar.MONTH) + 1, 2);
sb.append("-");
toString(sb, c.get(Calendar.DATE), 2);
sb.append(" ");
toString(sb, c.get(Calendar.HOUR_OF_DAY), 2);
sb.append(":");
toString(sb, c.get(Calendar.MINUTE), 2);
sb.append(":");
toString(sb, c.get(Calendar.SECOND), 2);
if (addTimeZoneOffset != Boolean.FALSE) {
if (addTimeZoneOffset == null && pc != null)
addTimeZoneOffset = ((PageContextImpl) pc).getTimestampWithTSOffset();
if (addTimeZoneOffset == Boolean.TRUE)
addTimeZoneOffset(c, sb);
}
sb.append("'}");
return sb.toString();
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class MacAddressWrap method run.
public void run() {
PageContextImpl pci = (PageContextImpl) pc;
Thread thread = pc.getThread();
if (thread == null)
return;
if (thread.isAlive()) {
pci.setTimeoutStackTrace();
thread.stop();
}
}
Aggregations