camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: From File to POJO using JAXB
Date Mon, 01 Oct 2007 15:47:14 GMT
On 28/09/2007, bgoetzmann <bgoetzmann@sophia.symag.com> wrote:
>
> Hello,
>
> Looking at the ETL example that is impressive, I see that a detected file is
> converted to a POJO ; this is defined a route declared in the EtlRoutes
> class:
>
> from("file:src/data?noop=true").convertBodyTo(PersonDocument.class)...
>
> I know that when a file is detected in the src folder the body of the
> message that comes in is of type File ; how the XML content of this file is
> converted (marshalled) to the POJO PersonDocument that has JAXB annotations?
> Can I have more details, for example how Camel knows that it has to marshall
> using JAXB?
>
> Thank you!

If camel-jaxb.jar is on the classpath it installs a
FallbackTypeConverter which looks at the requested type and if its a
JAXB2 POJO (i.e. has an @XmlRootElement) then it tries to convert the
body to the JAXB2 POJO using JAXB.

We should probably add the concept of explicit message Source (input
format) and Sink (output format) to make this a little more explicit
and a little less magic. (I've spun up a separate thread on this...)

http://www.nabble.com/musings-on-Source-Sink-integration-%28e.g.-serialization-v-JAXB2-v-SOAP-encoding-etc%29-tf4548713s22882.html

-- 
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com

Mime
View raw message