|
JAXB has been edited by willem jiang (Nov 24, 2008). Change summary: CAMEL-1074 return the JAXBElement value by default 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 <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:start"/> <unmarshal> <jaxb prettyPrint="true" contextPath="org.apache.camel.example"/> </unmarshal> <to uri="mock:result"/> </route> </camelContext> This example shows how to configure the data type just once and reuse it on multiple routes <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <dataFormats> <jaxb id="myJaxb" prettyPrint="true" contextPath="org.apache.camel.example"/> </dataFormats> <route> <from uri="direct:start"/> <marshal ref="myJaxb"/> <to uri="direct:marshalled"/> </route> <route> <from uri="direct:marshalled"/> <unmarshal ref="myJaxb"/> <to uri="mock:result"/> </route> </camelContext> Working with the ObjectFactoryIf you use XJC to create the java class from the schema, you will get a ObjectFactory for you JAXB context. Since the ObjectFactory uses JAXBElement |
Unsubscribe or edit your notifications preferences
