Search in sources :

Example 21 with CacheConnection

use of lucee.runtime.cache.CacheConnection in project Lucee by lucee.

the class ModernApplicationContext method _initCache.

private void _initCache(Map<Key, CacheConnection> cacheConnections, Iterator<Entry<Key, Object>> it, boolean sub) {
    Entry<Key, Object> e;
    Struct sct;
    CacheConnection cc;
    while (it.hasNext()) {
        e = it.next();
        if (!sub && KeyConstants._function.equals(e.getKey()) || KeyConstants._query.equals(e.getKey()) || KeyConstants._template.equals(e.getKey()) || KeyConstants._object.equals(e.getKey()) || KeyConstants._include.equals(e.getKey()) || KeyConstants._resource.equals(e.getKey()) || KeyConstants._http.equals(e.getKey()) || KeyConstants._file.equals(e.getKey()) || KeyConstants._webservice.equals(e.getKey()))
            continue;
        if (!sub && KeyConstants._connections.equals(e.getKey())) {
            Struct _sct = Caster.toStruct(e.getValue(), null);
            if (_sct != null)
                _initCache(cacheConnections, _sct.entryIterator(), true);
            continue;
        }
        sct = Caster.toStruct(e.getValue(), null);
        if (sct == null)
            continue;
        cc = toCacheConnection(config, e.getKey().getString(), sct, null);
        if (cc != null) {
            cacheConnections.put(e.getKey(), cc);
            Key def = Caster.toKey(sct.get(KeyConstants._default, null), null);
            if (def != null) {
                String n = e.getKey().getString().trim();
                if (KeyConstants._function.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_FUNCTION, n);
                else if (KeyConstants._query.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_QUERY, n);
                else if (KeyConstants._template.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_TEMPLATE, n);
                else if (KeyConstants._object.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_OBJECT, n);
                else if (KeyConstants._include.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_INCLUDE, n);
                else if (KeyConstants._resource.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_RESOURCE, n);
                else if (KeyConstants._http.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_HTTP, n);
                else if (KeyConstants._file.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_FILE, n);
                else if (KeyConstants._webservice.equals(def))
                    defaultCaches.put(Config.CACHE_TYPE_WEBSERVICE, n);
            }
        }
    }
}
Also used : CacheConnection(lucee.runtime.cache.CacheConnection) Key(lucee.runtime.type.Collection.Key) Struct(lucee.runtime.type.Struct)

Aggregations

CacheConnection (lucee.runtime.cache.CacheConnection)21 Struct (lucee.runtime.type.Struct)9 ApplicationException (lucee.runtime.exp.ApplicationException)7 Entry (java.util.Map.Entry)6 Map (java.util.Map)5 DataSource (lucee.runtime.db.DataSource)4 PageException (lucee.runtime.exp.PageException)4 ApplicationContextSupport (lucee.runtime.listener.ApplicationContextSupport)4 StructImpl (lucee.runtime.type.StructImpl)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 lucee.aprint (lucee.aprint)3 ServerCacheConnection (lucee.runtime.cache.ServerCacheConnection)3 ClassDefinition (lucee.runtime.db.ClassDefinition)3 ExpressionException (lucee.runtime.exp.ExpressionException)3 ApplicationContext (lucee.runtime.listener.ApplicationContext)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 CacheConnectionImpl (lucee.runtime.cache.CacheConnectionImpl)2