Package org.axonframework.messaging
Class MessageDecorator<T>
java.lang.Object
org.axonframework.messaging.MessageDecorator<T>
- All Implemented Interfaces:
Serializable,Message<T>
- Direct Known Subclasses:
GenericCommandMessage,GenericEventMessage,GenericQueryMessage,GenericResetContext,GenericResultMessage
Abstract implementation of a
Message that delegates to an existing message. Extend this decorator class to
extend the message with additional features.- Author:
- Rene de Waele
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMessageDecorator(Message<T> delegate) Initializes a new decorator with givendelegatemessage. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddescribeTo(StringBuilder stringBuilder) Describe the message specific properties to the givenstringBuilder.protected StringDescribe the type of message, used intoString().Returns the wrapped message delegate.Returns the identifier of this message.Returns the meta data for this message.Returns the payload of this message.Returns the type of the payload.<S> SerializedObject<S> serializeMetaData(Serializer serializer, Class<S> expectedRepresentation) Serialize the meta data of this message to theexpectedRepresentationusing givenserializer.<S> SerializedObject<S> serializePayload(Serializer serializer, Class<S> expectedRepresentation) Serialize the payload of this message to theexpectedRepresentationusing givenserializer.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.axonframework.messaging.Message
andMetaData, withMetaData
-
Constructor Details
-
MessageDecorator
Initializes a new decorator with givendelegatemessage. The decorator delegates to the delegate for the message's payload, metadata and identifier.- Parameters:
delegate- the message delegate
-
-
Method Details
-
getIdentifier
Description copied from interface:MessageReturns the identifier of this message. Two messages with the same identifiers should be interpreted as different representations of the same conceptual message. In such case, the meta-data may be different for both representations. The payload may be identical.- Specified by:
getIdentifierin interfaceMessage<T>- Returns:
- the unique identifier of this message
-
getMetaData
Description copied from interface:MessageReturns the meta data for this message. This meta data is a collection of key-value pairs, where the key is a String, and the value is a serializable object.- Specified by:
getMetaDatain interfaceMessage<T>- Returns:
- the meta data for this message
-
getPayload
Description copied from interface:MessageReturns the payload of this message. The payload is the application-specific information.- Specified by:
getPayloadin interfaceMessage<T>- Returns:
- the payload of this message
-
getPayloadType
Description copied from interface:MessageReturns the type of the payload. Is semantically equal togetPayload().getClass(), but allows implementations to optimize by using lazy loading or deserialization.- Specified by:
getPayloadTypein interfaceMessage<T>- Returns:
- the type of payload.
-
serializePayload
public <S> SerializedObject<S> serializePayload(Serializer serializer, Class<S> expectedRepresentation) Description copied from interface:MessageSerialize the payload of this message to theexpectedRepresentationusing givenserializer. This method should return the same SerializedObject instance when invoked multiple times using the same serializer.- Specified by:
serializePayloadin interfaceMessage<T>- Type Parameters:
S- The type of the serialized data- Parameters:
serializer- The serializer to serialize payload withexpectedRepresentation- The type of data to serialize to- Returns:
- a SerializedObject containing the serialized representation of the message's payload
-
serializeMetaData
public <S> SerializedObject<S> serializeMetaData(Serializer serializer, Class<S> expectedRepresentation) Description copied from interface:MessageSerialize the meta data of this message to theexpectedRepresentationusing givenserializer. This method should return the same SerializedObject instance when invoked multiple times using the same serializer.- Specified by:
serializeMetaDatain interfaceMessage<T>- Type Parameters:
S- The type of the serialized data- Parameters:
serializer- The serializer to serialize meta data withexpectedRepresentation- The type of data to serialize to- Returns:
- a SerializedObject containing the serialized representation of the message's meta data
-
getDelegate
Returns the wrapped message delegate.- Returns:
- the delegate message
-
toString
-
describeTo
Describe the message specific properties to the givenstringBuilder. Subclasses should override this method, calling the super method and appending their own properties to the end (or beginning).As convention, String values should be enclosed in single quotes, Objects in curly brackets and numeric values may be appended without enclosing. All properties should be preceded by a comma when appending, or finish with a comma when prefixing values.
- Parameters:
stringBuilder- the builder to append data to
-
describeType
Describe the type of message, used intoString().Defaults to the simple class name of the actual instance.
- Returns:
- the type of message
-