InteractionProvider
Provides the current thread’s Interaction .
An Interaction contains a top-level Execution representing the invocation of an action or the editing of a property. If that top-level action or property uses the org.apache.causeway.applib.services.wrapper.WrapperFactory domain service to invoke child actions/properties, then those sub-executions are captured as a call-graph. The Execution is thus a graph structure.
API
interface InteractionProvider {
boolean isInInteraction() (1)
Optional<Interaction> currentInteraction() (2)
Optional<InteractionContext> currentInteractionContext() (3)
Optional<ActionInvocation> currentActionInvocation()
boolean isCurrentActionInvocation(Object target, Identifier identifier)
boolean isCurrentActionInvocation(Object target, String memberName)
boolean isCurrentActionInvocation(Object target, Identifier identifier, ActionInvocation.RuleChecking ruleChecking)
boolean isCurrentActionInvocation(Object target, String memberName, ActionInvocation.RuleChecking ruleChecking)
Optional<UUID> getInteractionId() (4)
int getInteractionLayerCount() (5)
Interaction currentInteractionElseFail()
InteractionContext currentInteractionContextElseFail()
}
| 1 | isInInteraction()
Whether there is a currently active Interaction for the calling thread. |
| 2 | currentInteraction()
Optionally, the currently active Interaction for the calling thread. |
| 3 | currentInteractionContext()
Optionally, the currently active InteractionContext for the calling thread. |
| 4 | getInteractionId()
Unique id of the current request- or test-scoped Interaction . |
| 5 | getInteractionLayerCount()
interaction-layer-stack size |
Members
isInInteraction()
Whether there is a currently active Interaction for the calling thread.
currentInteraction()
Optionally, the currently active Interaction for the calling thread.
currentInteractionContext()
Optionally, the currently active InteractionContext for the calling thread.
getInteractionId()
Unique id of the current request- or test-scoped Interaction .
Current action invocation
currentActionInvocation() returns the current framework action execution, or empty when there is no action execution (including during a nested property edit).
Nested wrapper calls temporarily expose the child invocation and restore the parent when control returns, including after failure.
An action can retain defensive validation for direct Java callers while avoiding a duplicate check after framework validation:
public void updateName(String name) {
if (!interactionService.isCurrentActionInvocation(
this, "updateName", ActionInvocation.RuleChecking.CHECKED)) {
// Perform the defensive checks needed for direct or skip-rules callers.
checkName(name);
}
this.name = name;
}
Receiver matching uses Java identity (==), not entity equality.
The full Identifier overload distinguishes parameter signatures; the member-name form does not distinguish same-name overloads.
For a mixin implementation, use the mixin receiver (this) and its invoked method name, typically "act".
The invocation’s separate domainFacingLogicalMemberIdentifier identifies the contributed domain action.
CHECKED describes the framework’s rule-checking mode, SKIPPED an intentionally unchecked invocation, and UNKNOWN an invocation constructed without that information.
Presence of an invocation alone does not imply that rules were checked, and the aggregate status is not an inventory of individual supporting methods evaluated.
Direct Java calls create no execution frames. If such a call occurs inside a framework action, queries can still see that outer action; this API does not inspect arbitrary Java stack frames.