Search in sources :

Example 26 with ConfigWebImpl

use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.

the class CacheStorageScopeCleaner method _clean.

@Override
protected void _clean() {
    ConfigWebImpl config = (ConfigWebImpl) engine.getFactory().getConfig();
    Map<String, CacheConnection> connections = config.getCacheConnections();
    CacheConnection cc;
    if (connections != null) {
        Map.Entry<String, CacheConnection> entry;
        Iterator<Entry<String, CacheConnection>> it = connections.entrySet().iterator();
        while (it.hasNext()) {
            entry = it.next();
            cc = entry.getValue();
            if (cc.isStorage()) {
                try {
                    clean(cc, config);
                } catch (IOException e) {
                    error(e);
                }
            }
        }
    }
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) CacheEntry(lucee.commons.io.cache.CacheEntry) Entry(java.util.Map.Entry) IOException(java.io.IOException) CacheConnection(lucee.runtime.cache.CacheConnection) Map(java.util.Map)

Example 27 with ConfigWebImpl

use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.

the class _GetElement method toResourceExisting.

public static Resource toResourceExisting(Config config, ApplicationContext ac, Object obj, boolean onlyDir) {
    // Resource root = config.getRootDirectory();
    String path = Caster.toString(obj, null);
    if (StringUtil.isEmpty(path, true))
        return null;
    path = path.trim();
    Resource res;
    PageContext pc = ThreadLocalPageContext.get();
    // first check relative to application . cfc
    if (pc != null) {
        if (ac == null)
            ac = pc.getApplicationContext();
        // abs path
        if (path.startsWith("/")) {
            ConfigWebImpl cwi = (ConfigWebImpl) config;
            PageSource ps = cwi.getPageSourceExisting(pc, ac == null ? null : ac.getMappings(), path, false, false, true, false);
            if (ps != null) {
                res = ps.getResource();
                if (res != null && (!onlyDir || res.isDirectory()))
                    return res;
            }
        } else // real path
        {
            Resource src = ac != null ? ac.getSource() : null;
            if (src != null) {
                res = src.getParentResource().getRealResource(path);
                if (res != null && (!onlyDir || res.isDirectory()))
                    return res;
            } else // happens when this is called from within the application . cfc (init)
            {
                res = ResourceUtil.toResourceNotExisting(pc, path);
                if (res != null && (!onlyDir || res.isDirectory()))
                    return res;
            }
        }
    }
    // then in the webroot
    res = config.getRootDirectory().getRealResource(path);
    if (res != null && (!onlyDir || res.isDirectory()))
        return res;
    // then absolute
    res = ResourceUtil.toResourceNotExisting(config, path);
    if (res != null && (!onlyDir || res.isDirectory()))
        return res;
    return null;
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) Resource(lucee.commons.io.res.Resource) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) PageContext(lucee.runtime.PageContext) PageSource(lucee.runtime.PageSource)

Example 28 with ConfigWebImpl

use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.

the class Admin method doGetInfo.

private void doGetInfo() throws PageException {
    Struct sct = new StructImpl();
    pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
    if (config instanceof ConfigWebImpl) {
        ConfigWebImpl cw = (ConfigWebImpl) config;
        sct.setEL(KeyConstants._id, cw.getIdentification().getId());
        sct.setEL(KeyConstants._label, cw.getLabel());
        sct.setEL(KeyConstants._hash, cw.getHash());
        sct.setEL(KeyConstants._root, cw.getRootDirectory().getAbsolutePath());
        sct.setEL("configServerDir", cw.getConfigServerDir().getAbsolutePath());
        sct.setEL("configWebDir", cw.getConfigDir().getAbsolutePath());
    } else {
        sct.setEL("configServerDir", config.getConfigDir().getAbsolutePath());
        sct.setEL("configWebDir", pageContext.getConfig().getConfigDir().getAbsolutePath());
    }
    sct.setEL(KeyConstants._config, config.getConfigFile().getAbsolutePath());
    // Servlets
    if (config instanceof ConfigServer) {
        ConfigServer cs = (ConfigServer) config;
        CFMLEngineImpl engine = (CFMLEngineImpl) cs.getCFMLEngine();
        Struct srv = new StructImpl(), params;
        ServletConfig[] configs = engine.getServletConfigs();
        ServletConfig sc;
        Enumeration e;
        String name, value;
        for (int i = 0; i < configs.length; i++) {
            sc = configs[i];
            e = sc.getInitParameterNames();
            params = new StructImpl();
            while (e.hasMoreElements()) {
                name = (String) e.nextElement();
                value = sc.getInitParameter(name);
                params.set(name, value);
            }
            srv.set(sc.getServletName(), params);
        }
        sct.set("servlets", srv);
    }
    // sct.setEL("javaAgentSupported", Caster.toBoolean(InstrumentationUtil.isSupported()));
    sct.setEL("javaAgentSupported", Boolean.TRUE);
// sct.setEL("javaAgentPath", ClassUtil.getSourcePathForClass("lucee.runtime.instrumentation.Agent", ""));
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) CFMLEngineImpl(lucee.runtime.engine.CFMLEngineImpl) StructImpl(lucee.runtime.type.StructImpl) Enumeration(java.util.Enumeration) ServletConfig(javax.servlet.ServletConfig) ConfigServer(lucee.runtime.config.ConfigServer) Struct(lucee.runtime.type.Struct)

