/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  java.lang.Class
 *  java.lang.ClassLoader
 *  java.lang.Exception
 *  java.lang.Object
 *  java.lang.String
 *  java.lang.Thread
 *  java.lang.ThreadLocal
 *  java.lang.ref.WeakReference
 */
package org.dom4j.util;

import java.lang.ref.WeakReference;
import org.dom4j.util.SingletonStrategy;

public class PerThreadSingleton
implements SingletonStrategy {
    private ThreadLocal perThreadCache = new ThreadLocal();
    private String singletonClassName = null;

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    @Override
    public Object instance() {
        Object object;
        WeakReference weakReference = (WeakReference)this.perThreadCache.get();
        if (weakReference != null && weakReference.get() != null) {
            return weakReference.get();
        }
        try {
            Object object2;
            object = object2 = Thread.currentThread().getContextClassLoader().loadClass(this.singletonClassName).newInstance();
        }
        catch (Exception var2_4) {
            try {
                Object object3;
                object = object3 = Class.forName((String)this.singletonClassName).newInstance();
            }
            catch (Exception var3_6) {
                object = null;
            }
        }
        this.perThreadCache.set((Object)new WeakReference(object));
        return object;
    }

    @Override
    public void reset() {
        this.perThreadCache = new ThreadLocal();
    }

    @Override
    public void setSingletonClassName(String string2) {
        this.singletonClassName = string2;
    }
}

