Search in sources :

Example 1 with DelegatingClassLoader

use of com.google.gerrit.server.plugins.DelegatingClassLoader in project gerrit by GerritCodeReview.

the class DynamicOptions method getMergedClassLoader.

protected ClassLoader getMergedClassLoader(ClassLoader beanCl, ClassLoader dynamicBeanCl) {
    Map<ClassLoader, WeakReference<ClassLoader>> mergedClByCl = mergedClByCls.get(beanCl);
    if (mergedClByCl == null) {
        mergedClByCl = Collections.synchronizedMap(new WeakHashMap<>());
        mergedClByCls.put(beanCl, mergedClByCl);
    }
    WeakReference<ClassLoader> mergedClRef = mergedClByCl.get(dynamicBeanCl);
    ClassLoader mergedCl = null;
    if (mergedClRef != null) {
        mergedCl = mergedClRef.get();
    }
    if (mergedCl == null) {
        mergedCl = new DelegatingClassLoader(beanCl, dynamicBeanCl);
        mergedClByCl.put(dynamicBeanCl, new WeakReference<>(mergedCl));
    }
    return mergedCl;
}
Also used : WeakReference(java.lang.ref.WeakReference) DelegatingClassLoader(com.google.gerrit.server.plugins.DelegatingClassLoader) DelegatingClassLoader(com.google.gerrit.server.plugins.DelegatingClassLoader) WeakHashMap(java.util.WeakHashMap)

Aggregations

DelegatingClassLoader (com.google.gerrit.server.plugins.DelegatingClassLoader)1 WeakReference (java.lang.ref.WeakReference)1 WeakHashMap (java.util.WeakHashMap)1