Command

Represents the intention to invoke either an action or modify a property. There can be only one such intention per (web) request, so a command is in effect interaction-scoped.

Each Command holds a CommandDto (see Apache Causewaycmdschema) which reifies all the details in a serializable form.

It also captures details of the corresponding action invocation (or property edit), specifically when that action/edit Command#getStartedAt() started or Command#getCompletedAt() completed , and its result, either a Command#getResult() return value or an Command#getException() exception . Also captures a stack of ActionDomainEvent s.

Note that when invoking an action, other actions may be invoked courtesy of the WrapperFactory . These "sub-actions" do not modify the contents of the current command object; in other words think of the command object as representing the outer-most originating action.

That said, if the sub-action is invoked asynchronously (using WrapperFactory#asyncWrap(Object, AsyncControl) or WrapperFactory#asyncWrapMixin(Class, Object, AsyncControl) ), then a separate Command object is created, and the originating Command is set to be its Command#getParentInteractionId() parent .

API

Command.java
class Command {
  Command(UUID interactionId)
  UUID getInteractionId()     (1)
  String getUsername()     (2)
  Timestamp getTimestamp()     (3)
  CommandDto getCommandDto()     (4)
  Bookmark getTarget()     (5)
  String getLogicalMemberIdentifier()     (6)
  Updater updater()     (7)
}
1 getInteractionId()

The unique identifier of this command (inherited from HasInteractionId )

2 getUsername()

The user that created the command.

3 getTimestamp()

The date/time at which this command was created.

4 getCommandDto()

Serializable representation of the action invocation/property edit.

5 getTarget()

Derived from #getCommandDto() , is the Bookmark of the target object (entity or service) on which this action/edit was performed.

6 getLogicalMemberIdentifier()

Derived from #getCommandDto() , holds a string representation of the invoked action, or the edited property.

7 updater()
*NOT API* : intended to be called only by the framework.

Members

getInteractionId()

The unique identifier of this command (inherited from HasInteractionId )

In all cases this be the same as the Interaction that wraps the command, and can be used to correlate also to any audit records ( org.apache.causeway.applib.services.publishing.spi.EntityPropertyChange s resulting from state changes occurring as a consequence of the command.

Note that this is immutable in almost all cases. The one exception is if the Command is being executed through the CommandExecutorService , for example when executing a async action that has been reified into a CommandDto . In such cases, the CommandExecutorService#executeCommand(CommandDto) will replace the original Id with that of the DTO being executed.

getUsername()

The user that created the command.

Derived from #getCommandDto() 's CommandDto#getUsername() ()}

getTimestamp()

The date/time at which this command was created.

Derived from #getCommandDto() 's CommandDto#getTimestamp() .

getCommandDto()

Serializable representation of the action invocation/property edit.

When the framework sets this (through an internal API), it is expected that the CommandDto#getUsername() username , CommandDto#getTimestamp() timestamp , CommandDto#getTargets() target(s) and CommandDto#getMember() member will be populated. The #getInteractionId() , #getUsername() , #getTimestamp() and #getTarget() are all derived from the provided CommandDto .

getTarget()

Derived from #getCommandDto() , is the Bookmark of the target object (entity or service) on which this action/edit was performed.

getLogicalMemberIdentifier()

Derived from #getCommandDto() , holds a string representation of the invoked action, or the edited property.

updater()

*NOT API* : intended to be called only by the framework.