Class XStreamSerializer.Builder
- Enclosing class:
XStreamSerializer
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.
-
Field Summary
Fields inherited from class org.axonframework.serialization.AbstractXStreamSerializer.Builder
xStream -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aXStreamSerializeras specified through this Builder.Sets theCharsetused for the in- and output streams required byXStreamfor the to and from xml function calls.classLoader(ClassLoader classLoader) Sets theConverterused as a converter factory providing converter instances utilized by upcasters to convert between different content types.Configures the underlyingXStreaminstance to not include Axon's classes by default.Disables the caching of the names for classes which couldn't be resolved to a class.Configures the underlying XStream instance to be lenient when deserializing data into Java objects.revisionResolver(RevisionResolver revisionResolver) Sets theRevisionResolverused to resolve the revision from an object to be serialized.xStream(com.thoughtworks.xstream.XStream xStream) Sets theXStreamused to perform the serialization of objects to XML, and vice versa.Methods inherited from class org.axonframework.serialization.AbstractXStreamSerializer.Builder
validate
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
xStream
Sets theXStreamused to perform the serialization of objects to XML, and vice versa. Defaults to aXStream(HierarchicalStreamDriver)call, providing theCompactDriver.- Overrides:
xStreamin classAbstractXStreamSerializer.Builder- Parameters:
xStream- theXStreamused to perform the serialization of objects to XML, and vice versa- Returns:
- the current Builder instance, for fluent interfacing
-
charset
Description copied from class:AbstractXStreamSerializer.BuilderSets theCharsetused for the in- and output streams required byXStreamfor the to and from xml function calls. Defaults to aCharset.forName(String)using theUTF-8character set.- Overrides:
charsetin classAbstractXStreamSerializer.Builder- Parameters:
charset- theCharsetused for the in- and output streams required byXStream- Returns:
- the current Builder instance, for fluent interfacing
-
revisionResolver
Description copied from class:AbstractXStreamSerializer.BuilderSets theRevisionResolverused to resolve the revision from an object to be serialized. Defaults to anAnnotationRevisionResolverwhich resolves the revision based on the contents of theRevisionannotation on the serialized classes.- Overrides:
revisionResolverin classAbstractXStreamSerializer.Builder- Parameters:
revisionResolver- aRevisionResolverused to resolve the revision from an object to be serialized- Returns:
- the current Builder instance, for fluent interfacing
-
converter
Description copied from class:AbstractXStreamSerializer.BuilderSets theConverterused as a converter factory providing converter instances utilized by upcasters to convert between different content types. Defaults to aChainingConverter.- Overrides:
converterin classAbstractXStreamSerializer.Builder- Parameters:
converter- aConverterused as a converter factory providing converter instances utilized by upcasters to convert between different content types- Returns:
- the current Builder instance, for fluent interfacing
-
classLoader
Description copied from class:AbstractXStreamSerializer.BuilderSets theClassLoaderused as an override for defaultClassLoaderused in theXStream. The same solution could thus be achieved by configuring the `XStream` instance directly.- Overrides:
classLoaderin classAbstractXStreamSerializer.Builder- Parameters:
classLoader- aClassLoaderused as a class loader inXStream- Returns:
- the current Builder instance, for fluent interfacing
-
lenientDeserialization
Description copied from class:AbstractXStreamSerializer.BuilderConfigures the underlying XStream instance to be lenient when deserializing data into Java objects. Specifically sets theXStream.ignoreUnknownElements().- Overrides:
lenientDeserializationin classAbstractXStreamSerializer.Builder- Returns:
- the current Builder instance, for fluent interfacing
-
disableAxonTypeSecurity
Description copied from class:AbstractXStreamSerializer.BuilderConfigures the underlyingXStreaminstance to not include Axon's classes by default. Concretely, theXStream.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
XStreaminstance.- Overrides:
disableAxonTypeSecurityin classAbstractXStreamSerializer.Builder- Returns:
- the current Builder instance for fluent interfacing
-
disableCachingOfUnknownClasses
Description copied from class:AbstractXStreamSerializer.BuilderDisables the caching of the names for classes which couldn't be resolved to a class.It is recommended to disable this in case the class loading is dynamic, and classes that are not available at one point in time, may become available at any time later.
- Overrides:
disableCachingOfUnknownClassesin classAbstractXStreamSerializer.Builder- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aXStreamSerializeras specified through this Builder.- Returns:
- a
XStreamSerializeras specified through this Builder
-