This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7f1b0b61c14074605138b322e09224dc10fda1c8 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Aug 7 09:33:26 2019 +0200 CAMEL-13740: Update xstream json docs --- .../src/main/docs/json-xstream-dataformat.adoc | 70 ++-------------------- 1 file changed, 4 insertions(+), 66 deletions(-) diff --git a/components/camel-xstream/src/main/docs/json-xstream-dataformat.adoc b/components/camel-xstream/src/main/docs/json-xstream-dataformat.adoc index ccc9a20..287be2e 100644 --- a/components/camel-xstream/src/main/docs/json-xstream-dataformat.adoc +++ b/components/camel-xstream/src/main/docs/json-xstream-dataformat.adoc @@ -5,7 +5,9 @@ XStream is a Data Format which uses the http://xstream.codehaus.org/[XStream library] to marshal and unmarshal -Java objects to and from XML. +Java objects to and from JSon. However XStream was created primary for working +with XML and therefore using JSon with XStream is not as popular as for example +Jackson is for JSon. To use XStream in your camel routes you need to add the a dependency on *camel-xstream* which implements this data format. @@ -62,7 +64,7 @@ The JSon XStream dataformat supports 19 options, which are listed below. ----------------------------------------------------------- // lets turn Object messages into XML then send to MQSeries from("activemq:My.Queue"). - marshal().xstream(). + marshal().json(JsonLibrary.XStream). to("mqseries:Another.Queue"); ----------------------------------------------------------- @@ -83,67 +85,3 @@ from("direct:marshal"). to("mock:marshaled"); --------------------------------------------------------- -== XMLInputFactory and XMLOutputFactory - -http://xstream.codehaus.org/[The XStream library] uses the -`javax.xml.stream.XMLInputFactory` and -`javax.xml.stream.XMLOutputFactory`, you can control which -implementation of this factory should be used. - -The Factory is discovered using this algorithm: - 1. Use the `javax.xml.stream.XMLInputFactory` , -`javax.xml.stream.XMLOutputFactory` system property. - 2. Use the `lib/xml.stream.properties` file in the `JRE_HOME` -directory. - 3. Use the Services API, if available, to determine the classname by -looking in the `META-INF/services/javax.xml.stream.XMLInputFactory`, -`META-INF/services/javax.xml.stream.XMLOutputFactory` files in jars -available to the JRE. - 4. Use the platform default XMLInputFactory,XMLOutputFactory instance. - -== How to set the XML encoding in Xstream DataFormat? - -You can set the encoding of XML in Xstream DataFormat -by setting the Exchange's property with the key `Exchange.CHARSET_NAME`, -or setting the encoding property on Xstream from DSL or Spring config. - -[source,java] -------------------------------- -from("activemq:My.Queue"). - marshal().xstream("UTF-8"). - to("mqseries:Another.Queue"); -------------------------------- - -== Setting the type permissions of Xstream DataFormat - -In Camel, one can always use its own processing step in the route to -filter and block certain XML documents to be routed to the XStream's -unmarhall step. You can set http://x-stream.github.io/security.html[XStream's type -permissions] to automatically allow or deny the instantiation of certain -types. - -The default type permissions setting used by Camel denies all types -except for those from java.lang and java.util packages. This setting can -be changed by setting System property -org.apache.camel.xstream.permissions. Its value is a string of -comma-separated permission terms, each representing a type being allowed -or denied, depending on whether the term is prefixed with '+' (note '+' -may be omitted) or with '-', respectively. - -Each term may contain a wildcard character '*'. For example, value -"-*,java.lang.*,java.util.*" indicates denying all types except for -java.lang.* and java.util.* classes. Setting this value to an empty -string "" reverts to the default XStream's type permissions handling -which denies certain blacklisted classes and allow others. - -The type permissions setting can be extended at an individual XStream -DataFormat instance by setting its type permissions property. - -[source,java] -------------------------------------------------------------------- - <dataFormats> - <xstream id="xstream-default" - permissions="org.apache.camel.samples.xstream.*"/> - ... - --------------------------------------------------------------------