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 discoverableContextManagerExtensioninstances via theServiceLoadermechanism on the current thread-contextClassLoader(unless overridden byforClassLoader(ClassLoader)).Load all discoverableThreadContextProviderinstances via theServiceLoadermechanism on the current thread-contextClassLoader(unless overridden byforClassLoader(ClassLoader)).build()Creates a newContextManagerwith the specified configuration.forClassLoader(ClassLoader classLoader) Use the givenClassLoaderforaddDiscoveredThreadContextProviders()instead of the current thread-contextClassLoader.withContextManagerExtensions(ContextManagerExtension... extensions) Use the specifiedContextManagerExtensioninstances.withDefaultExecutorService(ExecutorService executorService) Use the givenExecutorServiceto execute async tasks for contextualisedCompletableFutureandCompletionStagewhen no executor is specified.withThreadContextProviders(ThreadContextProvider... providers) Use the specifiedThreadContextProviderinstances.
-
Method Details
-
withThreadContextProviders
Use the specifiedThreadContextProviderinstances.- Parameters:
providers- theThreadContextProviderinstances to use.- Returns:
- this builder
-
addDiscoveredContextManagerExtensions
ContextManager.Builder addDiscoveredContextManagerExtensions()Load all discoverableContextManagerExtensioninstances via theServiceLoadermechanism on the current thread-contextClassLoader(unless overridden byforClassLoader(ClassLoader)).- Returns:
- this builder
-
withContextManagerExtensions
Use the specifiedContextManagerExtensioninstances.- Parameters:
extensions- theContextManagerExtensioninstances to use.- Returns:
- this builder
-
addDiscoveredThreadContextProviders
ContextManager.Builder addDiscoveredThreadContextProviders()Load all discoverableThreadContextProviderinstances via theServiceLoadermechanism on the current thread-contextClassLoader(unless overridden byforClassLoader(ClassLoader)).- Returns:
- this builder
-
forClassLoader
Use the givenClassLoaderforaddDiscoveredThreadContextProviders()instead of the current thread-contextClassLoader.- Parameters:
classLoader- theClassLoaderto use foraddDiscoveredThreadContextProviders()- Returns:
- this builder
-
withDefaultExecutorService
Use the givenExecutorServiceto execute async tasks for contextualisedCompletableFutureandCompletionStagewhen no executor is specified.- Parameters:
executorService- theExecutorServiceto use for async tasks when no executor is specified.- Returns:
- this builder
-
build
ContextManager build()Creates a new
ContextManagerwith the specified configuration.Creating a
ContextManagerwill load and invoke all relatedContextManagerExtensionas described in its documentation.- Returns:
- a new
ContextManagerwith the specified configuration.
-