Class XStreamSerializer

  • All Implemented Interfaces:
    Serializer

    public class XStreamSerializer
    extends AbstractXStreamSerializer
    Serializer that uses XStream to serialize and deserialize arbitrary objects. The XStream instance is configured to deal with the Classes used in Axon Framework in the most compact fashion. When running on a Sun JVM, XStream does not pose any restrictions on classes to serialize. On other JVM's, however, you need to either implement Serializable, or provide a default constructor (accessible under the JVM's security policy). That means that for portability, you should do either of these two.
    Since:
    1.2
    Author:
    Allard Buijze
    See Also:
    XStream
    • Constructor Detail

      • XStreamSerializer

        public XStreamSerializer()
        Initialize a generic serializer using the UTF-8 character set. A default XStream instance (with XppDriver) is used to perform the serialization.
      • XStreamSerializer

        public XStreamSerializer​(RevisionResolver revisionResolver)
        Initialize a generic serializer using the UTF-8 character set. A default XStream instance (with XppDriver) is used to perform the serialization.
        Parameters:
        revisionResolver - The strategy to use to resolve the revision of an object
      • XStreamSerializer

        public XStreamSerializer​(com.thoughtworks.xstream.XStream xStream)
        Initialize a generic serializer using the UTF-8 character set. The provided XStream instance is used to perform the serialization.
        Parameters:
        xStream - XStream instance to use
      • XStreamSerializer

        public XStreamSerializer​(com.thoughtworks.xstream.XStream xStream,
                                 RevisionResolver revisionResolver)
        Initialize a generic serializer using the UTF-8 character set. The provided XStream instance is used to perform the serialization.
        Parameters:
        xStream - XStream instance to use
        revisionResolver - The strategy to use to resolve the revision of an object
      • XStreamSerializer

        public XStreamSerializer​(Charset charset)
        Initialize the serializer using the given charset. A default XStream instance (with XppDriver) is used to perform the serialization.
        Parameters:
        charset - The character set to use
      • XStreamSerializer

        public XStreamSerializer​(Charset charset,
                                 com.thoughtworks.xstream.XStream xStream,
                                 RevisionResolver revisionResolver)
        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.
        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
      • XStreamSerializer

        public XStreamSerializer​(Charset charset,
                                 com.thoughtworks.xstream.XStream xStream,
                                 RevisionResolver revisionResolver,
                                 Converter converter)
        Initialize the serializer using the given charset and xStream instance. The given converter is used to convert serialized objects for use by Upcasters. 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 strategy to use to resolve the revision of an object
        converter - The factory providing the converter instances for upcasters
    • Method Detail

      • 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(Object, Class, Class) 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

        public 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