You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sriramch <sr...@consortemedia.com> on 2009/06/20 00:49:40 UTC
camel bean processor question
I am trying to route to a bean instance by specifying a method-name using
Camel 1.6. This specific route is defined as below:
<camel:bean ref="myBean" method="myMethod"/>
The method myMethod is overloaded
public void myMethod(){
}
public void myMethod(Date date){
}
Depending on how I order my methods in the class, either of these seem to be
getting picked up by the BeanProcessor. Is there any way I can force it to
use the method without any arguments? If this is not possible, what is a
good way to always pass null as the date parameter to the myMethod
invocation? Any pointers would be very helpful.
Thanks
Sriram
--
View this message in context: http://www.nabble.com/camel-bean-processor-question-tp24119905p24119905.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
Re: camel bean processor question
Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Jun 20, 2009 at 12:49 AM, sriramch <sr...@consortemedia.com> wrote:
>
> I am trying to route to a bean instance by specifying a method-name using
> Camel 1.6. This specific route is defined as below:
>
> <camel:bean ref="myBean" method="myMethod"/>
>
> The method myMethod is overloaded
>
> public void myMethod(){
> }
>
> public void myMethod(Date date){
> }
>
> Depending on how I order my methods in the class, either of these seem to
> be
> getting picked up by the BeanProcessor. Is there any way I can force it to
> use the method without any arguments? If this is not possible, what is a
> good way to always pass null as the date parameter to the myMethod
> invocation? Any pointers would be very helpful.
Hi
As there are 2 methods with the same name, you need to help Camel pick the
one.
You can add the @Body annotation to the one you want to invoke and Camel
will prefer this one.
But that would require you to define at least 1 parameter for the method.
public void myMethod(@Body Object body)
Otherwise you can always add a little delegate method that has a unique
name.
In Camel 2.0 we have added a @Handler annotation to the method itself as a
kind of "use this method please".
>
>
> Thanks
> Sriram
> --
> View this message in context:
> http://www.nabble.com/camel-bean-processor-question-tp24119905p24119905.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus