Class FlowContextCarrier

java.lang.Object
com.fayupable.logged.spring.aspect.FlowContextCarrier

public final class FlowContextCarrier extends Object
The sanctioned public entry point for reading and writing this thread's active 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 Details

    • capture

      public static FlowContext capture()
      Returns the FlowContext currently active on this thread, or null if no @Logged call is in progress on this thread.
      Returns:
      the active flow context, or null if none is active
    • adopt

      public static Runnable adopt(FlowContext context)
      Makes context the active FlowContext on the calling thread and returns a Runnable that undoes this, restoring whatever context was active before this call.
      Parameters:
      context - the context to make active, or null to clear whatever is currently active
      Returns:
      a Runnable that restores this thread's previous context; never null