Interface ContextManager<T>
-
- All Known Subinterfaces:
ClearableContextManager<T>
public interface ContextManager<T>The contract for a ContextManager Service.Implementations can be registered by providing a fully qualified class name in a service file called:
"/META-INF/services/nl.talsmasoftware.context.ContextManager"
That will take care of any active context being captured inContextSnapshotinstances managed by theContextManagersutility class.
Note: Make sure your implementation has a default (no-argument) constructor.A context manager is required to notify registered ContextObserver instances of context updates.
The AbstractThreadLocalContext already notifies these observers.
Other implementations can use the ContextManagers.onActivate(Class, Object, Object) and ContextManagers.onDeactivate(Class, Object, Object) methods to notify the appropriate context observers.- Author:
- Sjoerd Talsma
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Context<T>getActiveContext()The currently active context, ornullif no context is active.Context<T>initializeNewContext(T value)Initialize a new context containing the specifiedvalue.
-
-
-
Method Detail
-
initializeNewContext
Context<T> initializeNewContext(T value)
Initialize a new context containing the specifiedvalue.Whether the value is allowed to be
nullis up to the implementation.- Parameters:
value- The value to initialize a new context for.- Returns:
- The new active context containing the specified value which should be closed by the caller at the end of its lifecycle.
-
-