Interface Repository<ID,E>
- Type Parameters:
ID- The type of identifier for entities in this repository.E- The type of entity this repository stores.
- All Superinterfaces:
DescribableComponent
- All Known Subinterfaces:
Repository.LifecycleManagement<ID,E>
- All Known Implementing Classes:
AccessSerializingRepository,EventSourcingRepository,InMemoryRepository,SimpleRepository
public sealed interface Repository<ID,E>
extends DescribableComponent
permits Repository.LifecycleManagement<ID,E>
The
Repository provides an abstraction for the storage of entities.
When interacting with the Repository the framework expects an active ProcessingContext. If there is
no active UnitOfWork an IllegalStateException is thrown.
- Since:
- 0.1
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceSpecialization of theRepositoryinterface that must be implemented by all implementations of theRepository. -
Method Summary
Modifier and TypeMethodDescriptionThe type of entity stored in this repository.idType()The type of the identifier used to identify entities in this repository.load(ID identifier, ProcessingContext processingContext) Load the entity with the given unique identifier.loadOrCreate(ID identifier, ProcessingContext processingContext) Loads an entity from the repository.persist(ID identifier, E entity, ProcessingContext processingContext) Persists the givenentityin this repositoryMethods inherited from interface org.axonframework.common.infra.DescribableComponent
describeTo
-
Method Details
-
entityType
The type of entity stored in this repository.- Returns:
- The type of entity stored in this repository.
-
idType
The type of the identifier used to identify entities in this repository.- Returns:
- The type of the identifier used to identify entities in this repository.
-
load
CompletableFuture<ManagedEntity<ID,E>> load(@Nonnull ID identifier, @Nonnull ProcessingContext processingContext) Load the entity with the given unique identifier. No version checks are done when loading an entity, meaning that concurrent access will not be checked for.- Parameters:
identifier- The identifier of the entity to load.processingContext- The processing context in which to manage the lifecycle of the entity.- Returns:
- A
CompletableFutureresolving to theManagedEntitywith the given identifier, ornullif it can't be found.
-
loadOrCreate
CompletableFuture<ManagedEntity<ID,E>> loadOrCreate(@Nonnull ID identifier, @Nonnull ProcessingContext processingContext) Loads an entity from the repository.- Parameters:
identifier- The identifier of the entity to load.processingContext- The processing context in which to manage the lifecycle of the entity.- Returns:
- A
CompletableFutureresolving to theManagedEntitywith the given identifier, or a newly constructed entity instance based on thefactoryMethod.
-
persist
ManagedEntity<ID,E> persist(@Nonnull ID identifier, @Nonnull E entity, @Nonnull ProcessingContext processingContext) Persists the givenentityin this repository- Parameters:
identifier- The identifier of the entity.entity- The current state of the entity to store.processingContext- TheProcessingContextin which the entity is active.- Returns:
- a
ManagedEntitywrapping the entity managed in theProcessingContext.
-