|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.repository.AbstractRepository<T> org.axonframework.repository.LockingRepository<T> org.axonframework.eventsourcing.EventSourcingRepository<T> org.axonframework.eventsourcing.CachingEventSourcingRepository<T>
T
- The type of aggregate this repository storespublic class CachingEventSourcingRepository<T extends EventSourcedAggregateRoot>
Implementation of the event sourcing repository that uses a cache to improve loading performance. The cache removes the need to read all events from disk, at the cost of memory usage. Since caching is not compatible with the optimistic locking strategy, only pessimistic locking is available for this type of repository.
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.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class org.axonframework.eventsourcing.EventSourcingRepository |
---|
doDeleteWithLock, doSaveWithLock, getAggregateFactory, getTypeIdentifier, resolveConflicts, setConflictResolver, setEventStreamDecorators, setSnapshotterTrigger, validateOnLoad |
Methods inherited from class org.axonframework.repository.LockingRepository |
---|
doDelete, doSave, load |
Methods inherited from class org.axonframework.repository.AbstractRepository |
---|
getAggregateType, load, setEventBus |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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)
Method Detail |
---|
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 aggregate
public void setCache(Cache cache)
cache
- the cache to use
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |