Search in sources :

Example 11 with Component

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

the class DebugEntryTemplatePartComparator method writeOut.

@Override
public void writeOut(PageContext pc) throws IOException {
    // stop();
    if (!output)
        return;
    String addr = pc.getHttpServletRequest().getRemoteAddr();
    lucee.runtime.config.DebugEntry debugEntry = ((ConfigImpl) pc.getConfig()).getDebugEntry(addr, null);
    if (debugEntry == null) {
        // pc.forceWrite(pc.getConfig().getDefaultDumpWriter().toString(pc,toDumpData(pc, 9999,DumpUtil.toDumpProperties()),true));
        return;
    }
    Struct args = new StructImpl();
    args.setEL(KeyConstants._custom, debugEntry.getCustom());
    try {
        args.setEL(KeyConstants._debugging, pc.getDebugger().getDebuggingData(pc));
    } catch (PageException e1) {
    }
    try {
        String path = debugEntry.getPath();
        PageSource[] arr = ((PageContextImpl) pc).getPageSources(path);
        Page p = PageSourceImpl.loadPage(pc, arr, null);
        // patch for old path
        String fullname = debugEntry.getFullname();
        if (p == null) {
            if (path != null) {
                boolean changed = false;
                if (path.endsWith("/Modern.cfc") || path.endsWith("\\Modern.cfc")) {
                    path = "/lucee-server-context/admin/debug/Modern.cfc";
                    fullname = "lucee-server-context.admin.debug.Modern";
                    changed = true;
                } else if (path.endsWith("/Classic.cfc") || path.endsWith("\\Classic.cfc")) {
                    path = "/lucee-server-context/admin/debug/Classic.cfc";
                    fullname = "lucee-server-context.admin.debug.Classic";
                    changed = true;
                } else if (path.endsWith("/Comment.cfc") || path.endsWith("\\Comment.cfc")) {
                    path = "/lucee-server-context/admin/debug/Comment.cfc";
                    fullname = "lucee-server-context.admin.debug.Comment";
                    changed = true;
                }
                if (changed)
                    pc.write("<span style='color:red'>Please update your debug template defintions in the Lucee admin by going into the detail view and hit the \"update\" button.</span>");
            }
            arr = ((PageContextImpl) pc).getPageSources(path);
            p = PageSourceImpl.loadPage(pc, arr);
        }
        pc.addPageSource(p.getPageSource(), true);
        try {
            Component c = pc.loadComponent(fullname);
            c.callWithNamedValues(pc, "output", args);
        } finally {
            pc.removeLastPageSource(true);
        }
    } catch (PageException e) {
        pc.handlePageException(e);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) Page(lucee.runtime.Page) PageContextImpl(lucee.runtime.PageContextImpl) Struct(lucee.runtime.type.Struct) PageSource(lucee.runtime.PageSource) StructImpl(lucee.runtime.type.StructImpl) Component(lucee.runtime.Component) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 12 with Component

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

the class ComponentLoader method _search.

private static Object _search(PageContext pc, PageSource loadingLocation, String rawPath, Boolean searchLocal, Boolean searchRoot, boolean executeConstr, short returnType, final boolean isExtendedComponent) throws PageException {
    PageSource currPS = pc.getCurrentPageSource(null);
    ImportDefintion[] importDefintions = null;
    if (currPS != null) {
        Page currP;
        Component cfc = pc.getActiveComponent();
        if (cfc instanceof ComponentImpl && currPS.equals(cfc.getPageSource())) {
            importDefintions = ((ComponentImpl) cfc)._getImportDefintions();
        } else if ((currP = currPS.loadPage(pc, false, null)) != null) {
            importDefintions = currP.getImportDefintions();
        }
    }
    int dialect = currPS == null ? pc.getCurrentTemplateDialect() : currPS.getDialect();
    // first try for the current dialect
    Object obj = _search(pc, loadingLocation, rawPath, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect, isExtendedComponent);
    // then we try the opposite dialect
    if (obj == null && ((ConfigImpl) pc.getConfig()).allowLuceeDialect()) {
        // only when the lucee dialect is enabled we have to check the opposite
        obj = _search(pc, loadingLocation, rawPath, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect == CFMLEngine.DIALECT_CFML ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML, isExtendedComponent);
    }
    if (obj == null)
        throw new ExpressionException("invalid " + toStringType(returnType, dialect) + " definition, can't find " + toStringType(returnType, dialect) + " [" + rawPath + "]");
    return obj;
}
Also used : Page(lucee.runtime.Page) CIPage(lucee.runtime.CIPage) CIObject(lucee.runtime.CIObject) Component(lucee.runtime.Component) ComponentImpl(lucee.runtime.ComponentImpl) ExpressionException(lucee.runtime.exp.ExpressionException) PageSource(lucee.runtime.PageSource)

Example 13 with Component

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

the class ComponentLoader method _search.

private static Object _search(PageContext pc, PageSource loadingLocation, String rawPath, Boolean searchLocal, Boolean searchRoot, boolean executeConstr, short returnType, PageSource currPS, ImportDefintion[] importDefintions, int dialect, final boolean isExtendedComponent) throws PageException {
    ConfigImpl config = (ConfigImpl) pc.getConfig();
    if (dialect == CFMLEngine.DIALECT_LUCEE && !config.allowLuceeDialect())
        PageContextImpl.notSupported();
    boolean doCache = config.useComponentPathCache();
    String sub = null;
    if (returnType != RETURN_TYPE_PAGE && rawPath.indexOf(':') != -1) {
        int d = rawPath.indexOf(':');
        int s = rawPath.indexOf('.');
        if (d > s) {
            sub = rawPath.substring(d + 1);
            rawPath = rawPath.substring(0, d);
        }
    }
    // app-String appName=pc.getApplicationContext().getName();
    rawPath = rawPath.trim().replace('\\', '/');
    String path = (rawPath.indexOf("./") == -1) ? rawPath.replace('.', '/') : rawPath;
    boolean isRealPath = !StringUtil.startsWith(path, '/');
    // PageSource currPS = pc.getCurrentPageSource();
    // Page currP=currPS.loadPage(pc,false);
    PageSource ps = null;
    CIPage page = null;
    // MUSTMUST improve to handle different extensions
    String pathWithCFC = path.concat("." + (dialect == CFMLEngine.DIALECT_CFML ? Constants.getCFMLComponentExtension() : Constants.getLuceeComponentExtension()));
    // no cache for per application pathes
    Mapping[] acm = pc.getApplicationContext().getComponentMappings();
    if (!ArrayUtil.isEmpty(acm)) {
        Mapping m;
        for (int y = 0; y < acm.length; y++) {
            m = acm[y];
            ps = m.getPageSource(pathWithCFC);
            page = toCIPage(ps.loadPageThrowTemplateException(pc, false, (Page) null));
            if (page != null) {
                return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
            }
        }
    }
    if (searchLocal == null)
        searchLocal = Caster.toBoolean(rawPath.indexOf('.') == -1 ? true : config.getComponentLocalSearch());
    if (searchRoot == null)
        searchRoot = Caster.toBoolean(config.getComponentRootSearch());
    // CACHE
    // check local in cache
    String localCacheName = null;
    if (searchLocal && isRealPath && currPS != null) {
        localCacheName = currPS.getDisplayPath().replace('\\', '/');
        localCacheName = localCacheName.substring(0, localCacheName.lastIndexOf('/') + 1).concat(pathWithCFC);
        if (doCache) {
            page = config.getCachedPage(pc, localCacheName);
            if (page != null)
                return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
        }
    }
    // check import cache
    if (doCache && isRealPath) {
        ImportDefintion impDef = config.getComponentDefaultImport();
        ImportDefintion[] impDefs = importDefintions == null ? EMPTY_ID : importDefintions;
        int i = -1;
        do {
            if (impDef.isWildcard() || impDef.getName().equalsIgnoreCase(path)) {
                page = config.getCachedPage(pc, "import:" + impDef.getPackageAsPath() + pathWithCFC);
                if (page != null)
                    return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
            }
            impDef = ++i < impDefs.length ? impDefs[i] : null;
        } while (impDef != null);
    }
    if (doCache) {
        // check global in cache
        page = config.getCachedPage(pc, pathWithCFC);
        if (page != null)
            return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
    }
    // search from local
    if (searchLocal && isRealPath) {
        // check realpath
        PageSource[] arr = ((PageContextImpl) pc).getRelativePageSources(pathWithCFC);
        page = toCIPage(PageSourceImpl.loadPage(pc, arr, null));
        if (page != null) {
            if (doCache)
                config.putCachedPageSource(localCacheName, page.getPageSource());
            return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
        }
    }
    // search with imports
    Mapping[] cMappings = config.getComponentMappings();
    if (isRealPath) {
        ImportDefintion impDef = config.getComponentDefaultImport();
        ImportDefintion[] impDefs = importDefintions == null ? EMPTY_ID : importDefintions;
        PageSource[] arr;
        int i = -1;
        do {
            if (impDef.isWildcard() || impDef.getName().equalsIgnoreCase(path)) {
                // search from local first
                if (searchLocal) {
                    arr = ((PageContextImpl) pc).getRelativePageSources(impDef.getPackageAsPath() + pathWithCFC);
                    page = toCIPage(PageSourceImpl.loadPage(pc, arr, null));
                    if (page != null) {
                        if (doCache)
                            config.putCachedPageSource("import:" + impDef.getPackageAsPath() + pathWithCFC, page.getPageSource());
                        return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
                    }
                }
                // search mappings and webroot
                page = toCIPage(PageSourceImpl.loadPage(pc, ((PageContextImpl) pc).getPageSources("/" + impDef.getPackageAsPath() + pathWithCFC), null));
                if (page != null) {
                    String key = impDef.getPackageAsPath() + pathWithCFC;
                    if (doCache && !((MappingImpl) page.getPageSource().getMapping()).isAppMapping())
                        config.putCachedPageSource("import:" + key, page.getPageSource());
                    return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
                }
                // search component mappings
                Mapping m;
                for (int y = 0; y < cMappings.length; y++) {
                    m = cMappings[y];
                    ps = m.getPageSource(impDef.getPackageAsPath() + pathWithCFC);
                    page = toCIPage(ps.loadPageThrowTemplateException(pc, false, (Page) null));
                    if (page != null) {
                        if (doCache)
                            config.putCachedPageSource("import:" + impDef.getPackageAsPath() + pathWithCFC, page.getPageSource());
                        return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
                    }
                }
            }
            impDef = ++i < impDefs.length ? impDefs[i] : null;
        } while (impDef != null);
    }
    String p;
    if (isRealPath)
        p = '/' + pathWithCFC;
    else
        p = pathWithCFC;
    // search mappings and webroot
    page = toCIPage(PageSourceImpl.loadPage(pc, ((PageContextImpl) pc).getPageSources(p), null));
    if (page != null) {
        String key = pathWithCFC;
        if (doCache && !((MappingImpl) page.getPageSource().getMapping()).isAppMapping())
            config.putCachedPageSource(key, page.getPageSource());
        return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
    }
    // search component mappings
    Mapping m;
    for (int i = 0; i < cMappings.length; i++) {
        m = cMappings[i];
        ps = m.getPageSource(p);
        page = toCIPage(ps.loadPageThrowTemplateException(pc, false, (Page) null));
        // recursive search
        if (page == null && config.doComponentDeepSearch() && path.indexOf('/') == -1) {
            ps = MappingUtil.searchMappingRecursive(m, pathWithCFC, true);
            if (ps != null) {
                page = toCIPage(ps.loadPageThrowTemplateException(pc, false, (Page) null));
                // do not cache this, it could be ambigous
                if (page != null)
                    doCache = false;
            }
        }
        if (page != null) {
            if (doCache)
                config.putCachedPageSource(pathWithCFC, page.getPageSource());
            return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
        }
    }
    // search relative to active component (this get not cached because the cache get ambigous if we do)
    if (searchLocal && isRealPath) {
        if (loadingLocation == null) {
            Component c = pc.getActiveComponent();
            if (c != null)
                loadingLocation = c.getPageSource();
        }
        if (loadingLocation != null) {
            ps = loadingLocation.getRealPage(pathWithCFC);
            if (ps != null) {
                page = toCIPage(ps.loadPageThrowTemplateException(pc, false, (Page) null));
                if (page != null) {
                    return returnType == RETURN_TYPE_PAGE ? page : load(pc, page, trim(path.replace('/', '.')), sub, isRealPath, returnType, isExtendedComponent, executeConstr);
                }
            }
        }
    }
    // translate cfide. to org.lucee.cfml
    if (StringUtil.startsWithIgnoreCase(rawPath, "cfide.")) {
        String rpm = Constants.DEFAULT_PACKAGE + "." + rawPath.substring(6);
        try {
            return _search(pc, loadingLocation, rpm, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect, false);
        } catch (ExpressionException ee) {
            return null;
        // throw new ExpressionException("invalid "+toStringType(returnType)+" definition, can't find "+rawPath+" or "+rpm);
        }
    }
    return null;
// throw new ExpressionException("invalid "+toStringType(returnType)+" definition, can't find "+toStringType(returnType)+" ["+rawPath+"]");
}
Also used : CIPage(lucee.runtime.CIPage) Mapping(lucee.runtime.Mapping) PageContextImpl(lucee.runtime.PageContextImpl) MappingImpl(lucee.runtime.MappingImpl) ExpressionException(lucee.runtime.exp.ExpressionException) PageSource(lucee.runtime.PageSource) Component(lucee.runtime.Component) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 14 with Component

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

the class EvaluateComponent method invoke.

public static Component invoke(PageContext pc, String name, String md5, Struct sctThis, Struct sctVariables) throws PageException {
    // Load comp
    Component comp = null;
    try {
        comp = pc.loadComponent(name);
        if (!ComponentUtil.md5(comp).equals(md5)) {
            SystemOut.printDate(pc.getConfig().getErrWriter(), "component [" + name + "] in this enviroment has not the same interface as the component to load, it is possible that one off the components has Functions added dynamicly.");
        // throw new ExpressionException("component ["+name+"] in this enviroment has not the same interface as the component to load");
        }
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
    setInternalState(comp, sctThis, sctVariables);
    return comp;
}
Also used : Component(lucee.runtime.Component) PageException(lucee.runtime.exp.PageException)

Example 15 with Component

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

the class GetApplicationSettings method call.

public static Struct call(PageContext pc, boolean suppressFunctions) {
    ApplicationContext ac = pc.getApplicationContext();
    Component cfc = null;
    if (ac instanceof ModernApplicationContext)
        cfc = ((ModernApplicationContext) ac).getComponent();
    Struct sct = new StructImpl();
    sct.setEL("applicationTimeout", ac.getApplicationTimeout());
    sct.setEL("clientManagement", Caster.toBoolean(ac.isSetClientManagement()));
    sct.setEL("clientStorage", ac.getClientstorage());
    sct.setEL("sessionStorage", ac.getSessionstorage());
    sct.setEL("customTagPaths", toArray(ac.getCustomTagMappings()));
    sct.setEL("loginStorage", AppListenerUtil.translateLoginStorage(ac.getLoginStorage()));
    sct.setEL(KeyConstants._mappings, toStruct(ac.getMappings()));
    sct.setEL(KeyConstants._name, ac.getName());
    sct.setEL("scriptProtect", AppListenerUtil.translateScriptProtect(ac.getScriptProtect()));
    sct.setEL("secureJson", Caster.toBoolean(ac.getSecureJson()));
    sct.setEL("typeChecking", Caster.toBoolean(ac.getTypeChecking()));
    sct.setEL("secureJsonPrefix", ac.getSecureJsonPrefix());
    sct.setEL("sessionManagement", Caster.toBoolean(ac.isSetSessionManagement()));
    sct.setEL("sessionTimeout", ac.getSessionTimeout());
    sct.setEL("clientTimeout", ac.getClientTimeout());
    sct.setEL("setClientCookies", Caster.toBoolean(ac.isSetClientCookies()));
    sct.setEL("setDomainCookies", Caster.toBoolean(ac.isSetDomainCookies()));
    sct.setEL(KeyConstants._name, ac.getName());
    sct.setEL("localMode", ac.getLocalMode() == Undefined.MODE_LOCAL_OR_ARGUMENTS_ALWAYS ? Boolean.TRUE : Boolean.FALSE);
    sct.setEL(KeyConstants._locale, LocaleFactory.toString(pc.getLocale()));
    sct.setEL(KeyConstants._timezone, TimeZoneUtil.toString(pc.getTimeZone()));
    // scope cascading
    sct.setEL("scopeCascading", ConfigWebUtil.toScopeCascading(ac.getScopeCascading(), null));
    if (ac.getScopeCascading() != Config.SCOPE_SMALL) {
        sct.setEL("searchImplicitScopes", ac.getScopeCascading() == Config.SCOPE_STANDARD);
    }
    Struct cs = new StructImpl();
    cs.setEL("web", pc.getWebCharset().name());
    cs.setEL("resource", ((PageContextImpl) pc).getResourceCharset().name());
    sct.setEL("charset", cs);
    sct.setEL("sessionType", AppListenerUtil.toSessionType(((PageContextImpl) pc).getSessionType(), "application"));
    // TODO impl
    sct.setEL("serverSideFormValidation", Boolean.FALSE);
    sct.setEL("clientCluster", Caster.toBoolean(ac.getClientCluster()));
    sct.setEL("sessionCluster", Caster.toBoolean(ac.getSessionCluster()));
    sct.setEL("invokeImplicitAccessor", Caster.toBoolean(ac.getTriggerComponentDataMember()));
    sct.setEL("triggerDataMember", Caster.toBoolean(ac.getTriggerComponentDataMember()));
    sct.setEL("sameformfieldsasarray", Caster.toBoolean(ac.getSameFieldAsArray(Scope.SCOPE_FORM)));
    sct.setEL("sameurlfieldsasarray", Caster.toBoolean(ac.getSameFieldAsArray(Scope.SCOPE_URL)));
    Object ds = ac.getDefDataSource();
    if (ds instanceof DataSource)
        ds = _call((DataSource) ds);
    else
        ds = Caster.toString(ds, null);
    sct.setEL(KeyConstants._datasource, ds);
    sct.setEL("defaultDatasource", ds);
    Resource src = ac.getSource();
    if (src != null)
        sct.setEL(KeyConstants._source, src.getAbsolutePath());
    // orm
    if (ac.isORMEnabled()) {
        ORMConfiguration conf = ac.getORMConfiguration();
        if (conf != null)
            sct.setEL(KeyConstants._orm, conf.toStruct());
    }
    // s3
    Properties props = ac.getS3();
    if (props != null) {
        sct.setEL(KeyConstants._s3, props.toStruct());
    }
    // ws settings
    {
        Struct wssettings = new StructImpl();
        wssettings.put(KeyConstants._type, AppListenerUtil.toWSType(ac.getWSType(), "Axis1"));
        sct.setEL("wssettings", wssettings);
    }
    // datasources
    Struct _sources = new StructImpl();
    sct.setEL(KeyConstants._datasources, _sources);
    DataSource[] sources = ac.getDataSources();
    if (!ArrayUtil.isEmpty(sources)) {
        for (int i = 0; i < sources.length; i++) {
            _sources.setEL(KeyImpl.init(sources[i].getName()), _call(sources[i]));
        }
    }
    // logs
    Struct _logs = new StructImpl();
    sct.setEL("logs", _logs);
    if (ac instanceof ApplicationContextSupport) {
        ApplicationContextSupport acs = (ApplicationContextSupport) ac;
        Iterator<Key> it = acs.getLogNames().iterator();
        Key name;
        while (it.hasNext()) {
            name = it.next();
            _logs.setEL(name, acs.getLogMetaData(name.getString()));
        }
    }
    // mails
    Array _mails = new ArrayImpl();
    sct.setEL("mails", _mails);
    if (ac instanceof ApplicationContextSupport) {
        ApplicationContextSupport acs = (ApplicationContextSupport) ac;
        Server[] servers = acs.getMailServers();
        Struct s;
        Server srv;
        if (servers != null) {
            for (int i = 0; i < servers.length; i++) {
                srv = servers[i];
                s = new StructImpl();
                _mails.appendEL(s);
                s.setEL(KeyConstants._host, srv.getHostName());
                s.setEL(KeyConstants._port, srv.getPort());
                if (!StringUtil.isEmpty(srv.getUsername()))
                    s.setEL(KeyConstants._username, srv.getUsername());
                if (!StringUtil.isEmpty(srv.getPassword()))
                    s.setEL(KeyConstants._password, srv.getPassword());
                s.setEL(KeyConstants._readonly, srv.isReadOnly());
                s.setEL("ssl", srv.isSSL());
                s.setEL("tls", srv.isTLS());
                if (srv instanceof ServerImpl) {
                    ServerImpl srvi = (ServerImpl) srv;
                    s.setEL("lifeTimespan", TimeSpanImpl.fromMillis(srvi.getLifeTimeSpan()));
                    s.setEL("idleTimespan", TimeSpanImpl.fromMillis(srvi.getIdleTimeSpan()));
                }
            }
        }
    }
    // tag
    Map<Key, Map<Collection.Key, Object>> tags = ac.getTagAttributeDefaultValues(pc);
    if (tags != null) {
        Struct tag = new StructImpl();
        Iterator<Entry<Key, Map<Collection.Key, Object>>> it = tags.entrySet().iterator();
        Entry<Collection.Key, Map<Collection.Key, Object>> e;
        Iterator<Entry<Collection.Key, Object>> iit;
        Entry<Collection.Key, Object> ee;
        Struct tmp;
        // TagLib lib = ((ConfigImpl)pc.getConfig()).getCoreTagLib();
        while (it.hasNext()) {
            e = it.next();
            iit = e.getValue().entrySet().iterator();
            tmp = new StructImpl();
            while (iit.hasNext()) {
                ee = iit.next();
                // lib.getTagByClassName(ee.getKey());
                tmp.setEL(ee.getKey(), ee.getValue());
            }
            tag.setEL(e.getKey(), tmp);
        }
        sct.setEL(KeyConstants._tag, tag);
    }
    // cache
    String fun = ac.getDefaultCacheName(Config.CACHE_TYPE_FUNCTION);
    String obj = ac.getDefaultCacheName(Config.CACHE_TYPE_OBJECT);
    String qry = ac.getDefaultCacheName(Config.CACHE_TYPE_QUERY);
    String res = ac.getDefaultCacheName(Config.CACHE_TYPE_RESOURCE);
    String tmp = ac.getDefaultCacheName(Config.CACHE_TYPE_TEMPLATE);
    String inc = ac.getDefaultCacheName(Config.CACHE_TYPE_INCLUDE);
    String htt = ac.getDefaultCacheName(Config.CACHE_TYPE_HTTP);
    String fil = ac.getDefaultCacheName(Config.CACHE_TYPE_FILE);
    String wse = ac.getDefaultCacheName(Config.CACHE_TYPE_WEBSERVICE);
    // cache connections
    Struct conns = new StructImpl();
    if (ac instanceof ApplicationContextSupport) {
        ApplicationContextSupport acs = (ApplicationContextSupport) ac;
        Key[] names = acs.getCacheConnectionNames();
        for (Key name : names) {
            CacheConnection data = acs.getCacheConnection(name.getString(), null);
            Struct _sct = new StructImpl();
            conns.setEL(name, _sct);
            _sct.setEL(KeyConstants._custom, data.getCustom());
            _sct.setEL(KeyConstants._storage, data.isStorage());
            ClassDefinition cd = data.getClassDefinition();
            if (cd != null) {
                _sct.setEL(KeyConstants._class, cd.getClassName());
                if (!StringUtil.isEmpty(cd.getName()))
                    _sct.setEL(KeyConstants._bundleName, cd.getClassName());
                if (cd.getVersion() != null)
                    _sct.setEL(KeyConstants._bundleVersion, cd.getVersionAsString());
            }
        }
    }
    if (!conns.isEmpty() || fun != null || obj != null || qry != null || res != null || tmp != null || inc != null || htt != null || fil != null || wse != null) {
        Struct cache = new StructImpl();
        sct.setEL(KeyConstants._cache, cache);
        if (fun != null)
            cache.setEL(KeyConstants._function, fun);
        if (obj != null)
            cache.setEL(KeyConstants._object, obj);
        if (qry != null)
            cache.setEL(KeyConstants._query, qry);
        if (res != null)
            cache.setEL(KeyConstants._resource, res);
        if (tmp != null)
            cache.setEL(KeyConstants._template, tmp);
        if (inc != null)
            cache.setEL(KeyConstants._include, inc);
        if (htt != null)
            cache.setEL(KeyConstants._http, htt);
        if (fil != null)
            cache.setEL(KeyConstants._file, fil);
        if (wse != null)
            cache.setEL(KeyConstants._webservice, wse);
        if (conns != null)
            cache.setEL(KeyConstants._connections, conns);
    }
    // java settings
    JavaSettings js = ac.getJavaSettings();
    StructImpl jsSct = new StructImpl();
    jsSct.put("loadCFMLClassPath", js.loadCFMLClassPath());
    jsSct.put("reloadOnChange", js.reloadOnChange());
    jsSct.put("watchInterval", new Double(js.watchInterval()));
    jsSct.put("watchExtensions", ListUtil.arrayToList(js.watchedExtensions(), ","));
    Resource[] reses = js.getResources();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < reses.length; i++) {
        if (i > 0)
            sb.append(',');
        sb.append(reses[i].getAbsolutePath());
    }
    jsSct.put("loadCFMLClassPath", sb.toString());
    sct.put("javaSettings", jsSct);
    if (cfc != null) {
        sct.setEL(KeyConstants._component, cfc.getPageSource().getDisplayPath());
        try {
            ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, cfc);
            Iterator<Key> it = cw.keyIterator();
            Collection.Key key;
            Object value;
            while (it.hasNext()) {
                key = it.next();
                value = cw.get(key);
                if (suppressFunctions && value instanceof UDF)
                    continue;
                if (!sct.containsKey(key))
                    sct.setEL(key, value);
            }
        } catch (PageException e) {
            SystemOut.printDate(e);
        }
    }
    return sct;
}
Also used : Server(lucee.runtime.net.mail.Server) ArrayImpl(lucee.runtime.type.ArrayImpl) Properties(lucee.runtime.net.s3.Properties) ClassDefinition(lucee.runtime.db.ClassDefinition) Struct(lucee.runtime.type.Struct) ModernApplicationContext(lucee.runtime.listener.ModernApplicationContext) ApplicationContext(lucee.runtime.listener.ApplicationContext) Entry(java.util.Map.Entry) ServerImpl(lucee.runtime.net.mail.ServerImpl) UDF(lucee.runtime.type.UDF) ComponentSpecificAccess(lucee.runtime.ComponentSpecificAccess) Component(lucee.runtime.Component) ORMConfiguration(lucee.runtime.orm.ORMConfiguration) ApplicationContextSupport(lucee.runtime.listener.ApplicationContextSupport) PageException(lucee.runtime.exp.PageException) JavaSettings(lucee.runtime.listener.JavaSettings) Resource(lucee.commons.io.res.Resource) PageContextImpl(lucee.runtime.PageContextImpl) DataSource(lucee.runtime.db.DataSource) Array(lucee.runtime.type.Array) Key(lucee.runtime.type.Collection.Key) StructImpl(lucee.runtime.type.StructImpl) Collection(lucee.runtime.type.Collection) ModernApplicationContext(lucee.runtime.listener.ModernApplicationContext) Map(java.util.Map) CacheConnection(lucee.runtime.cache.CacheConnection) Key(lucee.runtime.type.Collection.Key)

Aggregations

Component (lucee.runtime.Component)36 PageException (lucee.runtime.exp.PageException)12 Key (lucee.runtime.type.Collection.Key)12 Struct (lucee.runtime.type.Struct)12 PageContextImpl (lucee.runtime.PageContextImpl)9 UDF (lucee.runtime.type.UDF)9 Entry (java.util.Map.Entry)7 ComponentScope (lucee.runtime.ComponentScope)7 PageContext (lucee.runtime.PageContext)7 Array (lucee.runtime.type.Array)7 JavaObject (lucee.runtime.java.JavaObject)6 IOException (java.io.IOException)5 PageSource (lucee.runtime.PageSource)5 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)5 ExpressionException (lucee.runtime.exp.ExpressionException)5 Collection (lucee.runtime.type.Collection)5 ComponentSpecificAccess (lucee.runtime.ComponentSpecificAccess)4 Property (lucee.runtime.component.Property)4 ArrayImpl (lucee.runtime.type.ArrayImpl)4 StructImpl (lucee.runtime.type.StructImpl)4