Search in sources :

Example 21 with Config

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

the class CreationImpl method createPageContext.

@Override
public PageContext createPageContext(HttpServletRequest req, HttpServletResponse rsp, OutputStream out) {
    Config config = ThreadLocalPageContext.getConfig();
    if (!(config instanceof ConfigWeb))
        throw new RuntimeException("need a web context to create a PageContext");
    CFMLFactory factory = ((ConfigWeb) config).getFactory();
    return (PageContext) factory.getPageContext(factory.getServlet(), req, rsp, null, false, -1, false);
}
Also used : ServletConfig(javax.servlet.ServletConfig) Config(lucee.runtime.config.Config) CFMLFactory(lucee.runtime.CFMLFactory) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 22 with Config

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

the class Compress method load.

private synchronized void load(boolean caseSensitive) throws IOException {
    long actLastMod = ffile.lastModified();
    lastMod = actLastMod;
    lastCheck = System.currentTimeMillis();
    Map<String, Boolean> args = new HashMap<String, Boolean>();
    args.put("case-sensitive", Caster.toBoolean(caseSensitive));
    if (temp == null) {
        String cid = "";
        Config config = ThreadLocalPageContext.getConfig();
        if (config != null) {
            cid = config.getIdentification().getId();
            temp = config.getTempDirectory();
        }
        if (temp == null)
            temp = SystemUtil.getTempDirectory();
        temp = temp.getRealResource("compress");
        temp = temp.getRealResource(MD5.getDigestAsString(cid + "-" + ffile.getAbsolutePath()));
        if (!temp.exists())
            temp.mkdirs();
    }
    if (temp != null) {
        String name = Caster.toString(actLastMod) + ":" + Caster.toString(ffile.length());
        name = MD5.getDigestAsString(name, name);
        root = temp.getRealResource(name);
        if (actLastMod > 0 && root.exists())
            return;
        ResourceUtil.removeChildrenEL(temp);
        // if(root!=null)ResourceUtil.removeChildrenEL(root);
        // String name=CreateUUID.invoke();
        // root=temp.getRealResource(name);
        root.mkdirs();
    } else {
        ResourceProvider ramProvider = new RamResourceProviderOld().init("ram", args);
        root = ramProvider.getResource("/");
    }
    _load();
}
Also used : RamResourceProviderOld(lucee.commons.io.res.type.ram.RamResourceProviderOld) HashMap(java.util.HashMap) Config(lucee.runtime.config.Config) ResourceProvider(lucee.commons.io.res.ResourceProvider)

Example 23 with Config

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

the class DatasourceResourceProvider method getManager.

private DatasourceManagerImpl getManager() {
    if (_manager == null) {
        Config config = ThreadLocalPageContext.getConfig();
        _manager = new DatasourceManagerImpl((ConfigImpl) config);
    }
    return _manager;
}
Also used : Config(lucee.runtime.config.Config) DatasourceManagerImpl(lucee.runtime.db.DatasourceManagerImpl) ConfigImpl(lucee.runtime.config.ConfigImpl)

Example 24 with Config

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

the class ResourceLockImpl method _read.

private void _read(String path) {
    long start = -1, now;
    Thread t;
    do {
        if ((t = resources.get(path)) == null) {
            // print.ln("read ok");
            return;
        }
        if (t == Thread.currentThread()) {
            // aprint.err(path);
            Config config = ThreadLocalPageContext.getConfig();
            if (config != null)
                SystemOut.printDate(config.getErrWriter(), "conflict in same thread: on " + path);
            // SystemOut.printDate(config.getErrWriter(),"conflict in same thread: on "+path+"\nStacktrace:\n"+StringUtil.replace(ExceptionUtil.getStacktrace(new Throwable(), false),"java.lang.Throwable\n","",true));
            return;
        }
        // bugfix when lock von totem thread, wird es ignoriert
        if (!t.isAlive()) {
            resources.remove(path);
            return;
        }
        if (start == -1)
            start = System.currentTimeMillis();
        try {
            token.wait(lockTimeout);
            now = System.currentTimeMillis();
            if ((start + lockTimeout) <= now) {
                Config config = ThreadLocalPageContext.getConfig();
                if (config != null) {
                    PageContextImpl pc = null;
                    String add = "";
                    if (config instanceof ConfigWeb) {
                        CFMLFactory factory = ((ConfigWeb) config).getFactory();
                        if (factory instanceof CFMLFactoryImpl) {
                            Map<Integer, PageContextImpl> pcs = ((CFMLFactoryImpl) factory).getActivePageContexts();
                            Iterator<PageContextImpl> it = pcs.values().iterator();
                            PageContextImpl tmp;
                            while (it.hasNext()) {
                                tmp = it.next();
                                if (t == tmp.getThread()) {
                                    pc = tmp;
                                    break;
                                }
                            }
                        }
                    }
                    if (pc != null) {
                        add = " The file is locked by a request on the following URL " + ReqRspUtil.getRequestURL(pc.getHttpServletRequest(), true) + ", that request started " + (System.currentTimeMillis() - pc.getStartTime()) + "ms ago.";
                    }
                    SystemOut.printDate(config.getErrWriter(), "timeout after " + (now - start) + " ms (" + (lockTimeout) + " ms) occured while accessing file [" + path + "]." + add);
                } else
                    SystemOut.printDate("timeout (" + (lockTimeout) + " ms) occured while accessing file [" + path + "].");
                return;
            }
        } catch (InterruptedException e) {
        }
    } while (true);
}
Also used : CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) Config(lucee.runtime.config.Config) CFMLFactory(lucee.runtime.CFMLFactory) PageContextImpl(lucee.runtime.PageContextImpl) ConfigWeb(lucee.runtime.config.ConfigWeb)

Example 25 with Config

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

the class CharsetUtil method getWebCharset.

public static Charset getWebCharset() {
    PageContext pc = ThreadLocalPageContext.get();
    if (pc != null)
        return pc.getWebCharset();
    Config config = ThreadLocalPageContext.getConfig();
    if (config != null)
        return config.getWebCharset();
    return CharsetUtil.ISO88591;
}
Also used : Config(lucee.runtime.config.Config) PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext)

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