use of lucee.runtime.config.ConfigImpl 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);
}
}
use of lucee.runtime.config.ConfigImpl in project Lucee by lucee.
the class ApplicationContextSupport method initTagDefaultAttributeValues.
public static void initTagDefaultAttributeValues(Config config, Map<Collection.Key, Map<Collection.Key, Object>> tagDefaultAttributeValues, Struct sct, int dialect) {
if (sct.size() == 0)
return;
ConfigImpl ci = ((ConfigImpl) config);
// first check the core lib without namespace
TagLib lib = ci.getCoreTagLib(dialect);
_initTagDefaultAttributeValues(config, lib, tagDefaultAttributeValues, sct, false);
if (sct.size() == 0)
return;
// then all the other libs including the namespace
TagLib[] tlds = ci.getTLDs(dialect);
for (int i = 0; i < tlds.length; i++) {
_initTagDefaultAttributeValues(config, tlds[i], tagDefaultAttributeValues, sct, true);
if (sct.size() == 0)
return;
}
}
use of lucee.runtime.config.ConfigImpl in project Lucee by lucee.
the class GetBaseTagList method getName.
private static String getName(PageContext pc, Tag tag) {
Class clazz = tag.getClass();
if (clazz == CFImportTag.class)
clazz = CFTag.class;
String className = clazz.getName();
TagLib[] tlds = ((ConfigImpl) pc.getConfig()).getTLDs(pc.getCurrentTemplateDialect());
TagLibTag tlt;
for (int i = 0; i < tlds.length; i++) {
// String ns = tlds[i].getNameSpaceAndSeparator();
Map tags = tlds[i].getTags();
Iterator it = tags.keySet().iterator();
while (it.hasNext()) {
tlt = (TagLibTag) tags.get(it.next());
if (tlt.getTagClassDefinition().isClassNameEqualTo(className)) {
// custm tag
if (tag instanceof AppendixTag) {
AppendixTag atag = (AppendixTag) tag;
if (atag.getAppendix() != null && !(tag instanceof Module)) {
return tlt.getFullName().toUpperCase() + atag.getAppendix().toUpperCase();
}
}
// built in cfc based custom tag
if (tag instanceof CFTagCore) {
if (((CFTagCore) tag).getName().equals(tlt.getAttribute("__name").getDefaultValue()))
return tlt.getFullName().toUpperCase();
continue;
}
return tlt.getFullName().toUpperCase();
}
}
}
return ListUtil.last(className, ".", true).toUpperCase();
}
use of lucee.runtime.config.ConfigImpl in project Lucee by lucee.
the class ColumnInfo method doEndTag.
@Override
public int doEndTag() throws PageException {
Object ds = DBInfo.getDatasource(pageContext, datasource);
DataSourceManager manager = pageContext.getDataSourceManager();
DatasourceConnection dc = ds instanceof DataSource ? manager.getConnection(pageContext, (DataSource) ds, username, password) : manager.getConnection(pageContext, Caster.toString(ds), username, password);
try {
Struct meta = null;
try {
meta = getMeta(dc, tablequalifier, tableowner, tablename);
} catch (SQLException se) {
meta = new StructImpl();
}
SQL sql = createSQL(meta);
if (sql != null) {
lucee.runtime.type.Query query = new QueryImpl(pageContext, dc, sql, -1, -1, null, "query");
if (pageContext.getConfig().debug()) {
String dsn = ds instanceof DataSource ? ((DataSource) ds).getName() : Caster.toString(ds);
boolean logdb = ((ConfigImpl) pageContext.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DATABASE);
if (logdb) {
boolean debugUsage = DebuggerImpl.debugQueryUsage(pageContext, query);
pageContext.getDebugger().addQuery(debugUsage ? query : null, dsn, "", sql, query.getRecordcount(), pageContext.getCurrentPageSource(), query.getExecutionTime());
}
}
// log
Log log = pageContext.getConfig().getLog("datasource");
if (log.getLogLevel() >= Log.LEVEL_INFO) {
log.info("insert tag", "executed [" + sql.toString().trim() + "] in " + DecimalFormat.call(pageContext, query.getExecutionTime() / 1000000D) + " ms");
}
}
return EVAL_PAGE;
} catch (PageException pe) {
pageContext.getConfig().getLog("datasource").error("insert tag", pe);
throw pe;
} finally {
manager.releaseConnection(pageContext, dc);
}
}
use of lucee.runtime.config.ConfigImpl in project Lucee by lucee.
the class Log method getFileLog.
private static lucee.commons.io.log.Log getFileLog(PageContext pc, String file, CharSet charset, boolean async) throws PageException {
ConfigImpl config = (ConfigImpl) pc.getConfig();
Resource logDir = config.getLogDirectory();
Resource res = logDir.getRealResource(file);
LogAdapter log = FileLogPool.instance.get(res, CharsetUtil.toCharset(charset));
if (log != null)
return log;
if (charset == null)
charset = CharsetUtil.toCharSet(((PageContextImpl) pc).getResourceCharset());
try {
log = new LogAdapter(Log4jUtil.getResourceLog(config, res, CharsetUtil.toCharset(charset), "cflog." + FileLogPool.toKey(file, CharsetUtil.toCharset(charset)), Level.TRACE, 5, new Listener(FileLogPool.instance, res, charset), async));
FileLogPool.instance.put(res, CharsetUtil.toCharset(charset), log);
} catch (IOException e) {
throw Caster.toPageException(e);
}
return log;
}
Aggregations