|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.domain.AbstractAggregateRoot
public abstract class AbstractAggregateRoot
Very basic implementation of the AggregateRoot interface. It provides the mechanism to keep track of uncommitted events and maintains a version number based on the number of events generated.
| Constructor Summary | |
|---|---|
protected |
AbstractAggregateRoot()
Initializes the aggregate root using a random aggregate identifier. |
protected |
AbstractAggregateRoot(AggregateIdentifier identifier)
Initializes the aggregate root using the provided aggregate identifier. |
| Method Summary | |
|---|---|
void |
commitEvents()
Clears the events currently marked as "uncommitted". |
AggregateIdentifier |
getIdentifier()
Returns the identifier of this aggregate. |
int |
getUncommittedEventCount()
Returns the number of uncommitted events currently available in the aggregate. |
DomainEventStream |
getUncommittedEvents()
Returns a DomainEventStream to the events in the aggregate that have been raised since creation or the last commit. |
Long |
getVersion()
Returns the current version number of the aggregate, or null if the aggregate is newly created. |
protected void |
initializeEventStream(long lastSequenceNumber)
Initialize the event stream using the given sequence number of the last known event. |
protected void |
registerEvent(DomainEvent event)
Registers an event to be published when the aggregate is saved. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractAggregateRoot()
protected AbstractAggregateRoot(AggregateIdentifier identifier)
identifier - the identifier of this aggregate| Method Detail |
|---|
protected void registerEvent(DomainEvent event)
event - the event to registerpublic DomainEventStream getUncommittedEvents()
getUncommittedEvents in interface AggregateRootpublic AggregateIdentifier getIdentifier()
getIdentifier in interface AggregateRootpublic void commitEvents()
commitEvents in interface AggregateRootpublic int getUncommittedEventCount()
getUncommittedEventCount in interface AggregateRootprotected void initializeEventStream(long lastSequenceNumber)
lastSequenceNumber - The sequence number of the last event from this aggregatepublic Long getVersion()
null if the aggregate is newly created. This
version must reflect the version number of the aggregate on which changes are applied.
Each time the aggregate is modified and stored in a repository, the version number must be increased by
at least 1. This version number can be used by optimistic locking strategies and detection of conflicting
concurrent modification.
Typically the sequence number of the last committed event on this aggregate is used as version number.
getVersion in interface AggregateRootnull if no events were ever committed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||