Class ActivityRecorder
ActivityStore that stamps each event with the current session and tab, so
callers never have to figure out "where am I" themselves.
What this class is for
Two kinds of caller record activity, and both go through here:
- the
ActivityTrackedInterceptor, automatically, for every@ActivityTrackedmethod; - your own beans, manually, for things an annotation can't express (a free-text note typed into a
field, a multi-step wizard completing) — e.g.
recorder.record(Type.NOTE, "note", null, body).
Centralising it means the rule for "which session/tab does this belong to" lives in one place and is applied consistently, whichever path recorded the event.
Familiar analogy: the front desk where everyone drops off their timesheets. Whether the entry
came from an automatic badge-reader (the interceptor) or someone filling in a slip by hand (manual
calls), the front desk stamps it with today's date and the right department (session + tab) before
filing it. The filing cabinet itself is the ActivityStore.
How the result is used
Everything recorded here lands in the ActivityStore, from which an ActivityContext
later reads a recent slice to inject into the assistant's prompt. In other words, this class is the
write-end of the loop whose read-end is ActivityContext.render().
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionResolve the id of the HTTP session the caller is currently in.Resolve the id of the tab the caller is currently acting in.voidrecord(UserActivityEvent event) Record a fully-built event, filling in the current session and tab if the caller left them unset.voidConvenience builder-and-record for callers that don't want to assemble aUserActivityEvent.
-
Constructor Details
-
ActivityRecorder
public ActivityRecorder()
-
-
Method Details
-
record
Record a fully-built event, filling in the current session and tab if the caller left them unset.Called by
ActivityTrackedInterceptor(which builds the event from method metadata) and by any bean holding a pre-builtUserActivityEvent. The event is then handed to theActivityStore, where it waits to be read back by anActivityContext.- Parameters:
event- the event to store; must not benull. If itssessionId/tabIdarenull, they are stamped from the current context before storing.
-
record
Convenience builder-and-record for callers that don't want to assemble aUserActivityEvent.Stamps the current session/tab and timestamp automatically, then delegates to
record(UserActivityEvent). Handy for manual notes/searches from a backing bean.- Parameters:
type- the event category (required)verb- the act in your vocabulary (may benull)entities- the business objects touched (may benullor empty)text- authored text such as a note or query (may benull)
-
currentTabId
Resolve the id of the tab the caller is currently acting in.Used internally to stamp events; reads from
TabScopedContextHolder.getCurrentTabId(), which TabForge keeps set for the duration of a tab-scoped request.- Returns:
- the current tab id, or
nullwhen there is no active tab (e.g. outside a JSF request)
-
currentSessionId
Resolve the id of the HTTP session the caller is currently in.Used internally to scope the timeline per user session; reads the session id from the active
FacesContextwithout forcing a session to be created.- Returns:
- the current session id, or
nullwhen there is no active JSF request/session
-