|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.domain.AbstractAggregateRoot<I>
I
- The type of the identifier of this aggregate@MappedSuperclass public abstract class AbstractAggregateRoot<I>
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 | |
---|---|
AbstractAggregateRoot()
|
Method Summary | ||
---|---|---|
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
|
registerEvent(MetaData metaData,
T payload)
Registers an event to be published when the aggregate is saved. |
|
protected
|
registerEvent(T payload)
Registers an event to be published when the aggregate is saved, containing the given payload and no
(additional) meta-data. |
|
protected
|
registerEventMessage(DomainEventMessage<T> message)
Registers an event message 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 |
Methods inherited from interface org.axonframework.domain.AggregateRoot |
---|
getIdentifier |
Constructor Detail |
---|
public AbstractAggregateRoot()
Method Detail |
---|
protected <T> DomainEventMessage<T> registerEvent(T payload)
payload
and no
(additional) meta-data.
T
- The type of payloadpayload
- the payload of the event to register
payload
protected <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 register
payload
protected <T> DomainEventMessage<T> registerEventMessage(DomainEventMessage<T> message)
T
- The payload type carried by the messagemessage
- The message to publish
protected void markDeleted()
public boolean isDeleted()
AggregateRoot
true
, 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)
AggregateRoot
eventRegistrationCallback
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 committed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |