org.axonframework.saga.repository
Class XStreamSagaSerializer

java.lang.Object
  extended by org.axonframework.saga.repository.XStreamSagaSerializer
All Implemented Interfaces:
SagaSerializer

public class XStreamSagaSerializer
extends Object
implements SagaSerializer

Implementation of the SagaSerializer that uses XStream to serialize Saga instances to XML. The serialized form returned by this serializer is more flexible, making it safe to use if the Saga's class definition needs to change, and existing Sagas need to be converted.

Since:
0.7
Author:
Allard Buijze

Constructor Summary
XStreamSagaSerializer()
          Initialize an XStreamSagaSerializer with UTF-8 character set and default XStream instance.
XStreamSagaSerializer(Charset charset, com.thoughtworks.xstream.XStream xStream)
          Initialize an XStreamSagaSerializer with given charset and xStream instance.
XStreamSagaSerializer(com.thoughtworks.xstream.XStream xStream)
          Initialize an XStreamSagaSerializer with UTF-8 character set and the given xStream instance.
 
Method Summary
 Saga deserialize(byte[] serializedSaga)
          Deserializes the given serializedSaga.
 byte[] serialize(Saga saga)
          Serialize the given saga to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XStreamSagaSerializer

public XStreamSagaSerializer()
Initialize an XStreamSagaSerializer with UTF-8 character set and default XStream instance.


XStreamSagaSerializer

public XStreamSagaSerializer(com.thoughtworks.xstream.XStream xStream)
Initialize an XStreamSagaSerializer with UTF-8 character set and the given xStream instance.

Parameters:
xStream - The XStream instance to use. Default converters and aliases will be registered to it.

XStreamSagaSerializer

public XStreamSagaSerializer(Charset charset,
                             com.thoughtworks.xstream.XStream xStream)
Initialize an XStreamSagaSerializer with given charset and xStream instance.

Parameters:
charset - The character set to use to convert the XML to bytes.
xStream - The XStream instance to use. Default converters and aliases will be registered to it.
Method Detail

serialize

public byte[] serialize(Saga saga)
Description copied from interface: SagaSerializer
Serialize the given saga to a byte array.

Specified by:
serialize in interface SagaSerializer
Parameters:
saga - The saga to serialize
Returns:
The bytes representing the serialized form of the Saga

deserialize

public Saga deserialize(byte[] serializedSaga)
Description copied from interface: SagaSerializer
Deserializes the given serializedSaga.

Specified by:
deserialize in interface SagaSerializer
Parameters:
serializedSaga - the bytes representing the serialized form of a Saga
Returns:
The Saga instance represented by the given bytes


Copyright © 2011. All Rights Reserved.