Interface EventSourcedEntityModule<ID,E>

Type Parameters:
ID - The type of identifier used to identify the event-sourced entity.
E - The type of the event-sourced entity.
All Superinterfaces:
EntityModule<ID,E>, Module

public interface EventSourcedEntityModule<ID,E> extends EntityModule<ID,E>
An expansion of the EntityModule, specifically for event-sourced entities. When constructed, either autodetected or declarative, it provides the resulting Repository with the nearest StateManager so the state can be loaded.

Command Handling

An EntityCommandHandlingComponent will be registered to the CommandBus that subscribes to the commands of the EntityMetamodel that describes this entity. This is only done if an EntityIdResolver is provided. If no EntityIdResolver is provided, no command handling component will be registered, but the entity will still be registered to the StateManager so it can be loaded in stateful command handlers.

Annotation-based entities

Entities annotated with EventSourcedEntity can be built using autodetected(Class, Class). This will automatically build all required components based on the EventSourcedEntity annotation present on the entity type.

Declarative building

Entities can also be built using the declarative(Class, Class) method. This allows for a more manual approach to building the event-sourced entity, where the user can provide the required components.

There are several phases of the building process of the declarative event-sourced entity module:

Module hierarchy

This module does not provide a StateManager by itself, but rather registers the entity to the nearest StateManager in the module hierarchy. This means that you can load the event-sourced entity from the nearest parent configuration that provides a StateManager, or any of that parent's children modules. As such, to ensure access, this module should be registered at the right place in the module hierarchy.
Since:
5.0.0
Author:
Steven van Beelen, Mitchell Herrijgers
  • Method Details

    • declarative

      static <ID, E> EventSourcedEntityModule.MessagingModelPhase<ID,E> declarative(@Nonnull Class<ID> idType, @Nonnull Class<E> entityType)
      Starts building an event-sourced entity with the given entityType and idType.
      Type Parameters:
      ID - The type of identifier used to identify the event-sourced entity.
      E - The type of the event-sourced entity being built.
      Parameters:
      idType - The type of identifier used to identify the event-sourced entity.
      entityType - The type of the event-sourced entity being built.
      Returns:
      The EventSourcedEntityModule.MessagingModelPhase phase of this builder, for a fluent API.
    • autodetected

      static <ID, E> EventSourcedEntityModule<ID,E> autodetected(@Nonnull Class<ID> idType, @Nonnull Class<E> entityType)
      Creates the module for an annotated event-sourced entity with the given entityType and idType. The given entityType is expected to be annotated with EventSourcedEntity, which provides the module with the necessary information to build the event-sourced entity.
      Type Parameters:
      ID - The type of identifier used to identify the event-sourced entity.
      E - The type of the event-sourced entity being built.
      Parameters:
      idType - The type of identifier used to identify the annotated event-sourced entity.
      entityType - The type of the annotated event-sourced entity being built.
      Returns:
      The finished module.
      Throws:
      IllegalArgumentException - When the given entityType is not annotated with EventSourcedEntity.