Example 29 with ConfigWebImpl

use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.

the class Admin method doGetContexts.

/**
 * @throws PageException
 */
private void doGetContexts() throws PageException {
    CFMLFactory[] factories;
    if (config instanceof ConfigServerImpl) {
        ConfigServerImpl cs = (ConfigServerImpl) config;
        factories = cs.getJSPFactories();
    } else {
        ConfigWebImpl cw = (ConfigWebImpl) config;
        factories = new CFMLFactory[] { cw.getFactory() };
    }
    lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._path, KeyConstants._id, KeyConstants._hash, KeyConstants._label, HAS_OWN_SEC_CONTEXT, KeyConstants._url, CONFIG_FILE, CLIENT_SIZE, CLIENT_ELEMENTS, SESSION_SIZE, SESSION_ELEMENTS }, factories.length, getString("admin", action, "returnVariable"));
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    ConfigWebImpl cw;
    for (int i = 0; i < factories.length; i++) {
        int row = i + 1;
        CFMLFactoryImpl factory = (CFMLFactoryImpl) factories[i];
        cw = (ConfigWebImpl) factory.getConfig();
        qry.setAtEL(KeyConstants._path, row, ReqRspUtil.getRootPath(factory.getConfigWebImpl().getServletContext()));
        qry.setAtEL(CONFIG_FILE, row, factory.getConfigWebImpl().getConfigFile().getAbsolutePath());
        if (factory.getURL() != null)
            qry.setAtEL(KeyConstants._url, row, factory.getURL().toExternalForm());
        qry.setAtEL(KeyConstants._id, row, factory.getConfig().getIdentification().getId());
        qry.setAtEL(KeyConstants._hash, row, SystemUtil.hash(factory.getConfigWebImpl().getServletContext()));
        qry.setAtEL(KeyConstants._label, row, factory.getLabel());
        qry.setAtEL(HAS_OWN_SEC_CONTEXT, row, Caster.toBoolean(cw.hasIndividualSecurityManager()));
        setScopeDirInfo(qry, row, CLIENT_SIZE, CLIENT_ELEMENTS, cw.getClientScopeDir());
        setScopeDirInfo(qry, row, SESSION_SIZE, SESSION_ELEMENTS, cw.getSessionScopeDir());
    }
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) QueryImpl(lucee.runtime.type.QueryImpl) CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) CFMLFactory(lucee.runtime.CFMLFactory) ConfigServerImpl(lucee.runtime.config.ConfigServerImpl) Query(lucee.runtime.type.Query)

Example 30 with ConfigWebImpl

use of lucee.runtime.config.ConfigWebImpl in project Lucee by lucee.

the class Admin method doGateway.

private void doGateway() throws PageException {
    String id = getString("admin", action, "id");
    String act = getString("admin", action, "gatewayAction").trim().toLowerCase();
    if ("restart".equals(act))
        ((ConfigWebImpl) config).getGatewayEngine().restart(id);
    else if ("start".equals(act))
        ((ConfigWebImpl) config).getGatewayEngine().start(id);
    else if ("stop".equals(act))
        ((ConfigWebImpl) config).getGatewayEngine().stop(id);
    else
        throw new ApplicationException("invalid gateway action [" + act + "], valid actions are [start,stop,restart]");
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) ApplicationException(lucee.runtime.exp.ApplicationException)

Aggregations

ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)42 Resource (lucee.commons.io.res.Resource)9 PageContextImpl (lucee.runtime.PageContextImpl)9 Struct (lucee.runtime.type.Struct)9 PageSource (lucee.runtime.PageSource)8 PageException (lucee.runtime.exp.PageException)8 Key (lucee.runtime.type.Collection.Key)8 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)7 Mapping (lucee.runtime.Mapping)7 ConfigServer (lucee.runtime.config.ConfigServer)6 ConfigWeb (lucee.runtime.config.ConfigWeb)5 ApplicationException (lucee.runtime.exp.ApplicationException)5 StructImpl (lucee.runtime.type.StructImpl)5 IOException (java.io.IOException)4 Entry (java.util.Map.Entry)4 ConfigImpl (lucee.runtime.config.ConfigImpl)4 HTTPResource (lucee.commons.io.res.type.http.HTTPResource)3 Page (lucee.runtime.Page)3 PageContext (lucee.runtime.PageContext)3 ExpressionException (lucee.runtime.exp.ExpressionException)3