Quantcast

Static method in route?

classic Classic list List threaded Threaded
2 messages Options
Tim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Static method in route?

Tim
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?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Static method in route?

Claus Ibsen-2
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 <[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Loading...