Package org.jboss.threads
Interface ContextHandler<T>
-
- Type Parameters:
T- the class of the context to capture
public interface ContextHandler<T>A handler for propagating context from a task submitter to a task execution.
-
-
Field Summary
Fields Modifier and Type Field Description static ContextHandler<?>NONEThe context handler which captures no context.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TcaptureContext()Capture the current context from the submitting thread.voidrunWith(Runnable task, T context)Run the given task with the given captured context.
-
-
-
Field Detail
-
NONE
static final ContextHandler<?> NONE
The context handler which captures no context.
-
-
Method Detail
-
captureContext
T captureContext()
Capture the current context from the submitting thread.- Returns:
- the captured context
-
runWith
void runWith(Runnable task, T context)
Run the given task with the given captured context. The context should be cleared when this method returns.- Parameters:
task- the task to run (notnull)context- the context returned fromcaptureContext()
-
-