T - The type of payload contained in this messagepublic class SerializedMessage<T> extends Object implements Message<T>, SerializationAware
| Constructor and Description |
|---|
SerializedMessage(String identifier,
SerializedObject<?> serializedPayload,
SerializedObject<?> serializedMetaData,
Serializer serializer)
Reconstructs a Message using the given
identifier, serializedPayload,
serializedMetaData and serializer. |
| Modifier and Type | Method and Description |
|---|---|
SerializedMessage<T> |
andMetaData(Map<String,?> metaData)
Returns a copy of this Message with it MetaData merged with the given
metaData. |
String |
getIdentifier()
Returns the identifier of this message.
|
MetaData |
getMetaData()
Returns the meta data for this event.
|
T |
getPayload()
Returns the payload of this Event.
|
Class |
getPayloadType()
Returns the type of the payload.
|
boolean |
isPayloadDeserialized()
Indicates whether the payload of this message has already been deserialized.
|
<R> SerializedObject<R> |
serializeMetaData(Serializer serializer,
Class<R> expectedRepresentation)
Serialize the meta data of this message using given
serializer, using given
expectedRepresentation. |
<R> SerializedObject<R> |
serializePayload(Serializer serializer,
Class<R> expectedRepresentation)
Serialize the payload of this message using given
serializer, using given
expectedRepresentation. |
SerializedMessage<T> |
withMetaData(Map<String,?> metaData)
Returns a copy of this Message with the given
metaData. |
protected Object |
writeReplace()
Java Serialization API Method that provides a replacement to serialize, as the fields contained in this instance
are not serializable themselves.
|
public SerializedMessage(String identifier, SerializedObject<?> serializedPayload, SerializedObject<?> serializedMetaData, Serializer serializer)
identifier, serializedPayload,
serializedMetaData and serializer.identifier - The identifier of the messageserializedPayload - The serialized payload of the messageserializedMetaData - The serialized meta data of the messageserializer - The serializer to deserialize the payload and meta data withUnknownSerializedTypeException - if the type of the serialized object cannot be resolved to a classpublic <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation)
SerializationAwareserializer, using given
expectedRepresentation. This method should return the same SerializedObject instance when
invoked multiple times using the same serializer.serializePayload in interface SerializationAwareR - The type of data to serialize toserializer - The serializer to serialize payload withexpectedRepresentation - The type of data to serialize topublic <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation)
SerializationAwareserializer, using given
expectedRepresentation. This method should return the same SerializedObject instance when
invoked multiple times using the same serializer.serializeMetaData in interface SerializationAwareR - The type of data to serialize toserializer - The serializer to serialize meta data withexpectedRepresentation - The type of data to serialize topublic String getIdentifier()
MessagegetIdentifier in interface Message<T>public MetaData getMetaData()
MessagegetMetaData in interface Message<T>public T getPayload()
MessagegetPayload in interface Message<T>public Class getPayloadType()
MessagegetPayload().getClass(), but allows implementations to optimize by using
lazy loading or deserialization.getPayloadType in interface Message<T>public SerializedMessage<T> withMetaData(Map<String,?> metaData)
MessagemetaData. 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.withMetaData in interface Message<T>metaData - The new MetaData for the Messagepublic SerializedMessage<T> andMetaData(Map<String,?> metaData)
MessagemetaData. The payload
remains unchanged.andMetaData in interface Message<T>metaData - The MetaData to merge withpublic boolean isPayloadDeserialized()
true if the payload is deserialized, otherwise falseprotected Object writeReplace()
Copyright © 2010-2014. All Rights Reserved.