You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tim <ch...@gmail.com> on 2011/08/26 01:22:27 UTC

Static method in route?

Is it possible to invoke a static method in the middle of the route without
having to use a processor or other wrapper?

Basically I have a simple static utility function that I want to invoke and
use it's results as a header.
Normally this would look like:

        from(someInput)
            .bean(someBean)
            .setHeader("someheader",
bean(willMakeHeaderInfoFromResultsOfSomeBean))
            .filter().method(someFilter)
            .bean(someOtherBean);

The method in willMakeHeaderInfoFromResultsOfSomeBean is short and can come
from a strategy enum which I want to use directly.
Sorry I can't find anything in the docs that mentions this but is this
possible directly from the route?

Re: Static method in route?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah Camel should be able to invoke any public method on a bean.
However the logic may favor using a bean instance when invoking the
method. (Will have to check that).
So in case of a static method, the code could be optimized, in case it wasn't.

Let me create a JIRA ticket so we wont forget.


On Fri, Aug 26, 2011 at 1:22 AM, Tim <ch...@gmail.com> wrote:
> Is it possible to invoke a static method in the middle of the route without
> having to use a processor or other wrapper?
>
> Basically I have a simple static utility function that I want to invoke and
> use it's results as a header.
> Normally this would look like:
>
>        from(someInput)
>            .bean(someBean)
>            .setHeader("someheader",
> bean(willMakeHeaderInfoFromResultsOfSomeBean))
>            .filter().method(someFilter)
>            .bean(someOtherBean);
>
> The method in willMakeHeaderInfoFromResultsOfSomeBean is short and can come
> from a strategy enum which I want to use directly.
> Sorry I can't find anything in the docs that mentions this but is this
> possible directly from the route?
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/