Interface ContextManager.Builder
- Enclosing interface:
- ContextManager
public static interface ContextManager.Builder
Use this class to configure instances of
ContextManager
.-
Method Summary
Modifier and TypeMethodDescriptionLoad all discoverableContextManagerExtension
instances via theServiceLoader
mechanism on the current thread-contextClassLoader
(unless overridden byforClassLoader(ClassLoader)
).Load all discoverableThreadContextProvider
instances via theServiceLoader
mechanism on the current thread-contextClassLoader
(unless overridden byforClassLoader(ClassLoader)
).build()
Creates a newContextManager
with the specified configuration.forClassLoader
(ClassLoader classLoader) Use the givenClassLoader
foraddDiscoveredThreadContextProviders()
instead of the current thread-contextClassLoader
.withContextManagerExtensions
(ContextManagerExtension... extensions) Use the specifiedContextManagerExtension
instances.withDefaultExecutorService
(ExecutorService executorService) Use the givenExecutorService
to execute async tasks for contextualisedCompletableFuture
andCompletionStage
when no executor is specified.withThreadContextProviders
(ThreadContextProvider... providers) Use the specifiedThreadContextProvider
instances.
-
Method Details
-
withThreadContextProviders
Use the specifiedThreadContextProvider
instances.- Parameters:
providers
- theThreadContextProvider
instances to use.- Returns:
- this builder
-
addDiscoveredContextManagerExtensions
ContextManager.Builder addDiscoveredContextManagerExtensions()Load all discoverableContextManagerExtension
instances via theServiceLoader
mechanism on the current thread-contextClassLoader
(unless overridden byforClassLoader(ClassLoader)
).- Returns:
- this builder
-
withContextManagerExtensions
Use the specifiedContextManagerExtension
instances.- Parameters:
extensions
- theContextManagerExtension
instances to use.- Returns:
- this builder
-
addDiscoveredThreadContextProviders
ContextManager.Builder addDiscoveredThreadContextProviders()Load all discoverableThreadContextProvider
instances via theServiceLoader
mechanism on the current thread-contextClassLoader
(unless overridden byforClassLoader(ClassLoader)
).- Returns:
- this builder
-
forClassLoader
Use the givenClassLoader
foraddDiscoveredThreadContextProviders()
instead of the current thread-contextClassLoader
.- Parameters:
classLoader
- theClassLoader
to use foraddDiscoveredThreadContextProviders()
- Returns:
- this builder
-
withDefaultExecutorService
Use the givenExecutorService
to execute async tasks for contextualisedCompletableFuture
andCompletionStage
when no executor is specified.- Parameters:
executorService
- theExecutorService
to use for async tasks when no executor is specified.- Returns:
- this builder
-
build
ContextManager build()Creates a new
ContextManager
with the specified configuration.Creating a
ContextManager
will load and invoke all relatedContextManagerExtension
as described in its documentation.- Returns:
- a new
ContextManager
with the specified configuration.
-