You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bruce Elmore <be...@qualcomm.com> on 2008/10/13 19:25:53 UTC

BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity

Here's a test case that illustrates the problem:

import junit.framework.Assert;
import junit.framework.TestCase;

import org.apache.camel.Exchange;
import org.apache.camel.component.bean.AmbiguousMethodCallException;
import org.apache.camel.component.bean.BeanInfo;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;


public class BeanInfoTest extends TestCase {
    protected DefaultCamelContext camelContext = new DefaultCamelContext();
    protected Exchange exchange = new DefaultExchange(camelContext);
    
	public void test() throws Exception {
		
		BeanInfo beanInfo = new BeanInfo(camelContext, Y.class);
		
		exchange.getIn().setBody(new Request());
		
		try {
			beanInfo.createInvocation(null, exchange);
		}
		catch(AmbiguousMethodCallException e)
		{
			Assert.fail("This should not be ambiguous!");
		}
	}
}

class Request {
	int x;
}

class X {
	
	public int process(Request request) {
		return 0;
	}
}

class Y extends X {
	
	@Override
	public int process(Request request ) {
		return 1;
	}
}

There should be no ambiguity here, since X.process() should be hidden by
Y.process(). This is causing me some issues, since I am using inheritance in
the beans invoked by my Camel routes. I can work around the issue using a
delegation pattern:

class Z {
	Y y = new Y();
	
	public int process(Request request ) {
		return y.process(request);
	}
}

But obviously, I'd rather not have to do this.
-- 
View this message in context: http://www.nabble.com/BeanInfo.chooseMethodWithMatchingBody-throws-an-AmbiguousMethodCallException-when-there%27s-no-ambiguity-tp19959124s22882p19959124.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi Bruce

I created the ticket and a candidate for a patch
https://issues.apache.org/activemq/browse/CAMEL-983

Please review and feedback is welcome.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Bruce Elmore [mailto:belmore@qualcomm.com] 
Sent: 13. oktober 2008 19:26
To: camel-user@activemq.apache.org
Subject: BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity


Here's a test case that illustrates the problem:

import junit.framework.Assert;
import junit.framework.TestCase;

import org.apache.camel.Exchange;
import org.apache.camel.component.bean.AmbiguousMethodCallException;
import org.apache.camel.component.bean.BeanInfo;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;


public class BeanInfoTest extends TestCase {
    protected DefaultCamelContext camelContext = new DefaultCamelContext();
    protected Exchange exchange = new DefaultExchange(camelContext);
    
	public void test() throws Exception {
		
		BeanInfo beanInfo = new BeanInfo(camelContext, Y.class);
		
		exchange.getIn().setBody(new Request());
		
		try {
			beanInfo.createInvocation(null, exchange);
		}
		catch(AmbiguousMethodCallException e)
		{
			Assert.fail("This should not be ambiguous!");
		}
	}
}

class Request {
	int x;
}

class X {
	
	public int process(Request request) {
		return 0;
	}
}

class Y extends X {
	
	@Override
	public int process(Request request ) {
		return 1;
	}
}

There should be no ambiguity here, since X.process() should be hidden by
Y.process(). This is causing me some issues, since I am using inheritance in
the beans invoked by my Camel routes. I can work around the issue using a
delegation pattern:

class Z {
	Y y = new Y();
	
	public int process(Request request ) {
		return y.process(request);
	}
}

But obviously, I'd rather not have to do this.
-- 
View this message in context: http://www.nabble.com/BeanInfo.chooseMethodWithMatchingBody-throws-an-AmbiguousMethodCallException-when-there%27s-no-ambiguity-tp19959124s22882p19959124.html
Sent from the Camel - Users mailing list archive at Nabble.com.


RE: BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity

Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi

Could you create a ticket in the bug tracker for this issue?


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Bruce Elmore [mailto:belmore@qualcomm.com] 
Sent: 13. oktober 2008 19:26
To: camel-user@activemq.apache.org
Subject: BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity


Here's a test case that illustrates the problem:

import junit.framework.Assert;
import junit.framework.TestCase;

import org.apache.camel.Exchange;
import org.apache.camel.component.bean.AmbiguousMethodCallException;
import org.apache.camel.component.bean.BeanInfo;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;


public class BeanInfoTest extends TestCase {
    protected DefaultCamelContext camelContext = new DefaultCamelContext();
    protected Exchange exchange = new DefaultExchange(camelContext);
    
	public void test() throws Exception {
		
		BeanInfo beanInfo = new BeanInfo(camelContext, Y.class);
		
		exchange.getIn().setBody(new Request());
		
		try {
			beanInfo.createInvocation(null, exchange);
		}
		catch(AmbiguousMethodCallException e)
		{
			Assert.fail("This should not be ambiguous!");
		}
	}
}

class Request {
	int x;
}

class X {
	
	public int process(Request request) {
		return 0;
	}
}

class Y extends X {
	
	@Override
	public int process(Request request ) {
		return 1;
	}
}

There should be no ambiguity here, since X.process() should be hidden by
Y.process(). This is causing me some issues, since I am using inheritance in
the beans invoked by my Camel routes. I can work around the issue using a
delegation pattern:

class Z {
	Y y = new Y();
	
	public int process(Request request ) {
		return y.process(request);
	}
}

But obviously, I'd rather not have to do this.
-- 
View this message in context: http://www.nabble.com/BeanInfo.chooseMethodWithMatchingBody-throws-an-AmbiguousMethodCallException-when-there%27s-no-ambiguity-tp19959124s22882p19959124.html
Sent from the Camel - Users mailing list archive at Nabble.com.