public class EventContainer extends Object implements Serializable
DomainEventMessage
,
AbstractAggregateRoot
,
Serialized FormConstructor and Description |
---|
EventContainer(Object aggregateIdentifier)
Initialize an EventContainer for an aggregate with the given
aggregateIdentifier . |
Modifier and Type | Method and Description |
---|---|
<T> DomainEventMessage<T> |
addEvent(MetaData metaData,
T payload)
Add an event to this container.
|
void |
addEventRegistrationCallback(EventRegistrationCallback eventRegistrationCallback)
Adds an EventRegistrationCallback, which is invoked when the aggregate owning this container registers an Event.
|
void |
commit()
Clears the events in this container.
|
Object |
getAggregateIdentifier()
Returns the aggregate identifier assigned to this container.
|
List<DomainEventMessage> |
getEventList()
Returns an unmodifiable version of the backing list of events.
|
DomainEventStream |
getEventStream()
Read the events inside this container using a
DomainEventStream . |
Long |
getLastCommittedSequenceNumber()
Returns the sequence number of the last committed event, or
null if no events have been committed. |
Long |
getLastSequenceNumber()
Returns the sequence number of the event last added to this container.
|
void |
initializeSequenceNumber(Long lastKnownSequenceNumber)
Sets the first sequence number that should be assigned to an incoming event.
|
int |
size()
Returns the number of events currently inside this container.
|
public EventContainer(Object aggregateIdentifier)
aggregateIdentifier
. This identifier
will be attached to all incoming events.aggregateIdentifier
- the aggregate identifier to assign to this containerpublic <T> DomainEventMessage<T> addEvent(MetaData metaData, T payload)
T
- the type of payload contained in the eventmetaData
- the metaData of the event to add to this containerpayload
- the payload of the event to add to this containerpublic DomainEventStream getEventStream()
DomainEventStream
. The returned
stream is a snapshot of the uncommitted events in the aggregate at the time of the invocation. Once returned,
newly applied events are not accessible from the returned event stream.public Object getAggregateIdentifier()
public void initializeSequenceNumber(Long lastKnownSequenceNumber)
lastKnownSequenceNumber
- the sequence number of the last known eventpublic Long getLastSequenceNumber()
public Long getLastCommittedSequenceNumber()
null
if no events have been committed.public void commit()
public int size()
public List<DomainEventMessage> getEventList()
public void addEventRegistrationCallback(EventRegistrationCallback eventRegistrationCallback)
eventRegistrationCallback
- The callback to notify when an Event is registered.Copyright © 2010-2014. All Rights Reserved.