T - The type of aggregate this repository storespublic class CachingEventSourcingRepository<T> extends EventSourcingRepository<T>
Note that an entry of a cached aggregate is immediately invalidated when an error occurs while saving that aggregate. This is done to prevent the cache from returning aggregates that may not have fully persisted to disk.
EventSourcingRepository.Builder<T>spanFactory| Modifier | Constructor and Description |
|---|---|
protected |
CachingEventSourcingRepository(EventSourcingRepository.Builder<T> builder)
Instantiate a
CachingEventSourcingRepository based on the fields contained in the
EventSourcingRepository.Builder. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doDeleteWithLock(EventSourcedAggregate<T> aggregate)
Perform the actual deleting of the aggregate.
|
protected EventSourcedAggregate<T> |
doLoadWithLock(String aggregateIdentifier,
Long expectedVersion)
Perform the actual loading of an aggregate.
|
protected void |
doSaveWithLock(EventSourcedAggregate<T> aggregate)
Perform the actual saving of the aggregate.
|
protected void |
validateOnLoad(Aggregate<T> aggregate,
Long expectedVersion)
Checks the aggregate for concurrent changes.
|
builder, doCreateNewForLock, getAggregateFactory, readEvents, reportIllegalStatedoCreateNew, doDelete, doLoad, doLoadOrCreate, doSave, prepareForCommitaggregateModel, canResolve, getAggregateType, load, load, loadOrCreate, managedAggregates, newInstance, newInstance, postDelete, postSave, sendprotected CachingEventSourcingRepository(EventSourcingRepository.Builder<T> builder)
CachingEventSourcingRepository based on the fields contained in the
EventSourcingRepository.Builder.
A goal of the provided Builder is to create an AggregateModel specifying generic T as the
aggregate type to be stored. All aggregates in this repository must be instanceOf this aggregate type.
To instantiate this AggregateModel, either an AggregateModel can be provided directly or an
aggregateType of type Class can be used. The latter will internally resolve to an
AggregateModel. Thus, either the AggregateModel or the aggregateType should be provided. An
AxonConfigurationException is thrown if this criteria is not met.
The same criteria holds for the AggregateFactory. Either the AggregateFactory can be set directly or it
will be instantiated internally based on the aggregateType. Hence, one of both is a hard requirement, and
will also result in an AxonConfigurationException if both are missing.
Additionally will assert that the LockFactory, EventStore, SnapshotTriggerDefinition and
Cache are not null, resulting in an AxonConfigurationException if for any of these this is the
case.
builder - the EventSourcingRepository.Builder used to instantiate a
CachingEventSourcingRepository instanceprotected void validateOnLoad(Aggregate<T> aggregate, Long expectedVersion)
AbstractRepositoryConflictingModificationException when conflicting
changes have been detected.
This implementation throws a ConflictingAggregateVersionException if the expected version is not null
and the version number of the aggregate does not match the expected version
validateOnLoad in class EventSourcingRepository<T>aggregate - The loaded aggregateexpectedVersion - The expected version of the aggregateprotected void doSaveWithLock(EventSourcedAggregate<T> aggregate)
LockingRepositorydoSaveWithLock in class EventSourcingRepository<T>aggregate - the aggregate to storeprotected void doDeleteWithLock(EventSourcedAggregate<T> aggregate)
LockingRepositorydoDeleteWithLock in class EventSourcingRepository<T>aggregate - the aggregate to deleteprotected EventSourcedAggregate<T> doLoadWithLock(String aggregateIdentifier, Long expectedVersion)
doLoadWithLock in class EventSourcingRepository<T>aggregateIdentifier - the identifier of the aggregate to loadexpectedVersion - The expected version of the aggregateCopyright © 2010–2023. All rights reserved.