Package org.jboss.util.loading
Class ContextClassLoaderSwitcher.SwitchContext
- java.lang.Object
-
- org.jboss.util.loading.ContextClassLoaderSwitcher.SwitchContext
-
- Enclosing class:
- ContextClassLoaderSwitcher
public class ContextClassLoaderSwitcher.SwitchContext extends java.lang.Object
A helper class to remember the original classloader and avoid continually retrieveing the current thread.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.ClassLoader
currentCL
The current classloaderprivate java.lang.Thread
currentThread
The current threadprivate java.lang.ClassLoader
origCL
The original classloader
-
Constructor Summary
Constructors Modifier Constructor Description private
SwitchContext()
private
SwitchContext(java.lang.ClassLoader cl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
forceReset()
Force a reset back to the original classloader, useful when somebody else might have changed the thread context classloader so we cannot optimizejava.lang.ClassLoader
getCurrentClassLoader()
java.lang.ClassLoader
getOriginalClassLoader()
java.lang.Thread
getThread()
void
reset()
Reset back to the original classloader, only when it has changed.void
setClassLoader(java.lang.ClassLoader cl)
Change the context classloader
-
-
-
Method Detail
-
getThread
public java.lang.Thread getThread()
- Returns:
- the current thread
-
getOriginalClassLoader
public java.lang.ClassLoader getOriginalClassLoader()
- Returns:
- the original classloader
-
getCurrentClassLoader
public java.lang.ClassLoader getCurrentClassLoader()
- Returns:
- the current classloader (as set through this class).
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader cl)
Change the context classloaderThe operation is ignored if the classloader is null or has not changed
- Parameters:
cl
- the new classloader
-
reset
public void reset()
Reset back to the original classloader, only when it has changed.
-
forceReset
public void forceReset()
Force a reset back to the original classloader, useful when somebody else might have changed the thread context classloader so we cannot optimize
-
-