You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by bikehead <bi...@gmail.com> on 2013/02/27 14:50:15 UTC

Invoking a static bean method in my camel xml

Is it possible to invoke a static method to a class within my camel.xml
configuration?

For example I'd like to do something like:
<bean class="org.apache.log4j.MDC" method="put('dpservices.storyKey',
${body.urlKey})" />

Googleing shows an example of java route builder doing the equivilant of:
.bean(org.apache.log4j.MDC.class, "put('dpservices.storyKey',
${body.urlKey})"

when buiding the route, but I can't find any discussion of doing it in an
xml file


-Brian




--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-static-bean-method-in-my-camel-xml-tp5728228.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking a static bean method in my camel xml

Posted by bikehead <bi...@gmail.com>.
Actually some lucky guessing on my part yields the answer that doesn't
involve using an endpoint:
			<bean beanType="org.apache.log4j.MDC" method="put('dpservices.storyKey',
${body.md5})" />



--
View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-static-bean-method-in-my-camel-xml-tp5728228p5728241.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Invoking a static bean method in my camel xml

Posted by David Karlsen <da...@gmail.com>.
Yes, it's not very well documented.
Here is an example:

in the middle of a route I do:

<to uri="bean:org.apache.commons.lang3.StringUtils?method=substring(
${body}, 149 )" />

which will replace the body after the step in the route with the
substring 150 chars into the incoming payload.

2013/2/27 bikehead <bi...@gmail.com>:
> Is it possible to invoke a static method to a class within my camel.xml
> configuration?
>
> For example I'd like to do something like:
> <bean class="org.apache.log4j.MDC" method="put('dpservices.storyKey',
> ${body.urlKey})" />
>
> Googleing shows an example of java route builder doing the equivilant of:
> .bean(org.apache.log4j.MDC.class, "put('dpservices.storyKey',
> ${body.urlKey})"
>
> when buiding the route, but I can't find any discussion of doing it in an
> xml file
>
>
> -Brian
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Invoking-a-static-bean-method-in-my-camel-xml-tp5728228.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen