Example usage for org.apache.wicket.util.collections ClassMetaCache ClassMetaCache

List of usage examples for org.apache.wicket.util.collections ClassMetaCache ClassMetaCache

Introduction

In this page you can find the example usage for org.apache.wicket.util.collections ClassMetaCache ClassMetaCache.

Prototype

ClassMetaCache

Source Link

Usage

From source file:com.github.javawithmarcus.wicket.cdi.NonContextual.java

License:Apache License

private static ClassMetaCache<NonContextual<?>> getCache() {
    ClassMetaCache<NonContextual<?>> meta = cache.get(CDI.current().getBeanManager());
    if (meta == null) {
        synchronized (lock) {
            BeanManager manager = CDI.current().getBeanManager();
            meta = cache.get(manager);//from w  w  w.  j  a  v a 2s .com
            if (meta == null) {
                meta = new ClassMetaCache<>();

                // copy-on-write the cache
                Map<BeanManager, ClassMetaCache<NonContextual<?>>> newCache = new WeakHashMap<>(cache);
                newCache.put(manager, meta);
                cache = Collections.unmodifiableMap(newCache);
            }
        }
    }
    return meta;
}