Module org.fuin.ddd4j.esc
Package org.fuin.ddd4j.esc
Class EventStoreRepository<ID extends org.fuin.ddd4j.core.AggregateRootId,AGGREGATE extends org.fuin.ddd4j.core.AggregateRoot<ID>>
java.lang.Object
org.fuin.ddd4j.esc.EventStoreRepository<ID,AGGREGATE>
- Type Parameters:
ID- Type of the aggregate root identifier.AGGREGATE- Type of the aggregate root.
- All Implemented Interfaces:
org.fuin.ddd4j.core.Repository<ID,AGGREGATE>
public abstract class EventStoreRepository<ID extends org.fuin.ddd4j.core.AggregateRootId,AGGREGATE extends org.fuin.ddd4j.core.AggregateRoot<ID>>
extends Object
implements org.fuin.ddd4j.core.Repository<ID,AGGREGATE>
Event store based repository.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEventStoreRepository(@NotNull org.fuin.esc.api.EventStore eventStore) Constructor with all mandatory data. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprotected booleanconflictsResolved(List<org.fuin.ddd4j.core.DomainEvent<?>> uncommittedChanges, List<org.fuin.ddd4j.core.DomainEvent<?>> unseenEvents) Checks if the uncommitted changes conflicts with unseen changes from the event store and tries to solve the problem.final voidprotected @NotNull org.fuin.ddd4j.core.AggregateCache<AGGREGATE>Returns the aggregate cache.protected final @NotNull org.fuin.esc.api.EventStoreReturns the underlying event store.protected abstract @NotNull StringReturns the parameter name for the unique identifier.protected intReturns the number of tries that should be done to resolve a version conflict.intReturns the number of events to read in a slice.final AGGREGATEfinal AGGREGATEfinal voidfinal voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.fuin.ddd4j.core.Repository
create, getAggregateClass, getAggregateType
-
Constructor Details
-
EventStoreRepository
protected EventStoreRepository(@NotNull @NotNull org.fuin.esc.api.EventStore eventStore) Constructor with all mandatory data.- Parameters:
eventStore- Event store.
-
-
Method Details
-
read
-
read
public final AGGREGATE read(ID aggregateId, int version) throws org.fuin.ddd4j.core.AggregateNotFoundException, org.fuin.ddd4j.core.AggregateDeletedException, org.fuin.ddd4j.core.AggregateVersionNotFoundException - Specified by:
readin interfaceorg.fuin.ddd4j.core.Repository<ID extends org.fuin.ddd4j.core.AggregateRootId,AGGREGATE extends org.fuin.ddd4j.core.AggregateRoot<ID>> - Throws:
org.fuin.ddd4j.core.AggregateNotFoundExceptionorg.fuin.ddd4j.core.AggregateDeletedExceptionorg.fuin.ddd4j.core.AggregateVersionNotFoundException
-
update
public final void update(AGGREGATE aggregate) throws org.fuin.ddd4j.core.AggregateVersionConflictException, org.fuin.ddd4j.core.AggregateNotFoundException, org.fuin.ddd4j.core.AggregateDeletedException - Specified by:
updatein interfaceorg.fuin.ddd4j.core.Repository<ID extends org.fuin.ddd4j.core.AggregateRootId,AGGREGATE extends org.fuin.ddd4j.core.AggregateRoot<ID>> - Throws:
org.fuin.ddd4j.core.AggregateVersionConflictExceptionorg.fuin.ddd4j.core.AggregateNotFoundExceptionorg.fuin.ddd4j.core.AggregateDeletedException
-
update
public final void update(AGGREGATE aggregate, String metaType, Object metaData) throws org.fuin.ddd4j.core.AggregateVersionConflictException, org.fuin.ddd4j.core.AggregateNotFoundException, org.fuin.ddd4j.core.AggregateDeletedException - Specified by:
updatein interfaceorg.fuin.ddd4j.core.Repository<ID extends org.fuin.ddd4j.core.AggregateRootId,AGGREGATE extends org.fuin.ddd4j.core.AggregateRoot<ID>> - Throws:
org.fuin.ddd4j.core.AggregateVersionConflictExceptionorg.fuin.ddd4j.core.AggregateNotFoundExceptionorg.fuin.ddd4j.core.AggregateDeletedException
-
add
public void add(AGGREGATE aggregate) throws org.fuin.ddd4j.core.AggregateAlreadyExistsException, org.fuin.ddd4j.core.AggregateDeletedException -
add
-
delete
public final void delete(ID aggregateId, int expectedVersion) throws org.fuin.ddd4j.core.AggregateVersionConflictException -
conflictsResolved
protected boolean conflictsResolved(List<org.fuin.ddd4j.core.DomainEvent<?>> uncommittedChanges, List<org.fuin.ddd4j.core.DomainEvent<?>> unseenEvents) Checks if the uncommitted changes conflicts with unseen changes from the event store and tries to solve the problem. This method may be overwritten by concrete implementation. Returns FALSE as default if not overwritten in subclasses.- Parameters:
uncommittedChanges- Uncommitted changes.unseenEvents- Unseen changes from the event store.- Returns:
- TRUE if there are no conflicting changes, else FALSE (conflict couldn't be resolved).
-
getMaxTryCount
protected int getMaxTryCount()Returns the number of tries that should be done to resolve a version conflict. This method may be overwritten by concrete implementation. Returns3as default if not overwritten in subclasses.- Returns:
- Number of tries.
-
getAggregateCache
Returns the aggregate cache. This method may be overwritten by concrete implementation. Returns no cache as default if not overwritten in subclasses.- Returns:
- Cache.
-
getReadPageSize
public int getReadPageSize()Returns the number of events to read in a slice. This method may be overwritten by concrete implementation. Returns100as default if not overwritten in subclasses.- Returns:
- Page size.
-
getEventStore
@NotNull protected final @NotNull org.fuin.esc.api.EventStore getEventStore()Returns the underlying event store.- Returns:
- Event store implementation.
-
getIdParamName
Returns the parameter name for the unique identifier.- Returns:
- Name to be used as parameter.
-