public final class ClassLoaders extends Object
Modifier and Type | Method and Description |
---|---|
static ClassLoader |
inferDefault()
Infer a default class loader.
|
static ClassLoader |
inferDefault(Class<?> refClass)
Infer a default class loader.
|
static ClassLoaderContext |
pushContext(ClassLoader loader)
Use the specified class loader for the current thread's context class loader.
|
static ClassLoaderContext |
pushContext(Thread thread,
ClassLoader loader)
Use the specified class loader for the given thread's context class loader.
|
public static ClassLoader inferDefault()
public static ClassLoader inferDefault(Class<?> refClass)
refClass
- a reference class to use for looking up the class loader. If there is not
a context class loader on the current thread, the class loader used to load
this class is returned.public static ClassLoaderContext pushContext(ClassLoader loader)
ClassLoaderContext context = ClassLoaders.pushContext(classLoader);
try {
// some code with classLoader as the current loader
} finally {
context.pop();
}
loader
- The class loader to use.public static ClassLoaderContext pushContext(Thread thread, ClassLoader loader)
thread
- The thread whose class loader should be modified.loader
- The class loader to use.pushContext(ClassLoader)
Copyright © 2016 GroupLens Research. All rights reserved.