Search in sources :

Example 31 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class AppListenerUtil method setORMConfiguration.

public static void setORMConfiguration(PageContext pc, ApplicationContext ac, Struct sct) throws PageException {
    if (sct == null)
        sct = new StructImpl();
    ConfigImpl config = (ConfigImpl) pc.getConfig();
    PageSource curr = pc.getCurrentTemplatePageSource();
    Resource res = curr == null ? null : curr.getResourceTranslated(pc).getParentResource();
    ac.setORMConfiguration(ORMConfigurationImpl.load(config, ac, sct, res, config.getORMConfig()));
    // datasource
    Object o = sct.get(KeyConstants._datasource, null);
    if (o != null) {
        o = toDefaultDatasource(config, o, LogUtil.getLog(pc, "application"));
        if (o != null)
            ac.setORMDataSource(o);
    }
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Resource(lucee.commons.io.res.Resource) ConfigImpl(lucee.runtime.config.ConfigImpl) PageSource(lucee.runtime.PageSource)

Example 32 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class ClassicAppListener method onRequest.

@Override
public void onRequest(PageContext pc, PageSource requestedPage, RequestListener rl) throws PageException {
    PageSource application = AppListenerUtil.getApplicationPageSource(pc, requestedPage, Constants.CFML_CLASSIC_APPLICATION_EVENT_HANDLER, mode);
    _onRequest(pc, requestedPage, application, rl);
}
Also used : PageSource(lucee.runtime.PageSource)

Example 33 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class MixedAppListener method onRequest.

@Override
public void onRequest(PageContext pc, PageSource requestedPage, RequestListener rl) throws PageException {
    RefBoolean isCFC = new RefBooleanImpl(false);
    PageSource appPS = getApplicationPageSource(pc, requestedPage, mode, isCFC);
    if (isCFC.toBooleanValue())
        _onRequest(pc, requestedPage, appPS, rl);
    else
        ClassicAppListener._onRequest(pc, requestedPage, appPS, rl);
}
Also used : RefBoolean(lucee.commons.lang.types.RefBoolean) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl) PageSource(lucee.runtime.PageSource)

Example 34 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class MixedAppListener method getApplicationPageSourceRoot.

private static PageSource getApplicationPageSourceRoot(PageContext pc, RefBoolean isCFC) {
    PageSource ps = ((PageContextImpl) pc).getPageSourceExisting("/" + Constants.CFML_APPLICATION_EVENT_HANDLER);
    if (ps != null) {
        isCFC.setValue(true);
        return ps;
    }
    ps = ((PageContextImpl) pc).getPageSourceExisting("/" + Constants.CFML_CLASSIC_APPLICATION_EVENT_HANDLER);
    if (ps != null)
        return ps;
    return null;
}
Also used : PageContextImpl(lucee.runtime.PageContextImpl) PageSource(lucee.runtime.PageSource)

Example 35 with PageSource

use of lucee.runtime.PageSource in project Lucee by lucee.

the class CFImportTag method initFile.

@Override
public void initFile() throws PageException {
    ConfigWeb config = pageContext.getConfig();
    // = appendix+'.'+config.getCFMLExtension();
    String[] filenames = CustomTagUtil.getFileNames(config, getAppendix());
    String strRealPathes = attributesScope.remove("__custom_tag_path").toString();
    String[] realPathes = ListUtil.listToStringArray(strRealPathes, File.pathSeparatorChar);
    for (int i = 0; i < realPathes.length; i++) {
        if (!StringUtil.endsWith(realPathes[i], '/'))
            realPathes[i] = realPathes[i] + "/";
    }
    // MUSTMUST use cache like regular ct
    // page source
    PageSource ps;
    for (int rp = 0; rp < realPathes.length; rp++) {
        for (int fn = 0; fn < filenames.length; fn++) {
            ps = ((PageContextImpl) pageContext).getRelativePageSourceExisting(realPathes[rp] + filenames[fn]);
            if (ps != null) {
                source = new InitFile(pageContext, ps, filenames[fn]);
                return;
            }
        }
    }
    // EXCEPTION
    // message
    StringBuffer msg = new StringBuffer("could not find template [");
    msg.append(CustomTagUtil.getDisplayName(config, getAppendix()));
    msg.append("] in the following directories [");
    msg.append(strRealPathes.replace(File.pathSeparatorChar, ','));
    msg.append(']');
    throw new ExpressionException(msg.toString());
}
Also used : InitFile(lucee.runtime.customtag.InitFile) ConfigWeb(lucee.runtime.config.ConfigWeb) ExpressionException(lucee.runtime.exp.ExpressionException) PageSource(lucee.runtime.PageSource)

Aggregations

PageSource (lucee.runtime.PageSource)59 PageContextImpl (lucee.runtime.PageContextImpl)19 Resource (lucee.commons.io.res.Resource)16 Struct (lucee.runtime.type.Struct)10 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)8 Mapping (lucee.runtime.Mapping)7 PageException (lucee.runtime.exp.PageException)7 StructImpl (lucee.runtime.type.StructImpl)7 ConfigImpl (lucee.runtime.config.ConfigImpl)6 ConfigWeb (lucee.runtime.config.ConfigWeb)6 ExpressionException (lucee.runtime.exp.ExpressionException)6 ArrayList (java.util.ArrayList)5 Component (lucee.runtime.Component)5 PageSourceCode (lucee.transformer.util.PageSourceCode)5 IOException (java.io.IOException)4 MissingIncludeException (lucee.runtime.exp.MissingIncludeException)4 Array (lucee.runtime.type.Array)4 LitString (lucee.transformer.expression.literal.LitString)4 HTTPResource (lucee.commons.io.res.type.http.HTTPResource)3 Entry (java.util.Map.Entry)2