|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.repository.AbstractRepository<T>
T - The type of aggregate this repository storespublic abstract class AbstractRepository<T extends AggregateRoot>
Abstract implementation of the Repository that takes care of the dispatching of events when an aggregate is
persisted. All uncommitted events on an aggregate are dispatched when the aggregate is saved.
LockingRepository.
setEventBus(org.axonframework.eventhandling.EventBus),
LockingRepository| Constructor Summary | |
|---|---|
AbstractRepository()
|
|
| Method Summary | |
|---|---|
void |
add(T aggregate)
Adds the given aggregate to the repository. |
protected abstract T |
doLoad(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
Loads and initialized the aggregate with the given aggregateIdentifier. |
protected abstract void |
doSave(T aggregate)
Performs the actual saving of the aggregate. |
T |
load(AggregateIdentifier aggregateIdentifier)
Load the aggregate with the given unique identifier. |
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. |
void |
setEventBus(EventBus eventBus)
Sets the event bus to which newly stored events should be published. |
protected void |
validateOnLoad(T aggregate,
Long expectedVersion)
Checks the aggregate for concurrent changes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractRepository()
| Method Detail |
|---|
public void add(T aggregate)
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 AggregateRoot>aggregate - The aggregate to add to the repository.
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>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 classesUnitOfWorkpublic T load(AggregateIdentifier aggregateIdentifier)
load in interface Repository<T extends AggregateRoot>aggregateIdentifier - The identifier of the aggregate to load
protected void validateOnLoad(T aggregate,
Long expectedVersion)
ConflictingModificationException
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
aggregate - The loaded aggregateexpectedVersion - The expected version of the aggregate
ConflictingModificationException
ConflictingAggregateVersionExceptionprotected abstract void doSave(T aggregate)
aggregate - the aggregate to store
protected abstract T doLoad(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
aggregateIdentifier - the identifier of the aggregate to loadexpectedVersion - The expected version of the aggregate to load
AggregateNotFoundException - if the aggregate with given identifier does not existpublic void setEventBus(EventBus eventBus)
eventBus - the event bus to publish events to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||