Package org.axonframework.serialization
Class JavaSerializer
java.lang.Object
org.axonframework.serialization.JavaSerializer
- All Implemented Interfaces:
Serializer
Deprecated.
Serializer implementation that uses Java serialization to serialize and deserialize object instances. This
implementation is very suitable if the life span of the serialized objects allows classes to remain unchanged. If
Class definitions need to be changed during the object's life cycle, another implementation, like the
XStreamSerializer might be a more suitable alternative.- Since:
- 2.0
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.Builder class to instantiate aJavaSerializer. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJavaSerializer(JavaSerializer.Builder builder) Deprecated.Instantiate aJavaSerializerbased on the fields contained in theJavaSerializer.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic JavaSerializer.Builderbuilder()Deprecated.Instantiate a Builder to be able to create aJavaSerializer.<T> booleancanSerializeTo(Class<T> expectedRepresentation) Deprecated.Indicates whether this Serializer is capable of serializing to the givenexpectedRepresentation.classForType(SerializedType type) Deprecated.Returns the class for the given type identifier.<S,T> T deserialize(SerializedObject<S> serializedObject) Deprecated.Deserializes the first object read from the givenbytes.Deprecated.Returns theConverterused by this Serializer to convert between serialized representations.<T> SerializedObject<T> Deprecated.Serialize the givenobjectinto a Serialized Object containing the givenexpectedRepresentation.typeForClass(Class type) Deprecated.Returns the type identifier for the given class.
-
Constructor Details
-
JavaSerializer
Deprecated.Instantiate aJavaSerializerbased on the fields contained in theJavaSerializer.Builder.- Parameters:
builder- theJavaSerializer.Builderused to instantiate aJavaSerializerinstance
-
-
Method Details
-
builder
Deprecated.Instantiate a Builder to be able to create aJavaSerializer.The
RevisionResolveris defaulted to anSerialVersionUIDRevisionResolver.- Returns:
- a Builder to be able to create a
JavaSerializer
-
serialize
Deprecated.Description copied from interface:SerializerSerialize the givenobjectinto a Serialized Object containing the givenexpectedRepresentation. UseSerializer.canSerializeTo(Class)to detect whether theexpectedRepresentationis supported by this serializer.- Specified by:
serializein interfaceSerializer- Type Parameters:
T- The expected data type representing the serialized object- Parameters:
instance- The object to serializeexpectedType- The expected data type representing the serialized object- Returns:
- the instance representing the serialized object.
-
canSerializeTo
Deprecated.Description copied from interface:SerializerIndicates whether this Serializer is capable of serializing to the givenexpectedRepresentation. Whentrue, this does *not* guarantee that the serialization and (optional) conversion will also succeed when executed. For example, when a serializer produces abyte[]containing JSON, trying to convert to a Dom4J Document will fail, even though this serializer has a converter to convertbyte[]to Dom4J instances.- Specified by:
canSerializeToin interfaceSerializer- Type Parameters:
T- The type of data a Serialized Object should contain- Parameters:
expectedRepresentation- The type of data a Serialized Object should contain- Returns:
trueif theexpectedRepresentationis supported, otherwisefalse.
-
deserialize
Deprecated.Description copied from interface:SerializerDeserializes the first object read from the givenbytes. Thebytesare not consumed from the array or modified in any way. The resulting object instance is cast to the expected type.- Specified by:
deserializein interfaceSerializer- Type Parameters:
S- The data type of the serialized objectT- The expected deserialized type- Parameters:
serializedObject- the instance describing the type of object and the bytes providing the serialized data- Returns:
- the serialized object, cast to the expected type
-
classForType
Deprecated.Description copied from interface:SerializerReturns the class for the given type identifier. The result of this method must guarantee that the deserialized SerializedObject with the giventypeis 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 returns anUnknownSerializedTypeinstance which proides access to the raw underlying data.- Specified by:
classForTypein interfaceSerializer- Parameters:
type- The type identifier of the object- Returns:
- the Class representing the type of the serialized Object
-
typeForClass
Deprecated.Description copied from interface:SerializerReturns the type identifier for the given class. This is the type identifier of the Serialized object as returned bySerializer.serialize(Object, Class).- Specified by:
typeForClassin interfaceSerializer- Parameters:
type- Class representing the type of the serializable Object.- Returns:
- The type identifier of the object
-
getConverter
Deprecated.Description copied from interface:SerializerReturns theConverterused by this Serializer to convert between serialized representations. Generally, this Converter depends on the type of data the serializer serializes to.- Specified by:
getConverterin interfaceSerializer- Returns:
- the converter used by this Serializer
-
XStreamSerializerandJacksonSerializer, as direct Java serialization is relatively error prone. We hence strongly encourage to use either the XStream or Jackson solution in favor of thisSerializerimplementation.