Class ThreadContext
- java.lang.Object
-
- org.exoplatform.container.component.ThreadContext
-
public class ThreadContext extends Object
This component contains all the variables of type
ThreadLocalhold by aThreadContextHolderThis component has not been designed to be thread safe so ensure that you create a new instance each time you use it. Moreover for security reason, when theSecurityManageris installed we check theRuntimePermissionmanageThreadLocal only within the constructor of a ThreadContext.- Version:
- $Id$
- Author:
- Nicolas Filotto
-
-
Constructor Summary
Constructors Constructor Description ThreadContext(ThreadLocal<?>... threadLocals)Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ThreadContextmerge(List<ThreadContext> contexts)Merges all the providedThreadContextinto onevoidpush()Pushes values stored into memory into all the Thread Local variables and keeps previous values to be able to restore old statevoidrestore()Restores the old values of all the Thread Local variablesvoidstore()Stores into memory the current values of all the Thread Local variables
-
-
-
Constructor Detail
-
ThreadContext
public ThreadContext(ThreadLocal<?>... threadLocals)
Default constructor- Parameters:
threadLocals- the thread local variables whose value must be transfered from one thread to another to avoid critical issues.- Throws:
SecurityException- In case the security manager is installed and the calling stack doesn't have theRuntimePermissionmanageThreadLocal
-
-
Method Detail
-
merge
public static ThreadContext merge(List<ThreadContext> contexts)
Merges all the providedThreadContextinto one- Parameters:
contexts- theThreadContextto merge- Returns:
- a
ThreadContextrepresenting all the providedThreadContextinstance
-
store
public void store()
Stores into memory the current values of all the Thread Local variables
-
push
public void push()
Pushes values stored into memory into all the Thread Local variables and keeps previous values to be able to restore old state
-
restore
public void restore()
Restores the old values of all the Thread Local variables
-
-