public class SerializedMessage<T> extends AbstractMessage<T> implements SerializationAware
getPayload() or getMetaData() is called.
The SerializedMessage guarantees that the payload and metadata will not be deserialized more than once. Messages of
this type are also SerializationAware meaning they will not be serialized more than once by the same
serializer.
| Constructor and Description |
|---|
SerializedMessage(String identifier,
LazyDeserializingObject<T> payload,
LazyDeserializingObject<MetaData> metaData)
Initializes a
SerializedMessage with given identifier from the given lazily deserializing payload
and metadata. |
SerializedMessage(String identifier,
SerializedObject<?> serializedPayload,
SerializedObject<?> serializedMetaData,
Serializer serializer)
Initializes a
SerializedMessage with given identifier from the given serialized payload and
metadata. |
| 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. |
MetaData |
getMetaData()
Returns the meta data for this event.
|
T |
getPayload()
Returns the payload of this Event.
|
Class<T> |
getPayloadType()
Returns the type of the payload.
|
boolean |
isMetaDataDeserialized()
Indicates whether the metaData of this message has already been deserialized.
|
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 SerializedMessage<T> |
withMetaData(MetaData metaData)
Returns a new message instance with the same payload and properties as this message but 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.
|
getIdentifierpublic SerializedMessage(String identifier, SerializedObject<?> serializedPayload, SerializedObject<?> serializedMetaData, Serializer serializer)
SerializedMessage with given identifier from the given serialized payload and
metadata. The given serializer will be used to deserialize the data.identifier - the message identifierserializedPayload - the serialized message payloadserializedMetaData - the serialized message metadataserializer - the serializer required when the data needs to be deserializedpublic SerializedMessage(String identifier, LazyDeserializingObject<T> payload, LazyDeserializingObject<MetaData> metaData)
SerializedMessage with given identifier from the given lazily deserializing payload
and metadata.identifier - the message identifierpayload - serialized payload that can be deserialized on demand and never more than oncemetaData - serialized metadata that can be deserialized on demand and never more than oncepublic T getPayload()
MessagegetPayload in interface Message<T>public MetaData getMetaData()
MessagegetMetaData in interface Message<T>public Class<T> getPayloadType()
MessagegetPayload().getClass(), but allows implementations to optimize by using
lazy loading or deserialization.getPayloadType in interface Message<T>protected SerializedMessage<T> withMetaData(MetaData metaData)
AbstractMessagemetaData.withMetaData in class AbstractMessage<T>metaData - The metadata in the new messagepublic 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>withMetaData in class AbstractMessage<T>metaData - The new MetaData for the Messagepublic SerializedMessage<T> andMetaData(Map<String,?> metaData)
MessagemetaData. The payload
remains unchanged.andMetaData in interface Message<T>andMetaData in class AbstractMessage<T>metaData - The MetaData to merge withpublic <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 boolean isPayloadDeserialized()
true if the payload is deserialized, otherwise falsepublic boolean isMetaDataDeserialized()
true if the metaData is deserialized, otherwise falseprotected Object writeReplace()
Copyright © 2010–2018. All rights reserved.