|
||||||||||
| 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>
T - The type of aggregate this repository storespublic abstract class EventSourcingRepository<T extends EventSourcedAggregateRoot>
Abstract repository implementation that allows easy implementation of an Event Sourcing mechanism. It will
automatically publish new events to the given EventBus and delegate event
storage to the provided EventStore.
EventSourcedAggregateRoot,
AbstractEventSourcedAggregateRoot,
AbstractAnnotatedAggregateRoot,
EventStore,
FileSystemEventStore| Constructor Summary | |
|---|---|
protected |
EventSourcingRepository()
Initializes a repository with the default locking strategy. |
protected |
EventSourcingRepository(LockingStrategy lockingStrategy)
Initialize a repository with the given locking strategy. |
| Method Summary | |
|---|---|
T |
createAggregate(AggregateIdentifier aggregateIdentifier,
DomainEvent firstEvent)
Instantiate the aggregate using the given aggregate identifier and first event. |
protected T |
doLoad(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
Perform the actual loading of an aggregate. |
protected void |
doSaveWithLock(T aggregate)
Perform the actual saving of the aggregate. |
protected abstract T |
instantiateAggregate(AggregateIdentifier aggregateIdentifier,
DomainEvent firstEvent)
Instantiate the aggregate using the given aggregate identifier and first event. |
void |
setConflictResolver(ConflictResolver conflictResolver)
Sets the conflict resolver to use for this repository. |
void |
setEventStore(EventStore eventStore)
Sets the event store that would physically store the events. |
void |
setEventStreamDecorators(List<? extends EventStreamDecorator> eventProcessors)
Sets the Event Stream Decorators that will process the event in the DomainEventStream when read, or written to the event store. |
void |
setSnapshotterTrigger(SnapshotterTrigger snapshotterTrigger)
Sets the snapshotter trigger for this repository. |
protected void |
validateOnLoad(T aggregate,
Long expectedVersion)
Checks the aggregate for concurrent changes. |
| Methods inherited from class org.axonframework.repository.LockingRepository |
|---|
doSave, load |
| Methods inherited from class org.axonframework.repository.AbstractRepository |
|---|
add, load, setEventBus |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.axonframework.eventsourcing.AggregateFactory |
|---|
getTypeIdentifier |
| Constructor Detail |
|---|
protected EventSourcingRepository()
LockingRepository.LockingRepository()protected EventSourcingRepository(LockingStrategy lockingStrategy)
lockingStrategy - the locking strategy to apply to this| Method Detail |
|---|
protected void doSaveWithLock(T aggregate)
doSaveWithLock in class LockingRepository<T extends EventSourcedAggregateRoot>aggregate - the aggregate to store
protected T doLoad(AggregateIdentifier aggregateIdentifier,
Long expectedVersion)
doLoad in class LockingRepository<T extends EventSourcedAggregateRoot>aggregateIdentifier - the identifier of the aggregate to loadexpectedVersion - The expected version of the loaded aggregate
AggregateDeletedException - in case an aggregate existed in the past, but has been deleted
AggregateNotFoundException - when an aggregate with the given identifier does not exist
public T createAggregate(AggregateIdentifier aggregateIdentifier,
DomainEvent firstEvent)
firstEvent is an instance of
AggregateSnapshot, the aggregate is extracted from the event. Otherwise, aggregate creation is delegated
to the abstract instantiateAggregate(org.axonframework.domain.AggregateIdentifier,
org.axonframework.domain.DomainEvent) method.
createAggregate in interface AggregateFactory<T extends EventSourcedAggregateRoot>aggregateIdentifier - the aggregate identifier of the aggregate to instantiatefirstEvent - The first event in the event stream. This is either the event generated during
creation of the aggregate, or a snapshot event
protected abstract T instantiateAggregate(AggregateIdentifier aggregateIdentifier,
DomainEvent firstEvent)
aggregateIdentifier - the aggregate identifier of the aggregate to instantiatefirstEvent - The first event in the event stream. This is either the event generated during
creation of the aggregate, or a snapshot event
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
This implementation will do nothing if a conflict resolver (See setConflictResolver(ConflictResolver) is
set. Otherwise, it will call super.validateOnLoad(...).
validateOnLoad in class AbstractRepository<T extends EventSourcedAggregateRoot>aggregate - The loaded aggregateexpectedVersion - The expected version of the aggregatepublic void setEventStore(EventStore eventStore)
eventStore - the event bus to publish events topublic void setEventStreamDecorators(List<? extends EventStreamDecorator> eventProcessors)
eventProcessors - The processors to that will process events in the DomainEventStreampublic void setSnapshotterTrigger(SnapshotterTrigger snapshotterTrigger)
snapshotterTrigger - the snapshotter trigger for this repository.public void setConflictResolver(ConflictResolver conflictResolver)
null), the repository will
throw an exception if any unexpected changes appear in loaded aggregates.
conflictResolver - The conflict resolver to use for this repository
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||