Search in sources :

Example 26 with ConfigImpl

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);
    }
}
Also used : StructImpl(lucee.runtime.type.StructImpl) Resource(lucee.commons.io.res.Resource) ConfigImpl(lucee.runtime.config.ConfigImpl) PageSource(lucee.runtime.PageSource)

Example 27 with ConfigImpl

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;
    }
}
Also used : TagLib(lucee.transformer.library.tag.TagLib) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 28 with ConfigImpl

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();
}
Also used : TagLibTag(lucee.transformer.library.tag.TagLibTag) CFTag(lucee.runtime.tag.CFTag) CFTagCore(lucee.runtime.tag.CFTagCore) TagLib(lucee.transformer.library.tag.TagLib) Iterator(java.util.Iterator) AppendixTag(lucee.runtime.ext.tag.AppendixTag) Module(lucee.runtime.tag.Module) Map(java.util.Map) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 29 with ConfigImpl

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);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) DatasourceConnection(lucee.runtime.db.DatasourceConnection) SQLException(java.sql.SQLException) Log(lucee.commons.io.log.Log) DataSourceManager(lucee.runtime.db.DataSourceManager) DataSource(lucee.runtime.db.DataSource) Struct(lucee.runtime.type.Struct) SQL(lucee.runtime.db.SQL) QueryImpl(lucee.runtime.type.QueryImpl) StructImpl(lucee.runtime.type.StructImpl) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 30 with ConfigImpl

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;
}
Also used : RetireListener(lucee.commons.io.retirement.RetireListener) Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException) LogAdapter(lucee.commons.io.log.log4j.LogAdapter) ConfigImpl(lucee.runtime.config.ConfigImpl)

Aggregations

ConfigImpl (lucee.runtime.config.ConfigImpl)47 PageException (lucee.runtime.exp.PageException)15 Log (lucee.commons.io.log.Log)14 DatasourceConnection (lucee.runtime.db.DatasourceConnection)10 ApplicationException (lucee.runtime.exp.ApplicationException)8 Struct (lucee.runtime.type.Struct)8 StructImpl (lucee.runtime.type.StructImpl)8 DataSource (lucee.runtime.db.DataSource)7 DatasourceConnectionPool (lucee.runtime.db.DatasourceConnectionPool)7 SQLExecutor (lucee.runtime.type.scope.storage.db.SQLExecutor)7 SQLException (java.sql.SQLException)6 Resource (lucee.commons.io.res.Resource)6 PageContextImpl (lucee.runtime.PageContextImpl)6 PageSource (lucee.runtime.PageSource)6 QueryImpl (lucee.runtime.type.QueryImpl)5 ArrayList (java.util.ArrayList)4 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)4 DatabaseException (lucee.runtime.exp.DatabaseException)4 Key (lucee.runtime.type.Collection.Key)4 IOException (java.io.IOException)3