简体   繁体   中英

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

@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方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM