|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.serializer.JavaSerializer
public class JavaSerializer
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.
Constructor Summary | |
---|---|
JavaSerializer()
Initialize the serializer using a SerialVersionUIDRevisionResolver, which uses the SerialVersionUID field of the serializable object as the Revision. |
|
JavaSerializer(RevisionResolver revisionResolver)
Initialize the serializer using a SerialVersionUIDRevisionResolver. |
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 instance,
Class<T> expectedType)
Serialize the given object into a Serialized Object containing the given
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 JavaSerializer()
public JavaSerializer(RevisionResolver revisionResolver)
revisionResolver
- The revision resolver providing the revision numbers for a given classMethod Detail |
---|
public <T> SerializedObject<T> serialize(Object instance, Class<T> expectedType)
Serializer
object
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 Serializer
T
- The expected data type representing the serialized objectinstance
- The object to serializeexpectedType
- The expected data type representing the serialized object
public <T> boolean canSerializeTo(Class<T> expectedRepresentation)
Serializer
expectedRepresentation
.
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 Serializer
T
- 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)
Serializer
bytes
. 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 Serializer
S
- 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)
Serializer
type
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 Serializer
type
- The type identifier of the object
public SerializedType typeForClass(Class type)
Serializer
Serializer.serialize(Object, Class)
.
typeForClass
in interface Serializer
type
- 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 |