camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bgoetzmann <>
Subject Re: From File to POJO using JAXB
Date Tue, 02 Oct 2007 12:14:09 GMT

I only see now that when having camel-core jar in classpath, this installs
some converters, and in particular the converter File to InputStream!

In fact I've made a sample project based on the ETL example in order to show
the integration of XML files into a database using JAXB and JPA. Without
having camel-core in my class path I get an exception: I was unable to
unmashall a File to a POJO using JAXB. With the converter in camel-core it's
the content of the file that is unmarshalled to a POJO, and there, it was
possible to send this POJO to the jpa URI.

As you said James, it would be interesting to indicate explicit conversions
in routes.

I continue to explore Camel, this very interesting project!

bgoetzmann wrote:
> Thank you James,
> Looking at the source code of the FallbackTypeConverter's unmarshall
> method class, I don't see where the content file is unmarshalled to the
> POJO. Perhaps the file object is first converted to InputStream?
> Bertrand.
> James.Strachan wrote:
>> On 28/09/2007, bgoetzmann <> 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...)
>> -- 
>> James
>> -------
>> Open Source SOA

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message