Joe Fernandez created CAMEL-8463:
------------------------------------

             Summary: Have Camel Support Method Overloading With Implicit 
Binding Of Exchange
                 Key: CAMEL-8463
                 URL: https://issues.apache.org/jira/browse/CAMEL-8463
             Project: Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Joe Fernandez


Allow overloading of methods that accept a Camel exchange.

Suppose one defines a bean called “helloBean” with the following two methods:

{code}
public void hello(String first) 
public void hello(String first, String last) 
{code}
The following Camel route will distinguish one method from the other. 
{code}
from("timer://foo?repeatCount=1")
.beanRef("helloBean", "hello('Wilma')")
.beanRef("helloBean", "hello('Wilma','Flintstone')");
{code}
Now alter the two methods to have them accept a Camel Exchange, as follows:
{code}
public void hello(String first, Exchange ex1)
public void hello(String first, String last, Exchange ex1) 
{code}
The same Camel route will not be able to distinguish one method from the other. 
The route will throw either an AmbiguousMethodCallException or 
ParameterBindingException exception. 

If, on the other hand, you remove one of the methods, and alter the route 
accordingly, then the route will work just fine and the exchange will be 
implicitly passed to the method. For example, 

{code}
public void hello(String first, String last, Exchange ex1) 

from("timer://foo?repeatCount=1")
.beanRef("helloBean", "hello('Wilma','Flintstone')");
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to