use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class Admin method doGetComponent.
/**
* @throws PageException
* @throws PageException
*/
private void doGetComponent() throws PageException {
Struct sct = new StructImpl();
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
// Base Component
try {
PageSource psCFML = config.getBaseComponentPageSource(CFMLEngine.DIALECT_CFML);
if (psCFML != null && psCFML.exists())
sct.set("baseComponentTemplateCFML", psCFML.getDisplayPath());
else
sct.set("baseComponentTemplateCFML", "");
} catch (PageException e) {
sct.set("baseComponentTemplateCFML", "");
}
try {
PageSource psLucee = config.getBaseComponentPageSource(CFMLEngine.DIALECT_LUCEE);
if (psLucee != null && psLucee.exists())
sct.set("baseComponentTemplateLucee", psLucee.getDisplayPath());
else
sct.set("baseComponentTemplateLucee", "");
} catch (PageException e) {
sct.set("baseComponentTemplateLucee", "");
}
sct.set("strBaseComponentTemplateCFML", config.getBaseComponentTemplate(CFMLEngine.DIALECT_CFML));
sct.set("strBaseComponentTemplateLucee", config.getBaseComponentTemplate(CFMLEngine.DIALECT_LUCEE));
// dump template
try {
PageSource ps = ((PageContextImpl) pageContext).getPageSourceExisting(config.getComponentDumpTemplate());
if (ps != null)
sct.set("componentDumpTemplate", ps.getDisplayPath());
else
sct.set("componentDumpTemplate", "");
} catch (PageException e) {
sct.set("componentDumpTemplate", "");
}
sct.set("strComponentDumpTemplate", config.getComponentDumpTemplate());
sct.set("deepSearch", Caster.toBoolean(config.doComponentDeepSearch()));
sct.set("componentDataMemberDefaultAccess", ComponentUtil.toStringAccess(config.getComponentDataMemberDefaultAccess()));
sct.set("triggerDataMember", Caster.toBoolean(config.getTriggerComponentDataMember()));
sct.set("useShadow", Caster.toBoolean(config.useComponentShadow()));
sct.set("ComponentDefaultImport", config.getComponentDefaultImport());
sct.set("componentLocalSearch", config.getComponentLocalSearch());
sct.set("componentPathCache", config.useComponentPathCache());
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class UDFImpl method _callCachedWithin.
private Object _callCachedWithin(PageContext pc, Collection.Key calledName, Object[] args, Struct values, boolean doIncludePath) throws PageException {
PageContextImpl pci = (PageContextImpl) pc;
Object cachedWithin = getCachedWithin(pc);
String cacheId = CacheHandlerCollectionImpl.createId(this, args, values);
CacheHandler cacheHandler = pc.getConfig().getCacheHandlerCollection(Config.CACHE_TYPE_FUNCTION, null).getInstanceMatchingObject(getCachedWithin(pc), null);
if (cacheHandler instanceof CacheHandlerPro) {
CacheItem cacheItem = ((CacheHandlerPro) cacheHandler).get(pc, cacheId, cachedWithin);
if (cacheItem instanceof UDFCacheItem) {
UDFCacheItem entry = (UDFCacheItem) cacheItem;
try {
pc.write(entry.output);
} catch (IOException e) {
throw Caster.toPageException(e);
}
return entry.returnValue;
}
} else if (cacheHandler != null) {
// TODO this else block can be removed when all cache handlers implement CacheHandlerPro
CacheItem cacheItem = cacheHandler.get(pc, cacheId);
if (cacheItem instanceof UDFCacheItem) {
UDFCacheItem entry = (UDFCacheItem) cacheItem;
// if(entry.creationdate+properties.cachedWithin>=System.currentTimeMillis()) {
try {
pc.write(entry.output);
} catch (IOException e) {
throw Caster.toPageException(e);
}
return entry.returnValue;
// }
// cache.remove(id);
}
}
// cached item not found, process and cache result if needed
long start = System.nanoTime();
// execute the function
BodyContent bc = pci.pushBody();
try {
Object rtn = _call(pci, calledName, args, values, doIncludePath);
if (cacheHandler != null) {
String out = bc.getString();
cacheHandler.set(pc, cacheId, cachedWithin, new UDFCacheItem(out, rtn, getFunctionName(), getSource(), System.nanoTime() - start));
}
return rtn;
} finally {
BodyContentUtil.flushAndPop(pc, bc);
}
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class UDFPropertiesImpl method readExternal.
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
try {
PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
ConfigWebImpl cw = (ConfigWebImpl) ThreadLocalPageContext.getConfig(pc);
String path = ExternalizableUtil.readString(in);
ps = PageSourceImpl.best(cw.getPageSources(pc, null, path, false, true, true));
} catch (Exception e) {
throw ExceptionUtil.toIOException(e);
}
startLine = in.readInt();
endLine = in.readInt();
arguments = (FunctionArgument[]) in.readObject();
access = in.readInt();
index = in.readInt();
returnFormat = in.readInt();
returnType = in.readInt();
description = ExternalizableUtil.readString(in);
displayName = ExternalizableUtil.readString(in);
functionName = ExternalizableUtil.readString(in);
hint = ExternalizableUtil.readString(in);
meta = (Struct) in.readObject();
output = in.readBoolean();
bufferOutput = ExternalizableUtil.readBoolean(in);
secureJson = ExternalizableUtil.readBoolean(in);
strReturnFormat = ExternalizableUtil.readString(in);
strReturnType = ExternalizableUtil.readString(in);
verifyClient = ExternalizableUtil.readBoolean(in);
cachedWithin = ExternalizableUtil.readString(in);
int tmp = in.readInt();
localMode = tmp == -1 ? null : tmp;
if (arguments != null && arguments.length > 0) {
this.argumentsSet = new HashSet<Collection.Key>();
for (int i = 0; i < arguments.length; i++) {
argumentsSet.add(arguments[i].getName());
}
}
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class FDControllerImpl method pause.
private void pause(String name, CFMLFactoryImpl factory, List<IFDThread> threads) {
Map<Integer, PageContextImpl> pcs = factory.getActivePageContexts();
Iterator<PageContextImpl> it = pcs.values().iterator();
PageContextImpl pc;
while (it.hasNext()) {
pc = it.next();
try {
pc.getThread().wait();
} catch (InterruptedException e) {
SystemOut.printDate(e);
}
threads.add(new FDThreadImpl(this, factory, name, pc));
}
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class FDSignal method createExceptionStack.
public static List createExceptionStack(PageException pe) {
StackTraceElement[] traces = pe.getStackTrace();
PageContextImpl pc = (PageContextImpl) ThreadLocalPageContext.get();
String template = "";
StackTraceElement trace = null;
List list = new ArrayList();
Resource res;
PageSource ps;
FDStackFrameImpl frame;
for (int i = traces.length - 1; i >= 0; i--) {
trace = traces[i];
ps = null;
if (trace.getLineNumber() <= 0)
continue;
template = trace.getFileName();
if (template == null || ResourceUtil.getExtension(template, "").equals("java"))
continue;
res = ResourceUtil.toResourceNotExisting(pc, template);
ps = pc.toPageSource(res, null);
frame = new FDStackFrameImpl(null, pc, trace, ps);
if (ASMUtil.isOverfowMethod(trace.getMethodName()))
list.set(0, frame);
else
list.add(0, frame);
}
if (pe instanceof TemplateException) {
TemplateException te = (TemplateException) pe;
if (te.getPageSource() != null)
list.add(0, new FDStackFrameImpl(null, pc, te.getPageSource(), te.getLine()));
}
return list;
}
Aggregations