use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class ModernAppListener method onSessionEnd.
@Override
public void onSessionEnd(CFMLFactory factory, String applicationName, String cfid) throws PageException {
Component app = apps.get(applicationName);
if (app == null || !app.containsKey(ON_SESSION_END))
return;
PageContextImpl pc = null;
try {
pc = createPageContext(factory, app, applicationName, cfid, ON_SESSION_END, true, -1);
call(app, pc, ON_SESSION_END, new Object[] { pc.sessionScope(false), pc.applicationScope() }, true);
} finally {
if (pc != null) {
factory.releaseLuceePageContext(pc, true);
}
}
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class CreateDynamicProxy method _call.
public static Object _call(PageContext pc, Object oCFC, Object oInterfaces) throws PageException, IOException {
if (SystemUtil.getLoaderVersion() < 5.9D)
throw new ApplicationException("You need to update your lucee.jar to execute the function [createDynamicProxy], you can download the latest jar from http://download.lucee.org.");
// Component
Component cfc;
if (oCFC instanceof Component)
cfc = (Component) oCFC;
else
cfc = pc.loadComponent(Caster.toString(oCFC));
// string list to array
if (Decision.isString(oInterfaces)) {
String list = Caster.toString(oInterfaces);
oInterfaces = ListUtil.listToStringArray(list, ',');
}
Class[] interfaces = null;
if (Decision.isArray(oInterfaces)) {
Object[] arr = Caster.toNativeArray(oInterfaces);
ClassLoader cl = ((PageContextImpl) pc).getClassLoader();
interfaces = new Class[arr.length];
for (int i = 0; i < arr.length; i++) {
if (arr[i] instanceof JavaObject)
interfaces[i] = ((JavaObject) arr[i]).getClazz();
else
interfaces[i] = ClassUtil.loadClass(cl, Caster.toString(arr[i]));
}
// strInterfaces=ListUtil.toStringArray(Caster.toArray(oInterfaces));
} else if (oInterfaces instanceof JavaObject) {
interfaces = new Class[] { ((JavaObject) oInterfaces).getClazz() };
} else
throw new FunctionException(pc, "CreateDynamicProxy", 2, "interfaces", "invalid type [" + Caster.toClassName(oInterfaces) + "] for class defintion");
// check if all classes are interfaces
for (int i = 0; i < interfaces.length; i++) {
if (!interfaces[i].isInterface())
throw new FunctionException(pc, "CreateDynamicProxy", 2, "interfaces", "definition [" + interfaces[i].getClass() + "] is a class and not a interface");
}
return JavaProxyFactory.createProxy(pc, cfc, null, interfaces);
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class GetTagData method _call.
private static Struct _call(PageContext pc, String nameSpace, String strTagName, int dialect) throws PageException {
TagLib[] tlds;
tlds = ((ConfigImpl) pc.getConfig()).getTLDs(dialect);
TagLib tld = null;
TagLibTag tag = null;
for (int i = 0; i < tlds.length; i++) {
tld = tlds[i];
if (tld.getNameSpaceAndSeparator().equalsIgnoreCase(nameSpace)) {
tag = tld.getTag(strTagName.toLowerCase());
if (tag != null)
break;
}
}
if (tag == null)
throw new ExpressionException("tag [" + nameSpace + strTagName + "] is not a built in tag");
// CFML Based Function
Class clazz = null;
try {
clazz = tag.getTagClassDefinition().getClazz();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (clazz == CFTagCore.class) {
PageContextImpl pci = (PageContextImpl) pc;
boolean prior = pci.useSpecialMappings(true);
try {
return cfmlBasedTag(pc, tld, tag);
} finally {
pci.useSpecialMappings(prior);
}
}
return javaBasedTag(tld, tag);
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class ToBinary method call.
public static byte[] call(PageContext pc, Object data, String charset) throws PageException {
if (!StringUtil.isEmpty(charset)) {
charset = charset.trim().toLowerCase();
Charset cs;
if ("web".equalsIgnoreCase(charset))
cs = pc.getWebCharset();
if ("resource".equalsIgnoreCase(charset))
cs = ((PageContextImpl) pc).getResourceCharset();
else
cs = CharsetUtil.toCharset(charset);
String str = Caster.toString(data);
return str.getBytes(cs);
}
return Caster.toBinary(data);
}
use of lucee.runtime.PageContextImpl in project Lucee by lucee.
the class ValueList method toColumn.
protected static QueryColumn toColumn(PageContext pc, String strQueryColumn) throws PageException {
// if(strQueryColumn.indexOf('.')<1)
// throw new ExpressionException("invalid query column definition ["+strQueryColumn+"]");
VariableReference ref = ((PageContextImpl) pc).getVariableReference(strQueryColumn);
if (ref.getParent() instanceof Scope)
throw new ExpressionException("invalid query column definition [" + strQueryColumn + "]");
Query query = Caster.toQuery(ref.getParent());
return query.getColumn(ref.getKey());
}
Aggregations