I - The type of the identifier of this aggregate@MappedSuperclass public abstract class AbstractAggregateRoot<I> extends Object implements AggregateRoot<I>, Serializable
| Constructor and Description |
|---|
AbstractAggregateRoot() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventRegistrationCallback(EventRegistrationCallback eventRegistrationCallback)
Adds an EventRegistrationCallback, which is notified when the aggregate registers an Event for publication.
|
void |
commitEvents()
Clears the events currently marked as "uncommitted" and clears any known EventRegistrationCallbacks (see
AggregateRoot.addEventRegistrationCallback(EventRegistrationCallback)). |
protected Long |
getLastCommittedEventSequenceNumber()
Returns the sequence number of the last committed event, or
null if no events have been committed
before. |
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.
|
boolean |
isDeleted()
Indicates whether this aggregate has been marked as deleted.
|
protected void |
markDeleted()
Marks this aggregate as deleted, instructing a Repository to remove that aggregate at an appropriate time.
|
protected <T> DomainEventMessage<T> |
registerEvent(MetaData metaData,
T payload)
Registers an event to be published when the aggregate is saved.
|
protected <T> DomainEventMessage<T> |
registerEvent(T payload)
Registers an event to be published when the aggregate is saved, containing the given
payload and no
(additional) meta-data. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetIdentifierprotected <T> DomainEventMessage<T> registerEvent(T payload)
payload and no
(additional) meta-data.T - The type of payloadpayload - the payload of the event to registerpayloadprotected <T> DomainEventMessage<T> registerEvent(MetaData metaData, T payload)
T - The type of payloadmetaData - The meta data of the event to registerpayload - the payload of the event to registerpayloadprotected void markDeleted()
public boolean isDeleted()
AggregateRoottrue, it is an instruction to the
repository to remove this instance at an appropriate time.
Repositories should not return any instances of Aggregates that return true on
isDeleted().isDeleted in interface AggregateRoot<I>true if this aggregate was marked as deleted, otherwise false.public void addEventRegistrationCallback(EventRegistrationCallback eventRegistrationCallback)
AggregateRooteventRegistrationCallback for processing.addEventRegistrationCallback in interface AggregateRoot<I>eventRegistrationCallback - the callback to notify when an event is registeredpublic DomainEventStream getUncommittedEvents()
getUncommittedEvents in interface AggregateRoot<I>public void commitEvents()
AggregateRoot.addEventRegistrationCallback(EventRegistrationCallback)).commitEvents in interface AggregateRoot<I>EventContainer.commit()public int getUncommittedEventCount()
getUncommittedEventCount in interface AggregateRoot<I>protected void initializeEventStream(long lastSequenceNumber)
lastSequenceNumber - The sequence number of the last event from this aggregateprotected Long getLastCommittedEventSequenceNumber()
null if no events have been committed
before.public 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 AggregateRoot<I>null if no events were ever committedCopyright © 2010-2014. All Rights Reserved.