com.atlassian.plugin.util
Class ContextClassLoaderSwitchingUtil
java.lang.Object
com.atlassian.plugin.util.ContextClassLoaderSwitchingUtil
public class ContextClassLoaderSwitchingUtil
- extends java.lang.Object
Utility to run Runnable implementations in a different ClassLoader.
- Since:
- 2.5.0
|
Method Summary |
static
|
runInContext(java.lang.ClassLoader newClassLoader,
java.util.concurrent.Callable<T> callable)
Executes the provided Callable implementation in the specified ClassLoader. |
static void |
runInContext(java.lang.ClassLoader newClassLoader,
java.lang.Runnable runnable)
Executes the provided Runnable implementation in the specified ClassLoader. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ContextClassLoaderSwitchingUtil
public ContextClassLoaderSwitchingUtil()
runInContext
public static void runInContext(java.lang.ClassLoader newClassLoader,
java.lang.Runnable runnable)
- Executes the provided
Runnable implementation in the specified ClassLoader.
Utilises the ClassLoaderStack.push(java.lang.ClassLoader) method to save the old ClassLoader and
set the one specified as newClassLoader. ClassLoaderStack.pop() is
called in a finally block to ensure the ClassLoader is set back to the original one.
- Parameters:
newClassLoader - The ClassLoader to run the specified Runnable in.runnable - The implementation to be run in the specified ClassLoader
runInContext
public static <T> T runInContext(java.lang.ClassLoader newClassLoader,
java.util.concurrent.Callable<T> callable)
throws java.lang.Exception
- Executes the provided
Callable implementation in the specified ClassLoader.
Utilises the ClassLoaderStack.push(java.lang.ClassLoader) method to save the old ClassLoader and
set the one specified as newClassLoader. ClassLoaderStack.pop() is
called in a finally block to ensure the ClassLoader is set back to the original one.
- Parameters:
newClassLoader - The ClassLoader to run the specified Runnable in.callable - The implementation to be run in the specified ClassLoader
- Returns:
- the result of the
Callable
- Throws:
java.lang.Exception- Since:
- 2.7.0
Copyright © 2013 Atlassian. All Rights Reserved.