优先判断缓存容器

This commit is contained in:
wusheng 2016-08-02 23:00:11 +08:00
parent d6507d2fea
commit f3f1af7d6e
1 changed files with 5 additions and 4 deletions

View File

@ -25,15 +25,16 @@ public class InterceptorInstanceLoader {
public static <T> T load(String className, ClassLoader targetClassLoader)
throws InvocationTargetException, IllegalAccessException, InstantiationException, ClassNotFoundException {
if (InterceptorInstanceLoader.class.getClassLoader().equals(targetClassLoader)) {
return (T) targetClassLoader.loadClass(className).newInstance();
}
String instanceKey = className + "_OF_" + targetClassLoader.getClass().getName() + "@" + Integer.toHexString(targetClassLoader.hashCode());
Object inst = INSTANCE_CACHE.get(instanceKey);
if (inst != null) {
return (T) inst;
}
if (InterceptorInstanceLoader.class.getClassLoader().equals(targetClassLoader)) {
return (T) targetClassLoader.loadClass(className).newInstance();
}
instanceLoadLock.lock();
try {
try {