public enum ThreadContextHook extends Enum<ThreadContextHook>
Writing a new context hook:
1) Create an implementation of the interface ThreadContextFollower
2) Create a file in /resources/META-INF/services called "com.hubspot.java.thread.ThreadContextFollower"
3) Add a line containing the full class name of your implementation.
4) Profit!
Adding a new place to thread the context:
1) Save ThreadContextHook.Context currentContext = ThreadContextHook.INSTANCE.buildThreadContext(namePrefix) when about to leave the current thread.
2) In the other thread, call ThreadContextHook.INSTANCE.initializeThreadContext(namePrefix, currentContext) to hydreate the old context in the current thread.
| Modifier and Type | Class and Description |
|---|---|
static class |
ThreadContextHook.Context |
| Enum Constant and Description |
|---|
INSTANCE |
| Modifier and Type | Method and Description |
|---|---|
ThreadContextHook.Context |
buildThreadContext() |
ThreadContextHook.Context |
buildThreadContext(String namePrefix) |
void |
clearThreadContext(String namePrefix,
ThreadContextHook.Context context) |
void |
clearThreadContext(ThreadContextHook.Context context) |
ThreadContextHook.Context |
initializeThreadContext(String namePrefix,
ThreadContextHook.Context context) |
ThreadContextHook.Context |
initializeThreadContext(ThreadContextHook.Context context) |
static ThreadContextHook |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ThreadContextHook[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ThreadContextHook INSTANCE
public static ThreadContextHook[] values()
for (ThreadContextHook c : ThreadContextHook.values()) System.out.println(c);
public static ThreadContextHook valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic ThreadContextHook.Context buildThreadContext(String namePrefix)
public ThreadContextHook.Context initializeThreadContext(String namePrefix, ThreadContextHook.Context context)
public void clearThreadContext(String namePrefix, ThreadContextHook.Context context)
public ThreadContextHook.Context buildThreadContext()
public void clearThreadContext(ThreadContextHook.Context context)
public ThreadContextHook.Context initializeThreadContext(ThreadContextHook.Context context)
Copyright © 2020. All rights reserved.