|
JAXB has been edited by Claus Ibsen (Jan 21, 2009). Content:JAXBJAXB is a Data Format which uses the JAXB2 XML marshalling standard which is included in Java 6 to unmarshal an XML payload into Java objects or to marshal Java objects into an XML payload. Using the Java DSLFor example the following uses a named DataFormat of jaxb which is configured with a number of Java package names to initialize the JAXBContext DataFormat jaxb = new JaxbDataFormat("com.acme.model"); from("activemq:My.Queue"). unmarshal(jaxb). to("mqseries:Another.Queue"); You can if you prefer 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. from("activemq:My.Queue"). unmarshal("myJaxbDataType"). to("mqseries:Another.Queue"); Using Spring XMLThe following example shows how to use JAXB to unmarshal using Spring configuring the jaxb data type An error occurred: http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/springDataFormat.xml. The system administrator has been notified.This example shows how to configure the data type just once and reuse it on multiple routes An error occurred: http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml. The system administrator has been notified.Working with the ObjectFactoryIf you use XJC to create the java class from the schema, you will get an ObjectFactory for you JAXB context. Since the ObjectFactory uses JAXBElement DependenciesTo use JAXB in your camel routes you need to add the a dependency on camel-jaxb 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 the download page for the latest versions). <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jaxb</artifactId> <version>1.5.0</version> </dependency> |
Unsubscribe or edit your notifications preferences
