|
||||||||||
| 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>
T - The type that this aggregate storespublic abstract class LockingRepository<T extends AggregateRoot>
Implementation of the Repository interface that takes provides a locking mechanism to prevent concurrent modifications of persisted aggregates. Unless there is a locking mechanism present in the underlying persistence environment, it is recommended to use a LockingRepository (or one of its subclasses).
The LockingRepository can be initialized with two strategies:
| Constructor Summary | |
|---|---|
protected |
LockingRepository()
Initialize a repository with an optimistic locking strategy. |
protected |
LockingRepository(LockingStrategy lockingStrategy)
Initialize the repository with the given lockingStrategy. |
| Method Summary | |
|---|---|
protected abstract T |
doLoad(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
Perform the actual loading of an aggregate. |
protected void |
doSave(T aggregate)
Verifies whether all locks are valid and delegates to doSaveWithLock(org.axonframework.domain.AggregateRoot)
to perform actual storage. |
protected abstract void |
doSaveWithLock(T aggregate)
Perform the actual saving of the aggregate. |
T |
load(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
Load the aggregate with the given unique aggregateIdentifier, expecting the version of the aggregate
to be equal to the given expectedVersion. |
| Methods inherited from class org.axonframework.repository.AbstractRepository |
|---|
add, load, setEventBus, validateOnLoad |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected LockingRepository()
protected LockingRepository(LockingStrategy lockingStrategy)
lockingStrategy.
lockingStrategy - the locking strategy to use| Method Detail |
|---|
public T load(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
aggregateIdentifier, expecting the version of the aggregate
to be equal to the given expectedVersion. If the expectedVersion is null,
no version validation is done.
When versions do not match, implementations may either raise an exception immediately when loading an aggregate,
or at any other time while the aggregate is registered in the current Unit Of Work.
load in interface Repository<T extends AggregateRoot>load in class AbstractRepository<T extends AggregateRoot>aggregateIdentifier - The identifier of the aggregate to loadexpectedVersion - The expected version of the aggregate to load, or null to indicate the
version should not be checked
AggregateNotFoundException - if aggregate with given id cannot be found
RuntimeException - any exception thrown by implementing classesUnitOfWorkprotected final void doSave(T aggregate)
doSaveWithLock(org.axonframework.domain.AggregateRoot)
to perform actual storage.
doSave in class AbstractRepository<T extends AggregateRoot>aggregate - the aggregate to storeprotected abstract void doSaveWithLock(T aggregate)
aggregate - the aggregate to store
protected abstract T doLoad(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
doLoad in class AbstractRepository<T extends AggregateRoot>aggregateIdentifier - the identifier of the aggregate to loadexpectedVersion - The expected version of the aggregate
AggregateNotFoundException - if aggregate with given id cannot be found
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||