Search in sources :

Example 1 with FunctionLibException

use of lucee.transformer.library.function.FunctionLibException in project Lucee by lucee.

the class ConfigImpl method setFldFile.

protected void setFldFile(Resource fileFld, int dialect) throws FunctionLibException {
    if (dialect == CFMLEngine.DIALECT_BOTH) {
        setFldFile(fileFld, CFMLEngine.DIALECT_CFML);
        setFldFile(fileFld, CFMLEngine.DIALECT_LUCEE);
        return;
    }
    FunctionLib[] flds = dialect == CFMLEngine.DIALECT_CFML ? cfmlFlds : luceeFlds;
    // merge all together (backward compatibility)
    if (flds.length > 1)
        for (int i = 1; i < flds.length; i++) {
            overwrite(flds[0], flds[i]);
        }
    flds = new FunctionLib[] { flds[0] };
    if (dialect == CFMLEngine.DIALECT_CFML) {
        cfmlFlds = flds;
        // TODO improve check
        if (cfmlFlds != flds)
            combinedCFMLFLDs = null;
    } else {
        luceeFlds = flds;
        // TODO improve check
        if (luceeFlds != flds)
            combinedLuceeFLDs = null;
    }
    if (fileFld == null)
        return;
    this.fldFile = fileFld;
    // overwrite with addional functions
    FunctionLib fl;
    if (fileFld.isDirectory()) {
        Resource[] files = fileFld.listResources(new ExtensionResourceFilter(new String[] { "fld", "fldx" }));
        for (int i = 0; i < files.length; i++) {
            try {
                fl = FunctionLibFactory.loadFromFile(files[i], getIdentification());
                overwrite(flds[0], fl);
            } catch (FunctionLibException fle) {
                SystemOut.printDate(out, "can't load fld " + files[i]);
                fle.printStackTrace(getErrWriter());
            }
        }
    } else {
        fl = FunctionLibFactory.loadFromFile(fileFld, getIdentification());
        overwrite(flds[0], fl);
    }
}
Also used : FunctionLibException(lucee.transformer.library.function.FunctionLibException) Resource(lucee.commons.io.res.Resource) CompressResource(lucee.commons.io.res.type.compress.CompressResource) FunctionLib(lucee.transformer.library.function.FunctionLib) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter)

Aggregations

Resource (lucee.commons.io.res.Resource)1 ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)1 CompressResource (lucee.commons.io.res.type.compress.CompressResource)1 FunctionLib (lucee.transformer.library.function.FunctionLib)1 FunctionLibException (lucee.transformer.library.function.FunctionLibException)1