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());
}
}
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);
}
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);
}
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;
}
}
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;
}
}
Aggregations