ID - Type of the aggregate root identifier.AGGREGATE - Type of the aggregate root.public abstract class EventStoreRepository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>> extends java.lang.Object implements Repository<ID,AGGREGATE>
| Modifier | Constructor and Description |
|---|---|
protected |
EventStoreRepository(@NotNull org.fuin.esc.api.EventStore eventStore)
Constructor with all mandatory data.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(AGGREGATE aggregate)
Adds a new aggregate to the repository without any meta data.
|
void |
add(AGGREGATE aggregate,
java.lang.String metaType,
java.lang.Object metaData)
Adds a new aggregate to the repository with some meta data.
|
protected boolean |
conflictsResolved(java.util.List<DomainEvent<?>> uncommittedChanges,
java.util.List<DomainEvent<?>> unseenEvents)
Checks if the uncommitted changes conflicts with unseen changes from the event store and tries to solve the problem.
|
void |
delete(ID aggregateId,
int expectedVersion)
Deletes an aggregate from the repository.
|
protected @NotNull AggregateCache<AGGREGATE> |
getAggregateCache()
Returns the aggregate cache.
|
protected @NotNull org.fuin.esc.api.EventStore |
getEventStore()
Returns the underlying event store.
|
protected abstract @NotNull java.lang.String |
getIdParamName()
Returns the parameter name for the unique identifier.
|
protected int |
getMaxTryCount()
Returns the number of tries that should be done to resolve a version conflict.
|
int |
getReadPageSize()
Returns the number of events to read in a slice.
|
AGGREGATE |
read(ID aggregateId)
Reads the latest version of an aggregate.
|
AGGREGATE |
read(ID aggregateId,
int version)
Reads a given version of an aggregate.
|
void |
update(AGGREGATE aggregate)
Saves the changes on an aggregate in the repository without any meta data.
|
void |
update(AGGREGATE aggregate,
java.lang.String metaType,
java.lang.Object metaData)
Saves the changes on an aggregate in the repository including some meta data.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, getAggregateClass, getAggregateTypeprotected EventStoreRepository(@NotNull
@NotNull org.fuin.esc.api.EventStore eventStore)
eventStore - Event store.public final AGGREGATE read(ID aggregateId) throws AggregateNotFoundException, AggregateDeletedException
Repositoryread in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregateId - Unique aggregate identifier.AggregateNotFoundException - An aggregate with the given identifier was not found.AggregateDeletedException - The aggregate with the given identifier was already deleted.public final AGGREGATE read(ID aggregateId, int version) throws AggregateNotFoundException, AggregateDeletedException, AggregateVersionNotFoundException
Repositoryread in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregateId - Unique aggregate identifier.version - Version to read.AggregateNotFoundException - An aggregate with the given identifier was not found.AggregateDeletedException - The aggregate with the given identifier was already deleted.AggregateVersionNotFoundException - An aggregate with the requested version does not exist.public final void update(AGGREGATE aggregate) throws AggregateVersionConflictException, AggregateNotFoundException, AggregateDeletedException
Repositoryupdate in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregate - Aggregate to store.AggregateVersionConflictException - The expected version didn't match the actual version.AggregateNotFoundException - An aggregate with the given identifier was not found.AggregateDeletedException - The aggregate with the given identifier was already deleted.public final void update(AGGREGATE aggregate, java.lang.String metaType, java.lang.Object metaData) throws AggregateVersionConflictException, AggregateNotFoundException, AggregateDeletedException
Repositoryupdate in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregate - Aggregate to store.metaType - Optional unique name that identifies the type of meta data.metaData - Optional information that is not directly available in the event.AggregateVersionConflictException - The expected version didn't match the actual version.AggregateNotFoundException - An aggregate with the given identifier was not found.AggregateDeletedException - The aggregate with the given identifier was already deleted.public void add(AGGREGATE aggregate) throws AggregateAlreadyExistsException, AggregateDeletedException
Repositoryadd in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregate - Aggregate to add.AggregateAlreadyExistsException - The aggregate with the given version could not be created because it already exists.AggregateDeletedException - The aggregate with the given identifier was already deleted.public void add(AGGREGATE aggregate, java.lang.String metaType, java.lang.Object metaData) throws AggregateAlreadyExistsException, AggregateDeletedException
Repositoryadd in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregate - Aggregate to add.metaType - Optional unique name that identifies the type of meta data.metaData - Optional information that is not directly available in the event.AggregateAlreadyExistsException - The aggregate with the given version could not be created because it already exists.AggregateDeletedException - The aggregate with the given identifier was already deleted.public final void delete(ID aggregateId, int expectedVersion) throws AggregateVersionConflictException
Repositorydelete in interface Repository<ID extends AggregateRootId,AGGREGATE extends AggregateRoot<ID>>aggregateId - Identifier of the aggregate to delete.expectedVersion - Expected (current) version of the aggregate.AggregateVersionConflictException - The expected version didn't match the actual version.protected boolean conflictsResolved(java.util.List<DomainEvent<?>> uncommittedChanges, java.util.List<DomainEvent<?>> unseenEvents)
uncommittedChanges - Uncommitted changes.unseenEvents - Unseen changes from the event store.protected int getMaxTryCount()
3 as default if not overwritten in subclasses.@NotNull protected @NotNull AggregateCache<AGGREGATE> getAggregateCache()
public int getReadPageSize()
100
as default if not overwritten in subclasses.@NotNull protected final @NotNull org.fuin.esc.api.EventStore getEventStore()
@NotNull protected abstract @NotNull java.lang.String getIdParamName()
Copyright © 2019 fuin.org (Germany). All Rights Reserved.