T
- The type of aggregate this repository storespublic class CachingEventSourcingRepository<T extends EventSourcedAggregateRoot> extends EventSourcingRepository<T>
Constructor and Description |
---|
CachingEventSourcingRepository(AggregateFactory<T> aggregateFactory,
EventStore eventStore)
Initializes a repository with a the given
aggregateFactory and a pessimistic locking strategy. |
CachingEventSourcingRepository(AggregateFactory<T> aggregateFactory,
EventStore eventStore,
LockManager lockManager)
Initializes a repository with a the given
aggregateFactory and a pessimistic locking strategy. |
Modifier and Type | Method and Description |
---|---|
void |
add(T aggregate)
Adds the given
aggregate to the repository. |
T |
doLoad(Object aggregateIdentifier,
Long expectedVersion)
Perform the actual loading of an aggregate.
|
protected void |
postDelete(T aggregate)
Perform action that needs to be done directly after deleting an aggregate and committing the aggregate's
uncommitted events.
|
protected void |
postSave(T aggregate)
Perform action that needs to be done directly after updating an aggregate and committing the aggregate's
uncommitted events.
|
void |
setCache(Cache cache)
Set the cache to use for this repository.
|
doDeleteWithLock, doSaveWithLock, getAggregateFactory, getTypeIdentifier, resolveConflicts, setConflictResolver, setEventStreamDecorators, setSnapshotterTrigger, validateOnLoad
doDelete, doSave, load
getAggregateType, load, setEventBus
public CachingEventSourcingRepository(AggregateFactory<T> aggregateFactory, EventStore eventStore)
aggregateFactory
and a pessimistic locking strategy.
Optimistic locking is not compatible with caching.aggregateFactory
- The factory for new aggregate instanceseventStore
- The event store that holds the event streams for this repositoryLockingRepository.LockingRepository(Class)
public CachingEventSourcingRepository(AggregateFactory<T> aggregateFactory, EventStore eventStore, LockManager lockManager)
aggregateFactory
and a pessimistic locking strategy.
Note that an optimistic locking strategy is not compatible with caching.aggregateFactory
- The factory for new aggregate instanceseventStore
- The event store that holds the event streams for this repositorylockManager
- The lock manager restricting concurrent access to aggregate instancesLockingRepository.LockingRepository(Class)
public void add(T aggregate)
AbstractRepository
aggregate
to the repository. The version of this aggregate must be null
,
indicating that it has not been previously persisted.
This method will not force the repository to save the aggregate immediately. Instead, it is registered with the
current UnitOfWork. To force storage of an aggregate, commit the current unit of work
(CurrentUnitOfWork.commit()
)add
in interface Repository<T extends EventSourcedAggregateRoot>
add
in class LockingRepository<T extends EventSourcedAggregateRoot>
aggregate
- The aggregate to add to the repository.protected void postSave(T aggregate)
AbstractRepository
postSave
in class AbstractRepository<T extends EventSourcedAggregateRoot>
aggregate
- The aggregate instance being savedprotected void postDelete(T aggregate)
AbstractRepository
postDelete
in class AbstractRepository<T extends EventSourcedAggregateRoot>
aggregate
- The aggregate instance being savedpublic T doLoad(Object aggregateIdentifier, Long expectedVersion)
doLoad
in class EventSourcingRepository<T extends EventSourcedAggregateRoot>
aggregateIdentifier
- the identifier of the aggregate to loadexpectedVersion
- The expected version of the aggregatepublic void setCache(Cache cache)
cache
- the cache to useCopyright © 2010-2014. All Rights Reserved.