Search in sources :

Example 16 with PageContext

use of lucee.runtime.PageContext in project Lucee by lucee.

the class ScriptEngineImpl method get.

@Override
public Object get(String key) {
    PageContext oldPC = ThreadLocalPageContext.get();
    PageContext pc = getPageContext(getContext());
    try {
        return pc.undefinedScope().get(KeyImpl.init(key), null);
    } finally {
        releasePageContext(pc, oldPC);
    }
}
Also used : PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext)

Example 17 with PageContext

use of lucee.runtime.PageContext in project Lucee by lucee.

the class CacheResourceProvider method getCache.

public Cache getCache() {
    PageContext pc = ThreadLocalPageContext.get();
    Cache c = CacheUtil.getDefault(pc, Config.CACHE_TYPE_RESOURCE, null);
    if (c == null) {
        // CFMLEngineImpl e=null;
        if (defaultCache == null) {
            defaultCache = new RamCache().init(0, 0, RamCache.DEFAULT_CONTROL_INTERVAL);
        }
        c = defaultCache;
    }
    if (!inits.contains(c.hashCode())) {
        String k = toKey("null", "");
        try {
            if (!c.contains(k)) {
                CacheResourceCore value = new CacheResourceCore(CacheResourceCore.TYPE_DIRECTORY, null, "");
                c.put(k, value, Constants.LONG_ZERO, Constants.LONG_ZERO);
            }
        } catch (IOException e) {
        // simply ignore
        }
        inits.add(c.hashCode());
    }
    return c;
}
Also used : PageContext(lucee.runtime.PageContext) ThreadLocalPageContext(lucee.runtime.engine.ThreadLocalPageContext) IOException(java.io.IOException) RamCache(lucee.runtime.cache.ram.RamCache) Cache(lucee.commons.io.cache.Cache) RamCache(lucee.runtime.cache.ram.RamCache)

Example 18 with PageContext

use of lucee.runtime.PageContext in project Lucee by lucee.

the class ThreadTag method getThreadScope.

public static Threads getThreadScope(PageContext pc, Key name, int level) {
    Threads t = null;
    // current
    if ((level & LEVEL_CURRENT) > 0) {
        t = pc.getThreadScope(name);
        if (t != null)
            return t;
    }
    // parent
    if ((level & LEVEL_PARENTS) > 0) {
        PageContext parent = pc.getParentPageContext();
        while (parent != null) {
            t = parent.getThreadScope(name);
            if (t != null)
                return t;
            parent = parent.getParentPageContext();
        }
    }
    // children
    if ((level & LEVEL_KIDS) > 0 && pc.hasFamily()) {
        t = getKidsThreadScope(((PageContextImpl) pc).getChildPageContexts(), name);
        if (t != null)
            return t;
    }
    return t;
}
Also used : Threads(lucee.runtime.type.scope.Threads) PageContext(lucee.runtime.PageContext) PageContextImpl(lucee.runtime.PageContextImpl)

Example 19 with PageContext

use of lucee.runtime.PageContext in project Lucee by lucee.

the class ThreadTag method getKidsThreadScope.

private static Threads getKidsThreadScope(List<PageContext> pageContexts, Key name) {
    if (pageContexts == null || pageContexts.isEmpty())
        return null;
    Threads t;
    Iterator<PageContext> it = pageContexts.iterator();
    PageContext pc;
    while (it.hasNext()) {
        pc = it.next();
        t = pc.getThreadScope(name);
        if (t != null)
            return t;
        t = getKidsThreadScope(((PageContextImpl) pc).getChildPageContexts(), name);
        return t;
    }
    return null;
}
Also used : Threads(lucee.runtime.type.scope.Threads) PageContext(lucee.runtime.PageContext) PageContextImpl(lucee.runtime.PageContextImpl)

Example 20 with PageContext

use of lucee.runtime.PageContext in project Lucee by lucee.

the class ThreadTag method getKidsThreadScopeNames.

private static void getKidsThreadScopeNames(List<PageContext> pageContexts, java.util.Collection<String> result, int level) {
    if (pageContexts == null || pageContexts.isEmpty())
        return;
    String[] names = null;
    Iterator<PageContext> it = pageContexts.iterator();
    PageContext pc;
    while (it.hasNext()) {
        pc = it.next();
        names = pc.getThreadScopeNames();
        if (names != null)
            for (int i = 0; i < names.length; i++) {
                result.add(names[i]);
            }
        getKidsThreadScopeNames(((PageContextImpl) pc).getChildPageContexts(), result, level + 1);
    }
}
Also used : PageContext(lucee.runtime.PageContext)

Aggregations

PageContext (lucee.runtime.PageContext)44 ThreadLocalPageContext (lucee.runtime.engine.ThreadLocalPageContext)32 PageException (lucee.runtime.exp.PageException)11 Component (lucee.runtime.Component)7 PageContextImpl (lucee.runtime.PageContextImpl)6 IOException (java.io.IOException)5 Key (lucee.runtime.type.Collection.Key)5 Pair (lucee.commons.lang.Pair)4 ConfigWeb (lucee.runtime.config.ConfigWeb)4 Entry (java.util.Map.Entry)3 CFMLEngine (lucee.loader.engine.CFMLEngine)3 CFMLFactory (lucee.runtime.CFMLFactory)3 CFMLFactoryImpl (lucee.runtime.CFMLFactoryImpl)3 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)3 ArrayList (java.util.ArrayList)2 Cookie (javax.servlet.http.Cookie)2 TypeMapping (javax.xml.rpc.encoding.TypeMapping)2 DevNullOutputStream (lucee.commons.io.DevNullOutputStream)2 ComponentScope (lucee.runtime.ComponentScope)2 Config (lucee.runtime.config.Config)2