|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.domain.EventContainer
public class EventContainer
Container for events related to a single aggregate. The container will wrap registered event (payload) and metadata in an DomainEventMessage and automatically assign the aggregate identifier and the next sequence number.
The EventContainer also takes care of the invocation of EventRegistrationCallbacks once events are registered with this aggregate for publication. This implementation is not thread safe and should only be used with proper locking in place. Generally, only a single thread will be modifying an aggregate at any given time.
DomainEventMessage
,
AbstractAggregateRoot
,
Serialized FormConstructor Summary | |
---|---|
EventContainer(Object aggregateIdentifier)
Initialize an EventContainer for an aggregate with the given aggregateIdentifier . |
Method Summary | ||
---|---|---|
|
addEvent(DomainEventMessage<T> domainEventMessage)
Add an event to this container. |
|
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EventContainer(Object aggregateIdentifier)
aggregateIdentifier
. This identifier
will be attached to all incoming events.
aggregateIdentifier
- the aggregate identifier to assign to this containerMethod Detail |
---|
public <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 container
public <T> DomainEventMessage<T> addEvent(DomainEventMessage<T> domainEventMessage)
T
- the type of payload contained in the eventdomainEventMessage
- The message containing the event to add to the container
public 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |