import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Named;
import io.quarkus.runtime.annotations.RegisterForReflection;
@ApplicationScoped
@Named("myNamedBean")
@RegisterForReflection
public class NamedBean {
public String hello(String name) {
return "Hello " + name + " from the NamedBean";
}
}
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Named;
import io.quarkus.runtime.annotations.RegisterForReflection;
@ApplicationScoped
@Named("myNamedBean")
@RegisterForReflection
public class NamedBean {
public String hello(String name) {
return "Hello " + name + " from the NamedBean";
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
然后,您可以在路由定义中使用 myNamedBean 名称:
import org.apache.camel.builder.RouteBuilder;
public class CamelRoute extends RouteBuilder {
@Override
public void configure() {
from("direct:named")
.bean("myNamedBean", "hello");
/* ... which is an equivalent of the following: */
from("direct:named")
.to("bean:myNamedBean?method=hello");
}
}
import org.apache.camel.builder.RouteBuilder;
public class CamelRoute extends RouteBuilder {
@Override
public void configure() {
from("direct:named")
.bean("myNamedBean", "hello");
/* ... which is an equivalent of the following: */
from("direct:named")
.to("bean:myNamedBean?method=hello");
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow