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
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
AnEntityCommandHandlingComponent 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 withEventSourcedEntity 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 thedeclarative(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:
-
EventSourcedEntityModule.MessagingModelPhase- Provides theEntityMetamodelof the event-sourced entity being built. -
EventSourcedEntityModule.EntityFactoryPhase- Provides theEventSourcedEntityFactoryfor the event-sourced entity being built. -
EventSourcedEntityModule.CriteriaResolverPhase- Provides theCriteriaResolverfor the event-sourced entity being built. -
EventSourcedEntityModule.EntityIdResolverPhase- Provides theEntityIdResolverfor the event-sourced entity being built, or provides the user with a choice to not have aEntityCommandHandlingComponent.
Module hierarchy
This module does not provide aStateManager 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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePhase of the module's building process in which aComponentBuilderfor aCriteriaResolvershould be provided.static interfacePhase of the module's building process in which aComponentBuilderfor anEventSourcedEntityFactoryshould be provided.static interfacePhase of the module's building process in which aComponentBuilderfor anEntityIdResolvershould be provided.static interfacePhase of the module's building process in which the user should define the messaging metamodel for the event-sourced entity being built. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <ID,E> EventSourcedEntityModule <ID, E> autodetected(Class<ID> idType, Class<E> entityType) Creates the module for an annotated event-sourced entity with the givenentityTypeandidType.static <ID,E> EventSourcedEntityModule.MessagingModelPhase <ID, E> declarative(Class<ID> idType, Class<E> entityType) Starts building an event-sourced entity with the givenentityTypeandidType.Methods inherited from interface org.axonframework.modelling.configuration.EntityModule
entityName, entityType, idType
-
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 givenentityTypeandidType.- 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.MessagingModelPhasephase 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 givenentityTypeandidType. The givenentityTypeis expected to be annotated withEventSourcedEntity, 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 givenentityTypeis not annotated withEventSourcedEntity.
-