|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.domain.AbstractAggregateRoot
org.axonframework.eventsourcing.AbstractEventSourcedAggregateRoot
public abstract class AbstractEventSourcedAggregateRoot
Abstract convenience class to be extended by all aggregate roots. The AbstractEventSourcedAggregateRoot tracks all
uncommitted events. It also provides convenience methods to initialize the state of the aggregate root based on a
DomainEventStream, which can be used for event sourcing.
| Constructor Summary | |
|---|---|
protected |
AbstractEventSourcedAggregateRoot()
Initializes the aggregate root using a random aggregate identifier. |
protected |
AbstractEventSourcedAggregateRoot(AggregateIdentifier identifier)
Initializes the aggregate root using the provided aggregate identifier. |
protected |
AbstractEventSourcedAggregateRoot(UUID identifier)
Deprecated. Use AbstractEventSourcedAggregateRoot(org.axonframework.domain.AggregateIdentifier). Will be
removed in next release. |
| Method Summary | |
|---|---|
protected void |
apply(DomainEvent event)
Apply the provided event. |
protected Collection<AbstractEventSourcedEntity> |
getChildEntities()
Returns a list of event sourced entities directly referenced by the aggregate root. |
protected abstract void |
handle(DomainEvent event)
Apply state changes based on the given event. |
void |
initializeState(DomainEventStream domainEventStream)
Initialize the state of this aggregate using the events in the provided DomainEventStream. |
| Methods inherited from class org.axonframework.domain.AbstractAggregateRoot |
|---|
commitEvents, getIdentifier, getUncommittedEventCount, getUncommittedEvents, getVersion, initializeEventStream, registerEvent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.axonframework.domain.AggregateRoot |
|---|
commitEvents, getIdentifier, getUncommittedEventCount, getUncommittedEvents, getVersion |
| Constructor Detail |
|---|
protected AbstractEventSourcedAggregateRoot()
protected AbstractEventSourcedAggregateRoot(AggregateIdentifier identifier)
identifier - the identifier of this aggregate@Deprecated protected AbstractEventSourcedAggregateRoot(UUID identifier)
AbstractEventSourcedAggregateRoot(org.axonframework.domain.AggregateIdentifier). Will be
removed in next release.
identifier - the identifier of this aggregate| Method Detail |
|---|
public void initializeState(DomainEventStream domainEventStream)
DomainEventStream. A call to this method on an aggregate that has already been
initialized will result in an IllegalStateException.
This implementation is aware of two special types of DomainEvents: The
AggregateDeletedEvent, which indicates that the aggregate is deleted and the
AggregateSnapshot, which is a snapshot event, containing the actual aggregate inside.
When an AggregateDeletedEvent is encountered, a AggregateDeletedException is thrown,
unless there are events following the AggregateDeletedEvent. This could be the case when an event is
added to the stream as a correction to an earlier event.
AggregateSnapshot events are used to initialize the aggregate with the correct version (AbstractAggregateRoot.getVersion()).
initializeState in interface EventSourcedAggregateRootdomainEventStream - the event stream containing the events that describe the state changes of this
aggregate
IllegalStateException - if this aggregate was already initialized.
AggregateDeletedException - if the event stream contains an event of type AggregateDeletedEvent (or
subtype).protected void apply(DomainEvent event)
handle(DomainEvent) event handler method} for processing.
The event is applied on all entities part of this aggregate.
event - The event to applyprotected Collection<AbstractEventSourcedEntity> getChildEntities()
AbstractEventSourcedEntity
implementations.
It will look for entities: Iterable;Map
protected abstract void handle(DomainEvent event)
event - The event to handle
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||