Package nl.talsmasoftware.context
context-propagation concepts in this library
Context
A context contains
a value.
There can be one active context per thread. A context remains active until it is closed or another context
is activated in that thread.
An AbstractThreadLocalContext base class is provided that supports nested contexts and provides predictable behaviour for out-of-order closing.
ContextManager
Manages the active context. Can initialize a new context and provides access to the active context.
ContextSnapshot
A snapshot contains the current value from all known context managers.
These values can be reactivated in another thread.
Reactivated snapshots must be closed to avoid leaking context.
All context aware utility classes in this library are tested to make sure they reactivate and close snapshots in a safe way.
ContextManagers
Utility class that detects available context managers and lets you take a snapshot of all active contexts at once.
- Author:
- Sjoerd Talsma
-
Interface Summary Interface Description Context<T> A context can be anything that needs to be maintained on the 'current thread' level.ContextManager<T> The contract for a ContextManager Service.ContextSnapshot Interface for a 'snapshot' that can capture the (then-) 'active context' from all known registeredContextManagerimplementations.
Obtain a new snapshot by callingContextManagers.createContextSnapshot()which will include a snapshot for all supportedContexttypes through their respectivemanagers. -
Class Summary Class Description ContextManagers Utility class to allow concurrent systems totake snapshots of all contextsfrom knownContextManagerimplementations.