|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.serializer.MessageSerializer
public class MessageSerializer
Wrapper around a serializer that provides SerializationAware support. This class can either be used as a
wrapper around a Serializer, or as a static utility class.
serializePayload and serializeMetaData methods on this class are aware of
SerializationAware messages. When a Message implements that interface, serialization is delegated to that message to
allow performance optimizations.
Using this class to serialize the payload and meta-data of Message is preferred over the serialization using the
Serializer class.
| Constructor Summary | |
|---|---|
MessageSerializer(Serializer serializer)
Initializes the MessageSerializer as a wrapper around the given serializer. |
|
| Method Summary | ||
|---|---|---|
|
canSerializeTo(Class<T> expectedRepresentation)
Indicates whether this Serializer is capable of serializing to the given expectedRepresentation. |
|
Class |
classForType(SerializedType type)
Returns the class for the given type identifier. |
|
|
deserialize(SerializedObject<S> serializedObject)
Deserializes the first object read from the given bytes. |
|
ConverterFactory |
getConverterFactory()
Returns the converter factory used by this Serializer to convert between serialized representations. |
|
|
serialize(Object object,
Class<T> expectedRepresentation)
Serialize the given object into a Serialized Object containing the given
expectedRepresentation. |
|
|
serializeMetaData(Message<?> message,
Class<T> expectedRepresentation)
Serialize the meta data of given message to the given expectedRepresentation. |
|
static
|
serializeMetaData(Message<?> message,
Serializer serializer,
Class<T> expectedRepresentation)
Utility method that serializes the meta data of the given message using given
serializer and expectedRepresentation. |
|
|
serializePayload(Message<?> message,
Class<T> expectedRepresentation)
Serialize the payload of given message to the given expectedRepresentation. |
|
static
|
serializePayload(Message<?> message,
Serializer serializer,
Class<T> expectedRepresentation)
Utility method that serializes the payload of the given message using given serializer
and expectedRepresentation. |
|
SerializedType |
typeForClass(Class type)
Returns the type identifier for the given class. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MessageSerializer(Serializer serializer)
serializer - the serializer to serialize and deserialize objects with| Method Detail |
|---|
public static <T> SerializedObject<T> serializePayload(Message<?> message,
Serializer serializer,
Class<T> expectedRepresentation)
message using given serializer
and expectedRepresentation. This method will verify if the eventMessage is SerializationAware.
T - The data type to serialize tomessage - The message containing the payload to serializeserializer - The serializer to serialize the payload withexpectedRepresentation - The data type to serialize to
public static <T> SerializedObject<T> serializeMetaData(Message<?> message,
Serializer serializer,
Class<T> expectedRepresentation)
message using given
serializer and expectedRepresentation. This method will verify if the
eventMessage is SerializationAware.
T - The data type to serialize tomessage - The message containing the meta data to serializeserializer - The serializer to serialize the meta data withexpectedRepresentation - The data type to serialize to
public <T> SerializedObject<T> serializePayload(Message<?> message,
Class<T> expectedRepresentation)
message to the given expectedRepresentation.
T - The representation of the serialized datamessage - The message containing the payload to serializeexpectedRepresentation - The representation of the serialized data
public <T> SerializedObject<T> serializeMetaData(Message<?> message,
Class<T> expectedRepresentation)
message to the given expectedRepresentation.
T - The representation of the serialized datamessage - The message containing the meta data to serializeexpectedRepresentation - The representation of the serialized data
public <T> SerializedObject<T> serialize(Object object,
Class<T> expectedRepresentation)
Serializerobject into a Serialized Object containing the given
expectedRepresentation.
Use Serializer.canSerializeTo(Class) to detect whether the expectedRepresentation is supported by
this serializer.
serialize in interface SerializerT - The expected data type representing the serialized objectobject - The object to serializeexpectedRepresentation - The expected data type representing the serialized object
public <T> boolean canSerializeTo(Class<T> expectedRepresentation)
SerializerexpectedRepresentation.
When true, this does *not* guarantee that the serialization and (optional) conversion will also
succeed when executed. For example, when a serializer produces a byte[] containing JSON, trying to
convert to a Dom4J Document will fail, even though this serializer has a converter to convert
byte[]
to Dom4J instances.
canSerializeTo in interface SerializerT - The type of data a Serialized Object should containexpectedRepresentation - The type of data a Serialized Object should contain
true if the expectedRepresentation is supported, otherwise false.public <S,T> T deserialize(SerializedObject<S> serializedObject)
Serializerbytes. The bytes are not consumed
from the array or modified in any way. The resulting object instance is cast to the expected type.
deserialize in interface SerializerS - The data type of the serialized objectT - The expected deserialized typeserializedObject - the instance describing the type of object and the bytes providing the serialized data
public Class classForType(SerializedType type)
Serializertype is an instance of the returned Class.
If a class cannot be resolved (i.e. because the class is not available on this JVM's classpath) this method
throws UnknownSerializedTypeException.
classForType in interface Serializertype - The type identifier of the object
public SerializedType typeForClass(Class type)
SerializerSerializer.serialize(Object, Class).
typeForClass in interface Serializertype - Class representing the type of the serializable Object.
public ConverterFactory getConverterFactory()
Serializer
getConverterFactory in interface Serializer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||