com.lightbend.lagom.javadsl.persistence.PersistentEntity
Construct the corresponding immutable Behavior
.
Remove a command handler for a given command class.
Remove an event handler for a given event class.
Register a command handler for a given command class.
Register a command handler for a given command class.
The handler
function is supposed to return a Persist
directive that defines
what event or events, if any, to persist. Use the thenPersist
, thenPersistAll
or done
methods of the context that is passed to the handler function to create the
Persist
directive.
After persisting an event external side effects can be performed in the afterPersist
function that can be defined when creating the Persist
directive.
A typical side effect is to reply to the request to confirm that it was performed
successfully. Replies are sent with the reply
method of the context that is passed
to the command handler function.
The handler
function may validate the incoming command and reject it by
sending a reply
and returning ctx.done()
.
Register an event handler for a given event class.
Register an event handler for a given event class. The handler
function
is supposed to return the new state after applying the event to the current state.
Current state can be accessed with the state
method of the PersistentEntity
.
Register an event handler that is updating the behavior for a given event class.
Register an event handler that is updating the behavior for a given event class.
The handler
function is supposed to return the new behavior after applying the
event to the current state. Current behavior can be accessed with the behavior
method of the PersistentEntity
.
Register a read-only command handler for a given command class.
Register a read-only command handler for a given command class. A read-only command
handler does not persist events (i.e. it does not change state) but it may perform side
effects, such as replying to the request. Replies are sent with the reply
method of the
context that is passed to the command handler function.
Mutable builder that is used for defining the event and command handlers. Use [#build] to create the immutable Behavior.