camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vegi, Vamsi (MAN-Corporate-CON)" <>
Subject RE: how is the automatica type conversion happening
Date Tue, 21 May 2013 12:38:49 GMT
Thank you,
Well CompanyMsg is indeed a JaxB annotated. it is generated by the XJC compiler.
But here is the question:
Does Camel creates the JaxBContext every time? You know, that is an expensive operation. 
I am talking about performance tuning here.
If that was already taken care of, great.

in case, it is not taken care of, how can I use spring bean (JaxBContext) and give it to Camel
for it to use the type conversion.

Thanks much


-----Original Message-----
From: Claus Ibsen [] 
Sent: Tuesday, May 21, 2013 1:13 AM
Subject: Re: how is the automatica type conversion happening


Its the type converter that kicks in

There is a fallback converter for JAXB so when you declare the method signature to have CompanyMsg
as parameter type, then Camel will try to convert the message body to this type. And as CompanyMsg
is a JAXB annotated class, then JAXB kicks-in.

On Mon, May 20, 2013 at 7:22 PM, Vegi, Vamsi (MAN-Corporate-CON) <>
> Hello
> I am confused how the camel framework is automatically unmarshalling 
> the XML file into an JaxB object Here is my Configurator, with the 
> route def
> ======================================================================
> @Override
> public void configure() throws Exception {
>"CompanyMsgRouter: configure called");
>   try {
>        jaxbContext = JAXBContext.newInstance(CompanyMsg.class);
>        jaxbUnmarshaller = jaxbContext.createUnmarshaller();
>   } catch (JAXBException e) {
> e.printStackTrace();
>   }
> from("file:C:\\camel\\files\\in?noop=true") // contains XML Msg
> .routeId(READ_Q_ROUTE_ID)
> .log(LoggingLevel.INFO, "uploading file:${header.CamelFilePath}") 
> .bean(new TransformSvcCompanyMsg(), "getCompleteCompanyDao"); // 
> expects JAXB object here
> }
> ======================================================================
> The method: getCompleteCompanyDao has the signature like like public 
> Company getCompleteCompanyDao(final CompanyMsg compMsg) {
> :
> :
> }
> Question is: when I run the app, it works fine, but I am confused as when and where the
unmarshalling is happening.
> I am not explicitly calling the JaxB unmarshaller Is it using the 
> jaxBUnMarshaller that I had previously defined?
> Btw, all the needed JaxB classes are in the path.
> -thanks
> -V

Claus Ibsen
----------------- The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Twitter: davsclaus
Author of Camel in Action:

View raw message