Annotation Interface ActivityTracked
What this annotation is for
Put @ActivityTracked on a service or backing-bean method, and every successful call to it
becomes one UserActivityEvent in the store. You describe, in the annotation, what the
call means: its category, a verb, which method parameters identify the
business entity it touched (entityIdParams()), and whether a textual
argument should be captured (includeText()). The ActivityTrackedInterceptor reads all
of this at call time and hands a finished event to the ActivityRecorder.
Familiar analogy: a label you stick on a desk drawer that says "log every time this is opened, and note which file was pulled". You attach the label once (annotate the method); thereafter the logging happens by itself, with exactly the detail the label asked for.
How it is used
@Stateless
public class OrderService {
@ActivityTracked(type = Type.BUSINESS_ACTION, verb = "approve",
entityType = "order", entityIdParams = "orderId")
public void approve(String orderId) { ... }
@ActivityTracked(type = Type.SEARCH, includeText = true)
public List<Order> search(String query) { ... }
}
Notes
- All members are
Nonbinding— they configure the recorded event but do not participate in interceptor binding resolution, so any combination of values is matched by the singleActivityTrackedInterceptor. - Placed on a
, it applies to all of that bean's business methods.
invalid reference
type - The interceptor records after the method returns successfully; a method that throws records nothing.
- For tabs, the declarative shortcut
@DynTab(trackActivity = true)is the navigation-flavoured equivalent of annotating the tab's entry method with@ActivityTracked(type = NAVIGATION).
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Names of the method parameters that carry the touched entity's id(s).Theentity typeto tag the recorded event with (e.g.booleanWhether to capture a textual argument as the event'stext(e.g. a search query or a note body).The coarse category recorded for the call.The specific act in your domain's vocabulary (e.g.
-
Element Details
-
type
The coarse category recorded for the call.- Returns:
- the
UserActivityEvent.Type; defaults toUserActivityEvent.Type.BUSINESS_ACTION
- Default:
BUSINESS_ACTION
-
verb
String verbThe specific act in your domain's vocabulary (e.g."approve","cancel").When left blank, the interceptor falls back to the method's own name — so an explicit verb always wins, and you get a sensible default for free.
- Returns:
- the verb, or an empty string to derive it from the method name
- Default:
""
-
entityType
String entityTypeTheentity typeto tag the recorded event with (e.g."order").When blank, the interceptor falls back to the simple name of the method's declaring class.
- Returns:
- the entity type, or an empty string to derive it from the declaring class
- Default:
""
-
entityIdParams
String[] entityIdParamsNames of the method parameters that carry the touched entity's id(s).For each named parameter present, the interceptor builds an
EntityRefofentityType()whose id is the argument's string value. These refs are the raw material the assistant uses to resolve "this"/"that". Requires the module to be compiled with-parameters(which this project is) so parameter names are available at runtime.- Returns:
- parameter names to read entity ids from; empty means "record no entity"
- Default:
{}
-
includeText
boolean includeTextWhether to capture a textual argument as the event'stext(e.g. a search query or a note body).When
true, the interceptor uses the firstStringparameter that is not already consumed as an entity id.- Returns:
trueto capture authored text; defaults tofalse
- Default:
false
-