public final class ThreadContextHelper extends Object
Constructor and Description |
---|
ThreadContextHelper() |
Modifier and Type | Method and Description |
---|---|
void |
clearCurrentThread()
Remove Context from current Thread.
|
void |
setOnCurrentThread(Context context)
Set Context on current Thread.
|
static <T> T |
withContext(Context context, Callable<T> callable)
Run a Callable with a Context.
|
static void |
withContext(Context context, Runnable runnable)
Run a Runnable with a Context.
|
public static void withContext(Context context, Runnable runnable)
Use a ThreadContextHelper
instance, see its methods documentation.
context
- Context
runnable
- Runnable
public static <T> T withContext(Context context, Callable<T> callable) throws Exception
Use a ThreadContextHelper
instance, see its methods documentation.
T
- Parameterized type of the Callable result
context
- Context
callable
- Callable
Exception
- if the Callable was unable to compute a result
public void setOnCurrentThread(Context context)
In order:
ClassLoader
.ClassLoader
.Headers.Names.X_WERVAL_REQUEST_ID
key. Headers.Names.X_WERVAL_CLIENT_IP
key if enabled in the configuration. context
- Context
public void clearCurrentThread()
In order:
ClassLoader
to previous one.