org.axonframework.serializer.bson
Class DBObjectXStreamSerializer

java.lang.Object
  extended by org.axonframework.serializer.AbstractXStreamSerializer
      extended by org.axonframework.serializer.bson.DBObjectXStreamSerializer
All Implemented Interfaces:
Serializer

public class DBObjectXStreamSerializer
extends AbstractXStreamSerializer

XStream based serializer implementation that serializes objects into a Binary JSON structure. This serializer is originally meant for use with a MongoDB based Event Store. It escapes BSON Node names to prevent them containing periods (".").

Since:
2.0
Author:
Allard Buijze

Constructor Summary
DBObjectXStreamSerializer()
          Initialize the serializer with UTF-8 character set and a default XStream serializer.
DBObjectXStreamSerializer(Charset charset)
          Initialize the serializer using the given charset.
DBObjectXStreamSerializer(Charset charset, com.thoughtworks.xstream.XStream xStream)
          Initialize the serializer using the given charset and xStream instance.
DBObjectXStreamSerializer(Charset charset, com.thoughtworks.xstream.XStream xStream, RevisionResolver revisionResolver)
          Initialize the serializer using the given charset, xStream and revisionResolver instance.
DBObjectXStreamSerializer(Charset charset, com.thoughtworks.xstream.XStream xStream, RevisionResolver revisionResolver, ConverterFactory converterFactory)
          Initialize the serializer using the given charset and xStream instance.
DBObjectXStreamSerializer(com.thoughtworks.xstream.XStream xStream)
          Initialize the serializer using the UTF-8 character set.
DBObjectXStreamSerializer(com.thoughtworks.xstream.XStream xStream, RevisionResolver revisionResolver)
          Initialize the serializer using the UTF-8 character set.
 
Method Summary
protected  Object doDeserialize(SerializedObject serializedObject, com.thoughtworks.xstream.XStream xStream)
          Deserialize the given serializedObject.
protected
<T> T
doSerialize(Object object, Class<T> expectedFormat, com.thoughtworks.xstream.XStream xStream)
          Serialize the given object to the given expectedFormat.
protected  void registerConverters(ChainingConverterFactory converterFactory)
          Registers any converters that are specific to the type of content written by this serializer.
 
Methods inherited from class org.axonframework.serializer.AbstractXStreamSerializer
addAlias, addFieldAlias, addPackageAlias, canSerializeTo, classForType, convert, deserialize, getCharset, getConverterFactory, getXStream, serialize, typeForClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBObjectXStreamSerializer

public DBObjectXStreamSerializer()
Initialize the serializer with UTF-8 character set and a default XStream serializer.

An AnnotationRevisionResolver is used to resolve revision for serialized objects.


DBObjectXStreamSerializer

public DBObjectXStreamSerializer(com.thoughtworks.xstream.XStream xStream)
Initialize the serializer using the UTF-8 character set. The provided XStream instance is used to perform the serialization.

An AnnotationRevisionResolver is used to resolve the revision for serialized objects.

Parameters:
xStream - XStream instance to use

DBObjectXStreamSerializer

public DBObjectXStreamSerializer(com.thoughtworks.xstream.XStream xStream,
                                 RevisionResolver revisionResolver)
Initialize the serializer using the UTF-8 character set. The provided XStream instance is used to perform the serialization, while the given revisionResolver is used to resolve the revision of the serialized object.

Parameters:
xStream - The XStream instance to serialize objects with
revisionResolver - The instance to resolve revisions with

DBObjectXStreamSerializer

public DBObjectXStreamSerializer(Charset charset)
Initialize the serializer using the given charset. A default XStream instance (with XppDriver) is used to perform the serialization.

An AnnotationRevisionResolver is used to resolve the revision for serialized objects.

Parameters:
charset - The character set to use

DBObjectXStreamSerializer

public DBObjectXStreamSerializer(Charset charset,
                                 com.thoughtworks.xstream.XStream xStream)
Initialize the serializer using the given charset and xStream instance. The xStream instance is configured with several converters for the most common types in Axon.

An AnnotationRevisionResolver is used to resolve the revision for serialized objects.

Parameters:
charset - The character set to use
xStream - The XStream instance to use

DBObjectXStreamSerializer

public DBObjectXStreamSerializer(Charset charset,
                                 com.thoughtworks.xstream.XStream xStream,
                                 RevisionResolver revisionResolver)
Initialize the serializer using the given charset, xStream and revisionResolver instance. The xStream instance is configured with several converters for the most common types in Axon.

Parameters:
charset - The character set to use
xStream - The XStream instance to use
revisionResolver - The instance to resolve revisions with

DBObjectXStreamSerializer

public DBObjectXStreamSerializer(Charset charset,
                                 com.thoughtworks.xstream.XStream xStream,
                                 RevisionResolver revisionResolver,
                                 ConverterFactory converterFactory)
Initialize the serializer using the given charset and xStream instance. The given converterFactory instance is used to convert between serialized representation types.

Parameters:
charset - The character set to use
xStream - The XStream instance to use
revisionResolver - The strategy to use to resolve the revision of an object
converterFactory - The converter factory to provide the converters
Method Detail

registerConverters

protected void registerConverters(ChainingConverterFactory converterFactory)
Description copied from class: AbstractXStreamSerializer
Registers any converters that are specific to the type of content written by this serializer.

Specified by:
registerConverters in class AbstractXStreamSerializer
Parameters:
converterFactory - the ConverterFactory to register the converters with

doSerialize

protected <T> T doSerialize(Object object,
                            Class<T> expectedFormat,
                            com.thoughtworks.xstream.XStream xStream)
Description copied from class: AbstractXStreamSerializer
Serialize the given object to the given expectedFormat. The subclass may use AbstractXStreamSerializer.convert(Class, Class, Object) to convert the result of the serialization to the expected type.

Specified by:
doSerialize in class AbstractXStreamSerializer
Type Parameters:
T - The format in which the serialized object must be returned
Parameters:
object - The object to serialize
expectedFormat - The format in which the serialized object must be returned
xStream - The XStream instance to serialize with
Returns:
The serialized object

doDeserialize

protected Object doDeserialize(SerializedObject serializedObject,
                               com.thoughtworks.xstream.XStream xStream)
Description copied from class: AbstractXStreamSerializer
Deserialize the given serializedObject.

Specified by:
doDeserialize in class AbstractXStreamSerializer
Parameters:
serializedObject - The instance containing the serialized format of the object
xStream - The XStream instance to deserialize with
Returns:
the deserialized object


Copyright © 2010-2016. All Rights Reserved.