java.lang.Object
io.helidon.common.context.Contexts
Support for handling 
Context across thread boundaries.- 
Method SummaryModifier and TypeMethodDescriptioncontext()Get context registry associated with current thread.static ContextGlobal context is always present and statically shared in this JVM.static voidrunInContext(Context context, Runnable runnable) Run the runnable in the provided context.static <T> TrunInContext(Context context, Callable<T> callable) Run the callable in the provided context.static <T> TrunInContextWithThrow(Context context, Callable<T> callable) Run the callable in the provided context throwing any exception from its execution.static ExecutorServicewrap(ExecutorService toWrap) Wrap an executor service to correctly propagate context to its threads.static ScheduledExecutorServicewrap(ScheduledExecutorService toWrap) Wrap a scheduled executor service to correctly propagate context to its threads.
- 
Method Details- 
contextGet context registry associated with current thread.- Returns:
- context that is associated with current thread or empty if none is
 
- 
globalContextGlobal context is always present and statically shared in this JVM. This is similar to Singleton scope when using an injection engine. Global context is also used as a parent for newly created contexts, unless you specify a parent usingContext.Builder.parent(Context). Registering any instance in this context will make it available to any component in this JVM.- Returns:
- global context instance, never null
 
- 
wrapWrap an executor service to correctly propagate context to its threads.- Parameters:
- toWrap- executor service
- Returns:
- a new executor service wrapping the provided one
 
- 
wrapWrap a scheduled executor service to correctly propagate context to its threads. Note that all scheduled methods are going to run in context of the thread scheduling the tasks.- Parameters:
- toWrap- executor service
- Returns:
- a new executor service wrapping the provided one
 
- 
runInContextRun the runnable in the provided context. The runnable can usecontext()to retrieve the context.- Parameters:
- context- context to run in
- runnable- runnable to execute in context
 
- 
runInContextRun the callable in the provided context. The callable can usecontext()to retrieve the context.- Type Parameters:
- T- return type of the callable
- Parameters:
- context- context to run in
- callable- callable to execute in context
- Returns:
- the result of the callable
- Throws:
- RuntimeException- in case the- Callable.call()threw a runtime exception
 
- 
runInContextWithThrowRun the callable in the provided context throwing any exception from its execution. The callable can usecontext()to retrieve the context.- Type Parameters:
- T- return type of the callable
- Parameters:
- context- context to run in
- callable- callable to execute in context
- Returns:
- the result of the callable
- Throws:
- Exception- If thrown in- Callable.call()
 
 
-