简体   繁体   English

为什么我不能用常规将实现作为参数传递给采用其接口的方法?

[英]Why cant I, in groovy, pass a implementation as argument to a method that takes its interface?

I'm getting a 我正在

groovy.lang.MissingMethodException: No signature of method: org.apache.camel.builder.AdviceWithBuilder.replaceFromWith() is applicable for argument types: (org.apache.camel.component.direct.DirectEndpoint) values: [direct://start]

signature of the method is AdviceWithBuilder.replaceFromWith(Endpoint ep) Im passing in a DirectEndpoint that implements Endpoint I have tried to coerce it to Endpoint 该方法的签名是AdviceWithBuilder.replaceFromWith(Endpoint ep)我传入了实现Endpoint的DirectEndpoint ,我试图将其强制到Endpoint

@Test
void testSubmitDocument() {
    final Endpoint endpoint = context.getEndpoint("direct:start",Endpoint.class)
    camelContext.getRouteDefinitions().get(0).adviceWith(camelContext, 
         new AdviceWithRouteBuilder (){
             void configure(){
                 weaveById("bar").replaceFromWith(endpoint)
             }
        } 

    )
    }

因为AdviceWithRouteBuilder.weaveById(String pattern)返回AdviceWithBuilder ,但它没有replaceFromWith方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用方法参数超类的接口实现 - Interface implementation with method argument superclasses 爪哇。 如果在方法定义中参数是接口类型,为什么我可以传递对象参数? - Java. Why can i pass an object argument, if in the method definition the arguments are the type of an interface? 为什么我可以在Groovy的List接口中使用方法“ each”? - Why I can use method 'each' in List interface in Groovy? 如何使用Java Native Interface将字节数组传递给C函数,该函数将char *作为参数? - How can I use Java Native Interface to pass a byte array into a C function which takes a char* as an argument? Java:获取带有接口参数的方法及其实现 - Java: Get method with interface parameter with its implementation 为什么我可以将原语传递给采用对象的方法? - Why can I pass a primitive to a method that takes an object? 如何在Java方法中将接口的实现作为变量传递? - How to pass an implementation of an interface as a variable in a method in Java? 将反射方法作为参数传递(功能接口) - Pass reflection method as argument (functional interface) 为什么不能扩展接口“泛型方法”并将其类型缩小到继承的接口“类通用”? - Why can't I extend an interface “generic method” and narrow its type to my inherited interface “class generic”? 为什么接受接口的方法会拒绝该接口的实现? - Why would a method that accepts an interface reject an implementation of that interface?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM