Package io.mats3
Class MatsFactory.ContextLocal
java.lang.Object
io.mats3.MatsFactory.ContextLocal
- Enclosing interface:
- MatsFactory
Provides ThreadLocal access to attributes from the
MatsInitiator.MatsInitiate
initiate context and MatsStage
process context - currently getAttribute(Class, String...)
, which can provide you with the
transactionally demarcated SQL Connection if the Mats implementation provides such.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Optional<T>
getAttribute
(Class<T> type, String... name) Provides a ThreadLocal-accessible variant of theProcessContext.getAttribute(..)
andMatsInitiate.getAttribute(..)
methods: If the executing thread is within aMats initiation
, or is currently processing aMatsStage
, the return value will be the same as if the relevantgetAttribute(..)
method was invoked.
-
Constructor Details
-
ContextLocal
public ContextLocal()
-
-
Method Details
-
getAttribute
Provides a ThreadLocal-accessible variant of theProcessContext.getAttribute(..)
andMatsInitiate.getAttribute(..)
methods: If the executing thread is within aMats initiation
, or is currently processing aMatsStage
, the return value will be the same as if the relevantgetAttribute(..)
method was invoked. Otherwise, if the current thread is not processing a stage or performing an initiation,Optional.empty()
is returned. If the Mats implementation has a transactional SQL Connection, it shall be available byContextLocal.getAttribute(Connection.class)
when in the relevant contexts (init or stage).- Type Parameters:
T
- The type of the attribute.- Parameters:
type
- The expected type of the attributename
- The (optional) (hierarchical) name(s) of the attribute.- Returns:
- Optional of the attribute in question - if not in relevant context,
Optional.empty()
is always returned. - See Also:
-