public class

ContextClassLoaderSwitchingUtil

extends Object
java.lang.Object
   ↳ com.atlassian.plugin.util.ContextClassLoaderSwitchingUtil

Class Overview

Utility to run Runnable implementations in a different ClassLoader.

Summary

Public Constructors
ContextClassLoaderSwitchingUtil()
Public Methods
static void runInContext(ClassLoader newClassLoader, Runnable runnable)
Executes the provided Runnable implementation in the specified ClassLoader.
static <T> T runInContext(ClassLoader newClassLoader, Callable<T> callable)
Executes the provided Callable implementation in the specified ClassLoader.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ContextClassLoaderSwitchingUtil ()

Public Methods

public static void runInContext (ClassLoader newClassLoader, Runnable runnable)

Executes the provided Runnable implementation in the specified ClassLoader.

Utilises the push(ClassLoader) method to save the old ClassLoader and set the one specified as newClassLoader. 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

public static T runInContext (ClassLoader newClassLoader, Callable<T> callable)

Executes the provided Callable implementation in the specified ClassLoader.

Utilises the push(ClassLoader) method to save the old ClassLoader and set the one specified as newClassLoader. 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
Throws
Exception