public static class XStreamSerializer.Builder extends AbstractXStreamSerializer.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 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 XStreamSerializer.registerConverters(ChainingConverter)
function will be called. This will register the Dom4JToByteArrayConverter
, InputStreamToDom4jConverter
, XomToStringConverter
and InputStreamToXomConverter
to the Converter chain.
xStream
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
XStreamSerializer |
build()
Initializes a
XStreamSerializer as specified through this Builder. |
XStreamSerializer.Builder |
charset(Charset charset)
Sets the
Charset used for the in- and output streams required by XStream for the to and from
xml function calls. |
XStreamSerializer.Builder |
classLoader(ClassLoader classLoader)
|
XStreamSerializer.Builder |
converter(Converter converter)
Sets the
Converter used as a converter factory providing converter instances utilized by upcasters to
convert between different content types. |
XStreamSerializer.Builder |
disableAxonTypeSecurity()
Configures the underlying
XStream instance to not include Axon's classes by default. |
XStreamSerializer.Builder |
lenientDeserialization()
Configures the underlying XStream instance to be lenient when deserializing data into Java objects.
|
XStreamSerializer.Builder |
revisionResolver(RevisionResolver revisionResolver)
Sets the
RevisionResolver used to resolve the revision from an object to be serialized. |
XStreamSerializer.Builder |
xStream(com.thoughtworks.xstream.XStream xStream)
Sets the
XStream used to perform the serialization of objects to XML, and vice versa. |
validate
public XStreamSerializer.Builder xStream(@Nonnull com.thoughtworks.xstream.XStream xStream)
XStream
used to perform the serialization of objects to XML, and vice versa. Defaults to a XStream(HierarchicalStreamDriver)
call, providing the CompactDriver
.xStream
in class AbstractXStreamSerializer.Builder
xStream
- the XStream
used to perform the serialization of objects to XML, and vice versapublic XStreamSerializer.Builder charset(@Nonnull Charset charset)
AbstractXStreamSerializer.Builder
Charset
used for the in- and output streams required by XStream
for the to and from
xml function calls. Defaults to a Charset.forName(String)
using the UTF-8
character set.charset
in class AbstractXStreamSerializer.Builder
charset
- the Charset
used for the in- and output streams required by XStream
public XStreamSerializer.Builder revisionResolver(@Nonnull RevisionResolver revisionResolver)
AbstractXStreamSerializer.Builder
RevisionResolver
used to resolve the revision from an object to be serialized. Defaults to
an AnnotationRevisionResolver
which resolves the revision based on the contents of the Revision
annotation on the serialized classes.revisionResolver
in class AbstractXStreamSerializer.Builder
revisionResolver
- a RevisionResolver
used to resolve the revision from an object to be
serializedpublic XStreamSerializer.Builder converter(@Nonnull Converter converter)
AbstractXStreamSerializer.Builder
Converter
used as a converter factory providing converter instances utilized by upcasters to
convert between different content types. Defaults to a ChainingConverter
.converter
in class AbstractXStreamSerializer.Builder
converter
- a Converter
used as a converter factory providing converter instances utilized by
upcasters to convert between different content typespublic XStreamSerializer.Builder classLoader(@Nonnull ClassLoader classLoader)
AbstractXStreamSerializer.Builder
ClassLoader
used as an override for default ClassLoader
used in the XStream
.
The same solution could thus be achieved by configuring the `XStream` instance directly.classLoader
in class AbstractXStreamSerializer.Builder
classLoader
- a ClassLoader
used as a class loader in XStream
public XStreamSerializer.Builder lenientDeserialization()
AbstractXStreamSerializer.Builder
XStream.ignoreUnknownElements()
.lenientDeserialization
in class AbstractXStreamSerializer.Builder
public XStreamSerializer.Builder disableAxonTypeSecurity()
AbstractXStreamSerializer.Builder
XStream
instance to not include Axon's classes by default.
Concretely, the XStream.allowTypesByWildcard(String[])
method will not be invoked with "org.axonframework.**"
.
It is recommended to disable this setting when complete control is required over the allowed types in this
serializer's XStream
instance.
disableAxonTypeSecurity
in class AbstractXStreamSerializer.Builder
public XStreamSerializer build()
XStreamSerializer
as specified through this Builder.XStreamSerializer
as specified through this BuilderCopyright © 2010–2023. All rights reserved.