Search in sources :

Example 11 with Config

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

the class SessionEndCacheEvent method onExpires.

@Override
public void onExpires(CacheEntry entry) {
    String key = entry.getKey();
    // type
    int index = key.indexOf(':'), last;
    // String type=key.substring(0,index);
    // cfid
    last = index + 1;
    index = key.indexOf(':', last);
    String cfid = key.substring(last, index);
    // appName
    last = index + 1;
    index = key.indexOf(':', last);
    String appName = key.substring(last);
    Config config = ThreadLocalPageContext.getConfig();
    _doEnd((CFMLFactoryImpl) (((ConfigWeb) config).getFactory()), appName, cfid);
}
Also used : Config(lucee.runtime.config.Config)

Example 12 with Config

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

the class CFMLResourceProvider method getPageContext.

private PageContext getPageContext(PageContext pc) {
    ThreadLocalPageContext.get(pc);
    if (pc != null)
        return pc;
    Config c = ThreadLocalPageContext.getConfig();
    if (c instanceof ConfigWeb) {
        return ThreadUtil.createPageContext((ConfigWeb) c, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, "localhost", "/", "", new Cookie[0], new Pair[0], null, new Pair[0], new StructImpl(), false, -1);
    }
    try {
        return CFMLEngineFactory.getInstance().createPageContext(new File("."), "localhost", "/", "", new Cookie[0], null, null, null, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, -1, false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : StructImpl(lucee.runtime.type.StructImpl) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) Config(lucee.runtime.config.Config) ConfigWeb(lucee.runtime.config.ConfigWeb) File(java.io.File) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) PageException(lucee.runtime.exp.PageException) IOException(java.io.IOException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 13 with Config

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

the class FormatUtil method addCustom.

private static void addCustom(List<DateFormat> list, Locale locale, short formatType) {
    // get custom formats from file
    Config config = ThreadLocalPageContext.getConfig();
    Resource dir = config != null ? config.getConfigDir().getRealResource("locales") : null;
    if (dir != null && dir.isDirectory()) {
        String appendix = "-datetime";
        if (formatType == FORMAT_TYPE_DATE)
            appendix = "-date";
        if (formatType == FORMAT_TYPE_TIME)
            appendix = "-time";
        Resource file = dir.getRealResource(locale.getLanguage() + "-" + locale.getCountry() + appendix + ".df");
        if (file.isFile()) {
            try {
                String content = IOUtil.toString(file, (Charset) null);
                String[] arr = lucee.runtime.type.util.ListUtil.listToStringArray(content, '\n');
                String line;
                SimpleDateFormat sdf;
                for (int i = 0; i < arr.length; i++) {
                    line = arr[i].trim();
                    if (StringUtil.isEmpty(line))
                        continue;
                    sdf = new SimpleDateFormat(line, locale);
                    if (!list.contains(sdf))
                        list.add(sdf);
                }
            } catch (Throwable t) {
                ExceptionUtil.rethrowIfNecessary(t);
            }
        }
    }
}
Also used : Config(lucee.runtime.config.Config) Resource(lucee.commons.io.res.Resource) SimpleDateFormat(java.text.SimpleDateFormat)

Example 14 with Config

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

the class DBUtilImpl method getDatasourceConnection.

public DatasourceConnection getDatasourceConnection(PageContext pc, String datasourceName, String user, String pass, boolean managed) throws PageException {
    DataSource datasource = null;
    pc = ThreadLocalPageContext.get(pc);
    if (pc != null) {
        // default datasource
        if ("__default__".equalsIgnoreCase(datasourceName)) {
            Object obj = pc.getApplicationContext().getDefDataSource();
            if (obj instanceof String)
                datasourceName = (String) obj;
            else
                datasource = (DataSource) obj;
        }
        // get datasource from application context
        if (datasource == null)
            datasource = pc.getApplicationContext().getDataSource(datasourceName, null);
    }
    // get datasource from config
    if (datasource == null) {
        Config config = ThreadLocalPageContext.getConfig(pc);
        datasource = config.getDataSource(datasourceName);
    }
    return getDatasourceConnection(pc, datasource, user, pass, managed);
}
Also used : Config(lucee.runtime.config.Config) DataSource(lucee.runtime.db.DataSource)

Example 15 with Config

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

the class ThreadUtil method cloneHttpServletRequest.

public static HttpServletRequest cloneHttpServletRequest(PageContext pc) {
    Config config = pc.getConfig();
    HttpServletRequest req = pc.getHttpServletRequest();
    HttpServletRequestDummy dest = HttpServletRequestDummy.clone(config, config.getRootDirectory(), req);
    return dest;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletRequestDummy(lucee.runtime.net.http.HttpServletRequestDummy) Config(lucee.runtime.config.Config)

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