Search in sources :

Example 1 with ClassMetaCache

use of org.apache.wicket.util.collections.ClassMetaCache in project wicket by apache.

the class NonContextual method getCache.

private static ClassMetaCache<NonContextual<?>> getCache() {
    ClassMetaCache<NonContextual<?>> meta = cache.get(BeanManagerLookup.lookup());
    if (meta == null) {
        synchronized (lock) {
            BeanManager manager = BeanManagerLookup.lookup();
            meta = cache.get(manager);
            if (meta == null) {
                meta = new ClassMetaCache<NonContextual<?>>();
                // copy-on-write the cache
                Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<BeanManager, ClassMetaCache<NonContextual<?>>>(cache);
                newCache.put(manager, meta);
                cache = Collections.unmodifiableMap(newCache);
            }
        }
    }
    return meta;
}
Also used : ClassMetaCache(org.apache.wicket.util.collections.ClassMetaCache) BeanManager(javax.enterprise.inject.spi.BeanManager) WeakHashMap(java.util.WeakHashMap)

Aggregations

WeakHashMap (java.util.WeakHashMap)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 ClassMetaCache (org.apache.wicket.util.collections.ClassMetaCache)1