use of lucee.runtime.Component 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.Component in project Lucee by lucee.
the class CreateComponent method call.
public static Component call(PageContext pc, String path, Object args) throws PageException {
// first argument is the component itself
Component c = CreateObject.doComponent(pc, path);
if (c.get(KeyConstants._init, null) instanceof UDF) {
// no arguments
if (args == null) {
c.call(pc, KeyConstants._init, EMPTY);
} else // named arguments
if (Decision.isStruct(args)) {
Struct sct = Caster.toStruct(args);
c.callWithNamedValues(pc, KeyConstants._init, sct);
} else // not named arguments
if (Decision.isArray(args)) {
Object[] arr = Caster.toNativeArray(args);
c.call(pc, KeyConstants._init, arr);
} else {
c.call(pc, KeyConstants._init, new Object[] { args });
}
}
return c;
}
use of lucee.runtime.Component 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.Component in project Lucee by lucee.
the class _GetSuperStaticScope method call.
public static Struct call(PageContext pc) throws PageException {
Component cfc = pc.getActiveComponent();
if (cfc == null)
throw new ApplicationException("[static::] is not supported outside a component.");
Component base = cfc.getBaseComponent();
if (base == null)
throw new ApplicationException("component [" + cfc.getCallName() + "] does not have a base component.");
return base.staticScope();
}
use of lucee.runtime.Component in project Lucee by lucee.
the class EntityNew method call.
public static Object call(PageContext pc, String name, Struct properties) throws PageException {
ORMSession session = ORMUtil.getSession(pc);
if (properties == null)
return session.create(pc, name);
Component entity = session.create(pc, name);
setPropeties(pc, entity, properties, false);
return entity;
}
Aggregations