public class HelloEntity extends com.lightbend.lagom.javadsl.persistence.PersistentEntity<HelloCommand,HelloEvent,HelloState>
HelloState, which
stores what the greeting should be (eg, "Hello Alice").
Event sourced entities are interacted with by sending them commands. This
entity supports two commands, a HelloCommand.UseGreetingMessage command, which is
used to change the greeting, and a HelloCommand.Hello command, which is a read
only command which returns a greeting to the name specified by the command.
Commands get translated to events, and it's the events that get persisted by the entity. Each event will have an event handler registered for it, and an event handler simply applies an event to the current state. This will be done when the event is first created, and it will also be done when the entity is loaded from the database - each event will be replayed to recreate the state of the entity.
This entity defines one event, the HelloEvent.GreetingMessageChanged event,
which is emitted when a HelloCommand.UseGreetingMessage command is received.
com.lightbend.lagom.javadsl.persistence.PersistentEntity.Behavior, com.lightbend.lagom.javadsl.persistence.PersistentEntity.Behavior$, com.lightbend.lagom.javadsl.persistence.PersistentEntity.BehaviorBuilder, com.lightbend.lagom.javadsl.persistence.PersistentEntity.BehaviorBuilderImpl, com.lightbend.lagom.javadsl.persistence.PersistentEntity.CommandContext<R>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.InvalidCommandException, com.lightbend.lagom.javadsl.persistence.PersistentEntity.InvalidCommandException$, com.lightbend.lagom.javadsl.persistence.PersistentEntity.Persist<B extends Event>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistAll<B extends Event>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistAll$, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistException, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistException$, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistNone<B extends Event>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistNone$, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistOne<B extends Event>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.PersistOne$, com.lightbend.lagom.javadsl.persistence.PersistentEntity.ReadOnlyCommandContext<R>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.ReplyType<R>, com.lightbend.lagom.javadsl.persistence.PersistentEntity.UnhandledCommandException, com.lightbend.lagom.javadsl.persistence.PersistentEntity.UnhandledCommandException$| Constructor and Description |
|---|
HelloEntity() |
| Modifier and Type | Method and Description |
|---|---|
com.lightbend.lagom.javadsl.persistence.PersistentEntity.Behavior |
initialBehavior(java.util.Optional<HelloState> snapshotState)
An entity can define different behaviours for different states, but it will
always start with an initial behaviour.
|
behavior, Behavior, com$lightbend$lagom$javadsl$persistence$PersistentEntity$$persistNone, entityId, entityTypeName, internalSetCurrentBehavior, internalSetEntityId, newBehavior, newBehaviorBuilder, PersistAll, PersistNone, PersistOne, recoveryCompleted, statepublic com.lightbend.lagom.javadsl.persistence.PersistentEntity.Behavior initialBehavior(java.util.Optional<HelloState> snapshotState)
initialBehavior in class com.lightbend.lagom.javadsl.persistence.PersistentEntity<HelloCommand,HelloEvent,HelloState>