Repository: camel Updated Branches: refs/heads/master ec2e7ddab -> d6dca407a
Added Camel-castor docs to gitbook Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d6dca407 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d6dca407 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d6dca407 Branch: refs/heads/master Commit: d6dca407a5fd952b159f236c36a0f71a8277661b Parents: ec2e7dd Author: Andrea Cosentino <anco...@gmail.com> Authored: Fri Feb 12 16:22:37 2016 +0100 Committer: Andrea Cosentino <anco...@gmail.com> Committed: Fri Feb 12 16:22:37 2016 +0100 ---------------------------------------------------------------------- .../camel-castor/src/main/docs/castor.adoc | 150 +++++++++++++++++++ docs/user-manual/en/SUMMARY.md | 1 + 2 files changed, 151 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d6dca407/components/camel-castor/src/main/docs/castor.adoc ---------------------------------------------------------------------- diff --git a/components/camel-castor/src/main/docs/castor.adoc b/components/camel-castor/src/main/docs/castor.adoc new file mode 100644 index 0000000..0c930f5 --- /dev/null +++ b/components/camel-castor/src/main/docs/castor.adoc @@ -0,0 +1,150 @@ +[[Castor-Castor]] +Castor +~~~~~~ + +*Available as of Camel 2.1* + +Castor is a link:data-format.html[Data Format] which uses the +http://www.castor.org/[Castor XML library] to unmarshal an XML payload +into Java objects or to marshal Java objects into an XML payload. + +As usually you can use either Java DSL or Spring XML to work with Castor +Data Format. + +[[Castor-UsingtheJavaDSL]] +Using the Java DSL +^^^^^^^^^^^^^^^^^^ + +[source,java] +----------------------------- +from("direct:order"). + marshal().castor(). + to("activemq:queue:order"); +----------------------------- + +For example the following uses a named DataFormat of Castor which uses +default Castor data binding features. + +[source,java] +-------------------------------------------------- +CastorDataFormat castor = new CastorDataFormat (); + +from("activemq:My.Queue"). + unmarshal(castor). + to("mqseries:Another.Queue"); +-------------------------------------------------- + +If you prefer to use a named reference to a data format which can then +be defined in your Registry such as via your Spring XML file. e.g. + +[source,java] +------------------------------- +from("activemq:My.Queue"). + unmarshal("mycastorType"). + to("mqseries:Another.Queue"); +------------------------------- + +If you want to override default mapping schema by providing a mapping +file you can set it as follows. + +[source,java] +-------------------------------------------------- +CastorDataFormat castor = new CastorDataFormat (); +castor.setMappingFile("mapping.xml"); +-------------------------------------------------- + +Also if you want to have more control on Castor Marshaller and +Unmarshaller you can access them as below. + +[source,java] +------------------------- +castor.getMarshaller(); +castor.getUnmarshaller(); +------------------------- + +[[Castor-UsingSpringXML]] +Using Spring XML +^^^^^^^^^^^^^^^^ + +The following example shows how to use Castor to unmarshal using Spring +configuring the castor data type + +[source,java] +----------------------------------------------------------------------- +<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <unmarshal> + <castor validation="true" /> + </unmarshal> + <to uri="mock:result"/> + </route> +</camelContext> +----------------------------------------------------------------------- + +This example shows how to configure the data type just once and reuse it +on multiple routes. You have to set the <castor> element directly in +<camelContext>. + +[source,java] +----------------------------------------------------------------------- +<camelContext> +<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> + <dataFormats> + <castor id="myCastor"/> + </dataFormats> + + <route> + <from uri="direct:start"/> + <marshal ref="myCastor"/> + <to uri="direct:marshalled"/> + </route> + <route> + <from uri="direct:marshalled"/> + <unmarshal ref="myCastor"/> + <to uri="mock:result"/> + </route> + +</camelContext> +----------------------------------------------------------------------- + +[[Castor-Options]] +Options +^^^^^^^ + +Castor supports the following options + +[width="100%",cols="10%,10%,10%,70%",options="header",] +|======================================================================= +|Option |Type |Default |Description + +|encoding |String |UTF-8 |Encoding to use when marshalling an Object to XML + +|validation |Boolean |false |Whether validation is turned on or off. + +|mappingFile |String |null |Path to a Castor mapping file to load from the classpath. + +|packages |String[] |null |Add additional packages to Castor XmlContext + +|classNames |String[] |null |Add additional class names to Castor XmlContext +|======================================================================= + +[[Castor-Dependencies]] +Dependencies +^^^^^^^^^^^^ + +To use Castor in your camel routes you need to add the a dependency on +*camel-castor* which implements this data format. + +If you use maven you could just add the following to your pom.xml, +substituting the version number for the latest & greatest release (see +link:download.html[the download page for the latest versions]). + +[source,java] +--------------------------------------- +<dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-castor</artifactId> + <version>x.x.x</version> +</dependency> +--------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d6dca407/docs/user-manual/en/SUMMARY.md ---------------------------------------------------------------------- diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md index dacda7a..e27283e 100644 --- a/docs/user-manual/en/SUMMARY.md +++ b/docs/user-manual/en/SUMMARY.md @@ -102,6 +102,7 @@ * [Braintree](braintree.adoc) * [Cache](cache.adoc) * [Cassandraql](cassandra.adoc) + * [Castor](castor.adoc) * [CDI](cdi.adoc) * [JMS](jms.adoc) * [Metrics](metrics.adoc)