Search in sources :

Example 1 with BIFProxy

use of lucee.runtime.functions.BIFProxy in project Lucee by lucee.

the class TagUtil method invokeBIF.

/**
 * used by the bytecode builded
 * @param pc pageContext
 * @param className
 * @param bundleName
 * @param bundleVersion
 * @return
 * @throws BundleException
 * @throws ClassException
 */
public static Object invokeBIF(PageContext pc, Object[] args, String className, String bundleName, String bundleVersion) throws PageException {
    try {
        Class<?> clazz = ClassUtil.loadClassByBundle(className, bundleName, bundleVersion, pc.getConfig().getIdentification());
        BIF bif;
        if (Reflector.isInstaneOf(clazz, BIF.class))
            bif = (BIF) clazz.newInstance();
        else
            bif = new BIFProxy(clazz);
        return bif.invoke(pc, args);
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
}
Also used : BIFProxy(lucee.runtime.functions.BIFProxy) BIF(lucee.runtime.ext.function.BIF) ClassException(lucee.commons.lang.ClassException) PageException(lucee.runtime.exp.PageException) BundleException(org.osgi.framework.BundleException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 2 with BIFProxy

use of lucee.runtime.functions.BIFProxy in project Lucee by lucee.

the class ClassUtilImpl method loadBIF.

@Override
public BIF loadBIF(PageContext pc, String name) throws InstantiationException, IllegalAccessException {
    // first of all we chek if itis a class
    Class<?> res = lucee.commons.lang.ClassUtil.loadClass(name, null);
    if (res != null) {
        if (Reflector.isInstaneOf(res, BIF.class)) {
            return (BIF) res.newInstance();
        }
        return new BIFProxy(res);
    }
    FunctionLib[] flds = ((ConfigWebImpl) pc.getConfig()).getFLDs(pc.getCurrentTemplateDialect());
    FunctionLibFunction flf;
    for (int i = 0; i < flds.length; i++) {
        flf = flds[i].getFunction(name);
        if (flf != null)
            return flf.getBIF();
    }
    return null;
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) FunctionLibFunction(lucee.transformer.library.function.FunctionLibFunction) FunctionLib(lucee.transformer.library.function.FunctionLib) BIFProxy(lucee.runtime.functions.BIFProxy) BIF(lucee.runtime.ext.function.BIF)

Aggregations

BIF (lucee.runtime.ext.function.BIF)2 BIFProxy (lucee.runtime.functions.BIFProxy)2 ClassException (lucee.commons.lang.ClassException)1 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 PageException (lucee.runtime.exp.PageException)1 FunctionLib (lucee.transformer.library.function.FunctionLib)1 FunctionLibFunction (lucee.transformer.library.function.FunctionLibFunction)1 BundleException (org.osgi.framework.BundleException)1