camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: BeanInfo.chooseMethodWithMatchingBody throws an AmbiguousMethodCallException when there's no ambiguity
Date Mon, 13 Oct 2008 18:00:37 GMT
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.


Mime
View raw message