X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2FClassLoaderUtils.java;h=6e65b03658f58b55b3268dd03d9af9fffb49fbc7;hb=1eb87c819cc6881ca7be74917a5d0bb7a9cad41f;hp=6f84ef81ff8a115adcec1f4aae5e14044014844d;hpb=60bf2afa4363039a64ccd29837fd611bae40278d;p=yangtools.git
diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java b/common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java
index 6f84ef81ff..6e65b03658 100644
--- a/common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java
+++ b/common/util/src/main/java/org/opendaylight/yangtools/util/ClassLoaderUtils.java
@@ -11,53 +11,50 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
import com.google.common.base.Supplier;
-
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Callable;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ClassLoaderUtils {
private static final Logger LOG = LoggerFactory.getLogger(ClassLoaderUtils.class);
+ private static final Splitter DOT_SPLITTER = Splitter.on('.');
private ClassLoaderUtils() {
throw new UnsupportedOperationException("Utility class");
}
/**
- *
* Runs {@link Supplier} with provided {@link ClassLoader}.
*
- * Invokes supplies function and makes sure that original {@link ClassLoader}
+ *
Invokes supplies function and makes sure that original {@link ClassLoader}
* is context {@link ClassLoader} after execution.
*
* @param cls {@link ClassLoader} to be used.
* @param function Function to be executed.
* @return Result of supplier invocation.
- *
*/
public static V withClassLoader(final ClassLoader cls, final Supplier function) {
checkNotNull(cls, "Classloader should not be null");
checkNotNull(function, "Function should not be null");
- final ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
+ final Thread currentThread = Thread.currentThread();
+ final ClassLoader oldCls = currentThread.getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(cls);
+ currentThread.setContextClassLoader(cls);
return function.get();
} finally {
- Thread.currentThread().setContextClassLoader(oldCls);
+ currentThread.setContextClassLoader(oldCls);
}
}
/**
- *
* Runs {@link Callable} with provided {@link ClassLoader}.
*
* Invokes supplies function and makes sure that original {@link ClassLoader}
@@ -66,36 +63,31 @@ public final class ClassLoaderUtils {
* @param cls {@link ClassLoader} to be used.
* @param function Function to be executed.
* @return Result of callable invocation.
- *
*/
public static V withClassLoader(final ClassLoader cls, final Callable function) throws Exception {
checkNotNull(cls, "Classloader should not be null");
checkNotNull(function, "Function should not be null");
- final ClassLoader oldCls = Thread.currentThread().getContextClassLoader();
+ final Thread currentThread = Thread.currentThread();
+ final ClassLoader oldCls = currentThread.getContextClassLoader();
try {
- Thread.currentThread().setContextClassLoader(cls);
+ currentThread.setContextClassLoader(cls);
return function.call();
} finally {
- Thread.currentThread().setContextClassLoader(oldCls);
+ currentThread.setContextClassLoader(oldCls);
}
}
- public static Object construct(final Constructor extends Object> constructor, final List