Search in sources :

Example 16 with Config

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

the class OSGiUtil method log.

private static void log(Throwable t) {
    try {
        Config config = ThreadLocalPageContext.getConfig();
        Log log = config != null ? config.getLog("application") : null;
        if (log != null)
            log.log(Log.LEVEL_ERROR, "OSGi", t);
    } catch (Throwable _t) {
        ExceptionUtil.rethrowIfNecessary(_t);
        /* this can fail when called from an old loader */
        System.out.println(t.getMessage());
    }
}
Also used : Log(lucee.commons.io.log.Log) Config(lucee.runtime.config.Config)

Example 17 with Config

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

the class PageSourceImpl method getDialect.

@Override
public int getDialect() {
    Config c = getMapping().getConfig();
    if (!((ConfigImpl) c).allowLuceeDialect())
        return CFMLEngine.DIALECT_CFML;
    // MUST improve performance on this
    ConfigWeb cw = null;
    String ext = ResourceUtil.getExtension(relPath, Constants.getCFMLComponentExtension());
    if (c instanceof ConfigWeb)
        cw = (ConfigWeb) c;
    else {
        c = ThreadLocalPageContext.getConfig();
        if (c instanceof ConfigWeb)
            cw = (ConfigWeb) c;
    }
    if (cw != null) {
        return ((CFMLFactoryImpl) cw.getFactory()).toDialect(ext, CFMLEngine.DIALECT_CFML);
    }
    return ConfigWebUtil.toDialect(ext, CFMLEngine.DIALECT_CFML);
}
Also used : Config(lucee.runtime.config.Config) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 18 with Config

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

the class CacheUtil method getDefault.

/**
 * get the default cache for a certain type, also check definitions in application context (application . cfc/cfapplication)
 * @param pc current PageContext
 * @param type default type -> Config.CACHE_DEFAULT_...
 * @return matching cache
 * @throws IOException
 */
public static Cache getDefault(PageContext pc, int type) throws IOException {
    // get default from application conetxt
    String name = pc != null ? pc.getApplicationContext().getDefaultCacheName(type) : null;
    if (!StringUtil.isEmpty(name)) {
        Cache cc = getCache(pc, name, null);
        if (cc != null)
            return cc;
    }
    // get default from config
    Config config = ThreadLocalPageContext.getConfig(pc);
    CacheConnection cc = ((ConfigImpl) config).getCacheDefaultConnection(type);
    if (cc == null)
        throw new CacheException("there is no default " + toStringType(type, "") + " cache defined, you need to define this default cache in the Lucee Administrator");
    return cc.getInstance(config);
}
Also used : CacheException(lucee.commons.io.cache.exp.CacheException) Config(lucee.runtime.config.Config) ConfigImpl(lucee.runtime.config.ConfigImpl) Cache(lucee.commons.io.cache.Cache)

Example 19 with Config

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

the class CacheUtil method getCache.

public static Cache getCache(PageContext pc, String cacheName, Cache defaultValue) {
    CacheConnection cc = getCacheConnection(pc, cacheName, null);
    if (cc == null)
        return defaultValue;
    Config config = ThreadLocalPageContext.getConfig(pc);
    try {
        return cc.getInstance(config);
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        return defaultValue;
    }
}
Also used : Config(lucee.runtime.config.Config)

Example 20 with Config

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

the class CacheUtil method getDefault.

/**
 * get the default cache for a certain type, also check definitions in application context (application . cfc/cfapplication)
 * @param pc current PageContext
 * @param type default type -> Config.CACHE_DEFAULT_...
 * @param defaultValue value returned when there is no default cache for this type
 * @return matching cache
 */
public static Cache getDefault(PageContext pc, int type, Cache defaultValue) {
    // get default from application conetx
    String name = null;
    if (pc != null && pc.getApplicationContext() != null)
        name = pc.getApplicationContext().getDefaultCacheName(type);
    Config config = ThreadLocalPageContext.getConfig(pc);
    if (!StringUtil.isEmpty(name)) {
        Cache cc = getCache(pc, name, null);
        if (cc != null)
            return cc;
    }
    // get default from config
    CacheConnection cc = ((ConfigImpl) config).getCacheDefaultConnection(type);
    if (cc == null)
        return defaultValue;
    try {
        return cc.getInstance(config);
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        return defaultValue;
    }
}
Also used : Config(lucee.runtime.config.Config) ConfigImpl(lucee.runtime.config.ConfigImpl) Cache(lucee.commons.io.cache.Cache)

Aggregations

Config (lucee.runtime.config.Config)25 ConfigWeb (lucee.runtime.config.ConfigWeb)4 ConfigImpl (lucee.runtime.config.ConfigImpl)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 Cache (lucee.commons.io.cache.Cache)2 Log (lucee.commons.io.log.Log)2 Resource (lucee.commons.io.res.Resource)2 CFMLFactory (lucee.runtime.CFMLFactory)2 PageContext (lucee.runtime.PageContext)2 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)2 File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 Charset (java.nio.charset.Charset)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1 ServletConfig (javax.servlet.ServletConfig)1 CacheException (lucee.commons.io.cache.exp.CacheException)1 ResourceProvider (lucee.commons.io.res.ResourceProvider)1 ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)1