public class XStreamSerializer extends AbstractXStreamSerializer
XStream
Modifier and Type | Class and Description |
---|---|
static class |
XStreamSerializer.Builder
Builder class to instantiate a
XStreamSerializer . |
Modifier | Constructor and Description |
---|---|
protected |
XStreamSerializer(XStreamSerializer.Builder builder)
Instantiate a
XStreamSerializer based on the fields contained in the XStreamSerializer.Builder . |
Modifier and Type | Method and Description |
---|---|
static XStreamSerializer.Builder |
builder()
Instantiate a Builder to be able to create a
XStreamSerializer . |
static XStreamSerializer |
defaultSerializer()
Deprecated.
in favor of using the
builder() to construct an instance using a configured XStream
instance. Using this shorthand still works, but will use an XStream instance that allows
everything. Although this works, XStream expects the types or wildcards for the types to be defined to ensure
the application stays secure. As such, it is highly recommended to follow their recommended approach. |
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(ChainingConverter converter)
Registers any converters that are specific to the type of content written by this serializer.
|
addAlias, addFieldAlias, addPackageAlias, canSerializeTo, classForType, convert, deserialize, getCharset, getConverter, getXStream, serialize, typeForClass
protected XStreamSerializer(XStreamSerializer.Builder builder)
XStreamSerializer
based on the fields contained in the XStreamSerializer.Builder
. The XStream
instance is configured with several converters for the most common types in Axon.builder
- the XStreamSerializer.Builder
used to instantiate a XStreamSerializer
instancepublic static XStreamSerializer.Builder builder()
XStreamSerializer
.
The XStream
is defaulted to a XStream(HierarchicalStreamDriver)
call, providing a CompactDriver
, the Charset
is defaulted to a Charset.forName(String)
using the UTF-8
character set, the RevisionResolver
defaults to an AnnotationRevisionResolver
and the Converter
defaults to a ChainingConverter
. Lastly, the builder adds Axon types for XStream's security
settings by including "org.axonframework.**
as a wildcard type. This can be disabled with the XStreamSerializer.Builder.disableAxonTypeSecurity()
operation when required.
Upon instantiation, several defaults aliases are added to the XStream instance, for example for the GenericDomainEventMessage
, the GenericCommandMessage
and the MetaData
objects among others. Additionally, a MetaData Converter is registered too.
Lastly, if the provided Converter instance is of type ChainingConverter, then the registerConverters(ChainingConverter)
function will be called. This will register the Dom4JToByteArrayConverter
, InputStreamToDom4jConverter
, XomToStringConverter
and InputStreamToXomConverter
to the Converter chain.
XStreamSerializer
@Deprecated public static XStreamSerializer defaultSerializer()
builder()
to construct an instance using a configured XStream
instance. Using this shorthand still works, but will use an XStream
instance that allows
everything. Although this works, XStream expects the types or wildcards for the types to be defined to ensure
the application stays secure. As such, it is highly recommended to follow their recommended approach.XStreamSerializer
.
The XStream
is defaulted to a XStream(HierarchicalStreamDriver)
call, providing a CompactDriver
, the Charset
is defaulted to a Charset.forName(String)
using the UTF-8
character set, the RevisionResolver
defaults to an AnnotationRevisionResolver
and the Converter
defaults to a ChainingConverter
. Lastly, the builder adds Axon types for XStream's security
settings by including "org.axonframework.**
as a wildcard type.
Upon instantiation, several defaults aliases are added to the XStream instance, for example for the GenericDomainEventMessage
, the GenericCommandMessage
and the MetaData
objects among others. Additionally, a MetaData Converter is registered too.
Lastly, if the provided Converter instance is of type ChainingConverter, then the registerConverters(ChainingConverter)
function will be called. This will register the Dom4JToByteArrayConverter
, InputStreamToDom4jConverter
, XomToStringConverter
and InputStreamToXomConverter
to the Converter chain.
XStreamSerializer
protected <T> T doSerialize(Object object, Class<T> expectedFormat, com.thoughtworks.xstream.XStream xStream)
AbstractXStreamSerializer
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.doSerialize
in class AbstractXStreamSerializer
T
- The format in which the serialized object must be returnedobject
- The object to serializeexpectedFormat
- The format in which the serialized object must be returnedxStream
- The XStream instance to serialize withpublic Object doDeserialize(SerializedObject serializedObject, com.thoughtworks.xstream.XStream xStream)
AbstractXStreamSerializer
serializedObject
.doDeserialize
in class AbstractXStreamSerializer
serializedObject
- The instance containing the serialized format of the objectxStream
- The XStream instance to deserialize withprotected void registerConverters(ChainingConverter converter)
AbstractXStreamSerializer
registerConverters
in class AbstractXStreamSerializer
converter
- the Converter to register the converters withCopyright © 2010–2022. All rights reserved.