|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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)
Initializes a repository with a the given aggregateFactory and a pessimistic locking strategy. |
|
CachingEventSourcingRepository(AggregateFactory<T> aggregateFactory,
LockManager lockManager)
Initializes a repository with a the given aggregateFactory and a pessimistic locking strategy. |
|
| Method Summary | |
|---|---|
protected void |
doDeleteWithLock(T aggregate)
Delegates to EventSourcingRepository.doSaveWithLock(EventSourcedAggregateRoot), as Event Sourcing generally doesn't delete
aggregates (not their events). |
T |
doLoad(Object aggregateIdentifier,
Long expectedVersion)
Perform the actual loading of an aggregate. |
void |
doSaveWithLock(T aggregate)
Saves the aggregate and stores it in the cache (if configured) for fast retrieval. |
void |
setCache(net.sf.jsr107cache.Cache cache)
Set the cache to use for this repository. |
| Methods inherited from class org.axonframework.eventsourcing.EventSourcingRepository |
|---|
getAggregateFactory, getTypeIdentifier, setConflictResolver, setEventStore, setEventStreamDecorators, setSnapshotterTrigger, validateOnLoad |
| Methods inherited from class org.axonframework.repository.LockingRepository |
|---|
add, 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)
aggregateFactory and a pessimistic locking strategy.
Optimistic locking is not compatible with caching.
aggregateFactory - The factory for new aggregate instancesLockingRepository.LockingRepository(Class)
public CachingEventSourcingRepository(AggregateFactory<T> aggregateFactory,
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 instanceslockManager - The lock manager restricting concurrent access to aggregate instancesLockingRepository.LockingRepository(Class)| Method Detail |
|---|
public void doSaveWithLock(T aggregate)
doSaveWithLock in class EventSourcingRepository<T extends EventSourcedAggregateRoot>aggregate - the aggregate to saveprotected void doDeleteWithLock(T aggregate)
EventSourcingRepositoryEventSourcingRepository.doSaveWithLock(EventSourcedAggregateRoot), as Event Sourcing generally doesn't delete
aggregates (not their events).
This method may be safely overridden for special cases that do require deleting an Aggregate's Events.
doDeleteWithLock in class EventSourcingRepository<T extends EventSourcedAggregateRoot>aggregate - the aggregate to delete
public 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(net.sf.jsr107cache.Cache cache)
cache - the cache to use
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||