Hi,

I don't think you are follow the right practice of generic type,  the type 
information will be erase after compile.
 Camel cannot tell which method will be used finally, as the method parameter 
are same with Collections.

I think you can define a FactoryBean to create the instance of 
CollectionTransform like this

class CollectionTransformerFactoryBean implements 
FactoryBean<Transformer<String, Long>> {

  public Transformer<String, Long> getObject() throws Exception {
     return new CollectionTransformer<String, Long>;
  }

   …...
}
--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: willemjiang





On Friday, October 12, 2012 at 3:53 AM, swwyatt wrote:

> I have a setup resembling:
>  
> public interface Transformer<I,O> {
> public O transform(I input);
> }
>  
> public class CollectionTransformer<I, O> implements
> Transformer<Collection&lt;I>, O> {
> private Factory<String, O> factory;
>  
> @Override
> public O transform(Collection input) {
> return factory.create("something");
> }
> }
>  
> public class AnotherCollectionTransformer extends
> CollectionTransformer<String, Long> {
> @Override
> public Long transform(Collection<String> input) {
> return super.transform(input);
> }
> }
>  
> <bean id="transformer" class="AnotherCollectionTransformer" />
>  
> <route>
> <from uri="direct:aaa" />
> <bean ref="transformer" method="transform" />
> </route>
>  
>  
> I get an error similar to this:
>  
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous
> method invocations possible: [public java.lang.Long
> AnotherCollectionTransformer.transform(java.util.Collection), public
> java.lang.Object CollectionTransformer.transform(java.util.Collection)].
> Exchange[Message: java.lang.String@21faa3c5]
>  
> How can I get this to choose the subclass method?
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/AmbiguousMethodCallException-on-override-methods-tp5720931.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).



Reply via email to