open class XStreamMarshaller : AbstractMarshaller, BeanClassLoaderAware, InitializingBean
Implementation of the Marshaller
interface for XStream.
By default, XStream does not require any further configuration and can (un)marshal any class on the classpath. As such, it is not recommended to use the XStreamMarshaller
to unmarshal XML from external sources (i.e. the Web), as this can result in security vulnerabilities. If you do use the XStreamMarshaller
to unmarshal external XML, set the supportedClasses
and converters
properties (possibly using a CatchAllConverter) or override the #customizeXStream(XStream)
method to make sure it only accepts the classes you want it to support.
Due to XStream's API, it is required to set the encoding used for writing to OutputStreams. It defaults to UTF-8
.
NOTE: XStream is an XML serialization library, not a data binding library. Therefore, it has limited namespace support. As such, it is rather unsuitable for usage within Web Services.
This marshaller requires XStream 1.4.5 or higher, as of Spring 4.3. Note that XStream construction has been reworked in 4.0, with the stream driver and the class loader getting passed into XStream itself now.
Author
Peter Meijer
Author
Arjen Poutsma
Author
Juergen Hoeller
Since
3.0
XStreamMarshaller()
Implementation of the By default, XStream does not require any further configuration and can (un)marshal any class on the classpath. As such, it is not recommended to use the Due to XStream's API, it is required to set the encoding used for writing to OutputStreams. It defaults to NOTE: XStream is an XML serialization library, not a data binding library. Therefore, it has limited namespace support. As such, it is rather unsuitable for usage within Web Services. This marshaller requires XStream 1.4.5 or higher, as of Spring 4.3. Note that XStream construction has been reworked in 4.0, with the stream driver and the class loader getting passed into XStream itself now. |
static val DEFAULT_ENCODING: String
The default encoding used for stream access: UTF-8. |
open fun afterPropertiesSet(): Unit |
|
fun getXStream(): XStream
Return the native XStream delegate used by this marshaller. NOTE: This method has been marked as final as of Spring 4.0. It can be used to access the fully configured XStream for marshalling but not configuration purposes anymore. |
|
open fun marshalOutputStream(graph: Any, outputStream: OutputStream): Unit open fun marshalOutputStream(graph: Any, outputStream: OutputStream, dataHolder: DataHolder): Unit |
|
open fun marshalWriter(graph: Any, writer: Writer): Unit open fun marshalWriter(graph: Any, writer: Writer, dataHolder: DataHolder): Unit |
|
open fun setAliases(aliases: MutableMap<String, *>): Unit
Set the alias/type map, consisting of string aliases mapped to classes. Keys are aliases; values are either |
|
open fun setAliasesByType(aliasesByType: MutableMap<String, *>): Unit
Set the aliases by type map, consisting of string aliases mapped to classes. Any class that is assignable to this type will be aliased to the same name. Keys are aliases; values are either |
|
open fun setAnnotatedClasses(vararg annotatedClasses: Class<*>): Unit
Set annotated classes for which aliases will be read from class-level annotation metadata. |
|
open fun setAutodetectAnnotations(autodetectAnnotations: Boolean): Unit
Activate XStream's autodetection mode. Note: Autodetection implies that the XStream instance is being configured while it is processing the XML streams, and thus introduces a potential concurrency problem. |
|
open fun setBeanClassLoader(classLoader: ClassLoader): Unit |
|
open fun setConverterLookup(converterLookup: ConverterLookup): Unit
Set a custom XStream ConverterLookup to use. Also used as ConverterRegistry if the given reference implements it as well. |
|
open fun setConverterRegistry(converterRegistry: ConverterRegistry): Unit
Set a custom XStream ConverterRegistry to use. |
|
open fun setConverters(vararg converters: ConverterMatcher): Unit
Set the |
|
open fun setEncoding(encoding: String): Unit
Set the encoding to be used for stream access. |
|
open fun setFieldAliases(fieldAliases: MutableMap<String, String>): Unit
Set the field alias/type map, consisting of field names. |
|
open fun setImplicitCollections(implicitCollections: MutableMap<Class<*>, String>): Unit
Specify implicit collection fields, as a Map consisting of |
|
open fun setMapper(mapper: Mapper): Unit
Set a custom XStream Mapper to use. |
|
open fun setMapperWrappers(vararg mapperWrappers: Class<out MapperWrapper>): Unit
Set one or more custom XStream MapperWrapper classes. Each of those classes needs to have a constructor with a single argument of type Mapper or MapperWrapper. |
|
open fun setMarshallingStrategy(marshallingStrategy: MarshallingStrategy): Unit
Set a custom XStream MarshallingStrategy to use. |
|
open fun setMode(mode: Int): Unit
Set the XStream mode to use. |
|
open fun setNameCoder(nameCoder: NameCoder): Unit
Set a custom XStream NameCoder to use. The default is an XmlFriendlyNameCoder. |
|
open fun setOmittedFields(omittedFields: MutableMap<Class<*>, String>): Unit
Specify omitted fields, as a Map consisting of |
|
open fun setReflectionProvider(reflectionProvider: ReflectionProvider): Unit
Set a custom XStream ReflectionProvider to use. |
|
open fun setStreamDriver(streamDriver: HierarchicalStreamDriver): Unit
Set a XStream HierarchicalStreamDriver to be used for readers and writers. As of Spring 4.0, this stream driver will also be passed to the XStream constructor and therefore used by streaming-related native API methods themselves. |
|
open fun setSupportedClasses(vararg supportedClasses: Class<*>): Unit
Set the classes supported by this marshaller. If this property is empty (the default), all classes are supported. |
|
open fun setUseAttributeFor(useAttributeFor: MutableMap<*, *>): Unit
Set the types to use XML attributes for. The given map can contain either |
|
open fun setUseAttributeForTypes(vararg useAttributeForTypes: Class<*>): Unit
Set types to use XML attributes for. |
|
open fun supports(clazz: Class<*>): Boolean |
|
open fun unmarshalInputStream(inputStream: InputStream): Any open fun unmarshalInputStream(inputStream: InputStream, dataHolder: DataHolder): Any |
|
open fun unmarshalReader(reader: Reader): Any open fun unmarshalReader(reader: Reader, dataHolder: DataHolder): Any |
open fun isProcessExternalEntities(): Boolean
Returns the configured value for whether XML external entities are allowed. |
|
open fun isSupportDtd(): Boolean
Whether DTD parsing is supported. |
|
fun marshal(graph: Any, result: Result): Unit
Marshals the object graph with the given root into the provided This implementation inspects the given result, and calls |
|
open fun setProcessExternalEntities(processExternalEntities: Boolean): Unit
Indicates whether external XML entities are processed when unmarshalling. Default is Note: setting this option to |
|
open fun setSupportDtd(supportDtd: Boolean): Unit
Indicates whether DTD parsing should be supported. Default is |
|
fun unmarshal(source: Source): Any
Unmarshals the given provided This implementation inspects the given result, and calls |