org.axonframework.domain
Class GenericDomainEventMessage<T>

java.lang.Object
  extended by org.axonframework.domain.GenericMessage<T>
      extended by org.axonframework.domain.GenericEventMessage<T>
          extended by org.axonframework.domain.GenericDomainEventMessage<T>
Type Parameters:
T - The type of payload contained in this Message
All Implemented Interfaces:
Serializable, DomainEventMessage<T>, EventMessage<T>, Message<T>

public class GenericDomainEventMessage<T>
extends GenericEventMessage<T>
implements DomainEventMessage<T>

Generic implementation of the DomainEventMessage interface. It simply keeps a reference to the payload and MetaData, as well as the aggregate identifier and sequence number.

Since:
2.0
Author:
Allard Buijze
See Also:
Serialized Form

Constructor Summary
GenericDomainEventMessage(Object aggregateIdentifier, long sequenceNumber, T payload)
          Initialize a DomainEventMessage originating from an Aggregate with the given aggregateIdentifier, with given sequenceNumber and payload.
GenericDomainEventMessage(Object aggregateIdentifier, long sequenceNumber, T payload, Map<String,?> metaData)
          Initialize a DomainEventMessage originating from an Aggregate with the given aggregateIdentifier, with given sequenceNumber, metaData and payload.
GenericDomainEventMessage(String identifier, org.joda.time.DateTime timestamp, Object aggregateIdentifier, long sequenceNumber, T payload, Map<String,?> metaData)
          Constructor to reconstruct a DomainEventMessage using existing data.
 
Method Summary
 GenericDomainEventMessage<T> andMetaData(Map<String,?> additionalMetaData)
          Returns a copy of this Message with it MetaData merged with the given metaData.
 Object getAggregateIdentifier()
          Returns the identifier of the Aggregate that generated this DomainEvent.
 long getSequenceNumber()
          Returns the sequence number that allows DomainEvents originating from the same Aggregate to be placed in the order of generation.
 String toString()
           
 GenericDomainEventMessage<T> withMetaData(Map<String,?> newMetaData)
          Returns a copy of this Message with the given metaData.
 
Methods inherited from class org.axonframework.domain.GenericEventMessage
asEventMessage, getTimestamp
 
Methods inherited from class org.axonframework.domain.GenericMessage
getIdentifier, getMetaData, getPayload, getPayloadType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.axonframework.domain.EventMessage
getIdentifier, getTimestamp
 
Methods inherited from interface org.axonframework.domain.Message
getMetaData, getPayload, getPayloadType
 

Constructor Detail

GenericDomainEventMessage

public GenericDomainEventMessage(Object aggregateIdentifier,
                                 long sequenceNumber,
                                 T payload)
Initialize a DomainEventMessage originating from an Aggregate with the given aggregateIdentifier, with given sequenceNumber and payload. The MetaData of the message is empty.

Parameters:
aggregateIdentifier - The identifier of the aggregate generating this message
sequenceNumber - The message's sequence number
payload - The application-specific payload of the message

GenericDomainEventMessage

public GenericDomainEventMessage(Object aggregateIdentifier,
                                 long sequenceNumber,
                                 T payload,
                                 Map<String,?> metaData)
Initialize a DomainEventMessage originating from an Aggregate with the given aggregateIdentifier, with given sequenceNumber, metaData and payload.

Parameters:
aggregateIdentifier - The identifier of the aggregate generating this message
sequenceNumber - The message's sequence number
payload - The application-specific payload of the message
metaData - The MetaData to attach to the message

GenericDomainEventMessage

public GenericDomainEventMessage(String identifier,
                                 org.joda.time.DateTime timestamp,
                                 Object aggregateIdentifier,
                                 long sequenceNumber,
                                 T payload,
                                 Map<String,?> metaData)
Constructor to reconstruct a DomainEventMessage using existing data.

Parameters:
identifier - The identifier of the Message
timestamp - The timestamp of the Message creation
aggregateIdentifier - The identifier of the aggregate from which the message originates
sequenceNumber - The sequence number of the message withing the originating aggregate
payload - The payload of the message
metaData - The meta data of the message
Method Detail

getSequenceNumber

public long getSequenceNumber()
Description copied from interface: DomainEventMessage
Returns the sequence number that allows DomainEvents originating from the same Aggregate to be placed in the order of generation.

Specified by:
getSequenceNumber in interface DomainEventMessage<T>
Returns:
the sequence number of this Event

getAggregateIdentifier

public Object getAggregateIdentifier()
Description copied from interface: DomainEventMessage
Returns the identifier of the Aggregate that generated this DomainEvent. Note that the value returned does not necessarily have to be the same instance that was provided at creation time. It is possible that (due to serialization, for example) the value returned here has a different structure.

Specified by:
getAggregateIdentifier in interface DomainEventMessage<T>
Returns:
the identifier of the Aggregate that generated this DomainEvent

withMetaData

public GenericDomainEventMessage<T> withMetaData(Map<String,?> newMetaData)
Description copied from interface: Message
Returns a copy of this Message with the given metaData. The payload remains unchanged.

While the implementation returned may be different than the implementation of this, implementations must take special care in returning the same type of Message (e.g. EventMessage, DomainEventMessage) to prevent errors further downstream.

Specified by:
withMetaData in interface DomainEventMessage<T>
Specified by:
withMetaData in interface EventMessage<T>
Specified by:
withMetaData in interface Message<T>
Overrides:
withMetaData in class GenericEventMessage<T>
Parameters:
newMetaData - The new MetaData for the Message
Returns:
a copy of this message with the given MetaData

andMetaData

public GenericDomainEventMessage<T> andMetaData(Map<String,?> additionalMetaData)
Description copied from interface: Message
Returns a copy of this Message with it MetaData merged with the given metaData. The payload remains unchanged.

Specified by:
andMetaData in interface DomainEventMessage<T>
Specified by:
andMetaData in interface EventMessage<T>
Specified by:
andMetaData in interface Message<T>
Overrides:
andMetaData in class GenericEventMessage<T>
Parameters:
additionalMetaData - The MetaData to merge with
Returns:
a copy of this message with the given MetaData

toString

public String toString()
Overrides:
toString in class GenericEventMessage<T>


Copyright © 2010-2016. All Rights Reserved.