Class ActivityTrackedInterceptor

java.lang.Object
dyntabs.ai.activity.ActivityTrackedInterceptor

@Interceptor @Priority(2100) public class ActivityTrackedInterceptor extends Object
The interceptor that turns an ActivityTracked method call into a recorded UserActivityEvent — the runtime engine behind the declarative annotation.

What this class is for

CDI invokes this interceptor around every method (or every method of a bean) annotated with ActivityTracked. It lets the real method run, and if it returns successfully, reads the annotation's configuration plus the call's arguments to assemble one activity event, then hands it to the ActivityRecorder. The developer thus gets automatic, structured capture purely by annotating — no boilerplate inside the business method.

Familiar analogy: a court stenographer sitting beside the witness. The witness (your method) just does their job; the stenographer quietly writes down, in a fixed format, who said what about which case — but only once the statement is actually completed (the method returns), never for a sentence cut off by an objection (an exception).

Where it sits and when it runs

Enabled globally via Priority (no beans.xml entry needed). It runs at aroundInvoke(InvocationContext) time, after any container interceptors of lower priority, and records only on the success path. Capture failures are swallowed and logged, never propagated — the user's action must never break because activity logging hiccuped.

See Also:
  • Constructor Details

    • ActivityTrackedInterceptor

      public ActivityTrackedInterceptor()
  • Method Details

    • aroundInvoke

      public Object aroundInvoke(jakarta.interceptor.InvocationContext ctx) throws Exception
      Wraps the tracked call: proceed first, then record the activity on success.

      Invoked by the CDI container for every @ActivityTracked method. The original return value is passed straight back to the caller; recording is a side effect whose own errors are contained here. The event produced is consumed downstream by ActivityRecorder and the ActivityStore.

      Parameters:
      ctx - the container-supplied invocation context (method, arguments, target)
      Returns:
      whatever the intercepted method returns
      Throws:
      Exception - only if the intercepted method itself throws (re-propagated unchanged)