camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: How to avoid a org.apache.camel.component.bean.AmbiguousMethodCallException when calling methods of a Bean component
Date Tue, 14 Jul 2009 09:16:01 GMT
On Tue, Jul 14, 2009 at 11:03 AM, James
Strachan<james.strachan@gmail.com> wrote:
> How is Camel meant to decide which method you want; if they are both
> annotated and both have the same name?
>

Yeah @Handler should only be added at one of them.

If the number of parameters differ we could add another option to bean
component to give a hint that X parameters is expected in these rare
cases where people
have overloaded methods.




> 2009/7/14 Charles Moulliard <cmoulliard@gmail.com>:
>> Even If I add the annotation @Handler on the two methods with the same name,
>> the error is generated
>>
>> Exception: org.apache.camel.component.bean.AmbiguousMethodCallException:
>> Ambiguous method invocations possible: [public java.util.List
>> com.xpectis.x3s.core.util.ServiceHelper.updateRequestStatus(java.lang.String,java.lang.String,java.util.List),
>> public void
>> com.xpectis.x3s.core.util.ServiceHelper.updateRequestStatus(java.lang.String,java.lang.String,java.lang.String,org.apache.camel.Exchange)]
>>
>> Charles Moulliard
>> Senior Enterprise Architect
>> Apache Camel Committer
>>
>> *****************************
>> blog : http://cmoulliard.blogspot.com
>>
>>
>> On Tue, Jul 14, 2009 at 10:27 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>>
>>> On Tue, Jul 14, 2009 at 10:25 AM, Charles Moulliard<cmoulliard@gmail.com>
>>> wrote:
>>> > Hi,
>>> >
>>> > Is there any other workaround except renaming the method "updatStatus" to
>>> > avoid to have an error : AmbiguousMethodCallException.
>>> >
>>> > In my example, I would like to allow to have two methods with the same
>>> name
>>> > but having different input parameters and return type
>>> >
>>> > Here is the route that I want to use :
>>> >
>>> > from(file)
>>> > .to(beanA) // Create Request
>>> > .to(beanB) // parse request
>>> > .to(queueA)
>>> >
>>> > from(queueA)
>>> > .to(beanC) // validate request
>>> > .to(beanD method="updateStatus") // update Status (input parameter : Body
>>> =
>>> > Request.class, return type = void)
>>> > .to(queueB)
>>> >
>>> > ...
>>> >
>>> > from(queueX)
>>> > .to(beanX)
>>> > .to(beanD method="updateStatus") // update Status (input parameter : Body
>>> =
>>> > Report.class, Header "requestId" String request ID, return type = void)
>>> >
>>> > Is it possible ?
>>> >
>>>
>>> Add @Handle to the method you want Camel to choose.
>>>
>>>
>>> > Regards,
>>> >
>>> > Charles Moulliard
>>> > Senior Enterprise Architect
>>> > Apache Camel Committer
>>> >
>>> > *****************************
>>> > blog : http://cmoulliard.blogspot.com
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message