Class FlowContextCarrier
FlowContext from outside the aspect package.
FlowContextHolder deliberately stays package-private: it is an
internal detail of LoggedAspect, not part of this library's public
API. But carrying a call chain across a boundary that is not a plain Java
thread hand-off — a Kafka or RabbitMQ message, for example — requires code
outside this package to read the current FlowContext on a
producing thread and re-establish it on a consuming thread, in modules
(this library's own kafka/rabbitmq packages today, a
consuming application's own carrier tomorrow) that have no reason to see
anything else FlowContextHolder exposes.
This class exists to be that one, narrow, intentional door: two
methods, mirroring FlowContextHolder.snapshot() and
FlowContextHolder.adopt(com.fayupable.logged.core.model.FlowContext), and nothing else. It does not replace
FlowContextHolder; it is a thin, public façade in front of it,
kept in the same package specifically so it can call it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Runnableadopt(FlowContext context) Makescontextthe activeFlowContexton the calling thread and returns aRunnablethat undoes this, restoring whatever context was active before this call.static FlowContextcapture()Returns theFlowContextcurrently active on this thread, ornullif no@Loggedcall is in progress on this thread.
-
Method Details
-
capture
Returns theFlowContextcurrently active on this thread, ornullif no@Loggedcall is in progress on this thread.- Returns:
- the active flow context, or
nullif none is active
-
adopt
Makescontextthe activeFlowContexton the calling thread and returns aRunnablethat undoes this, restoring whatever context was active before this call.- Parameters:
context- the context to make active, ornullto clear whatever is currently active- Returns:
- a
Runnablethat restores this thread's previous context; nevernull
-