10.7. Java DSL bean 语法
Java DSL 附带了与组件相关的语法提示。您可以使用以下语法,而不是明确指定 bean 作为端点(如 to("bean:beanName")):
// Send message to the bean endpoint
// and invoke method resolved using Bean Binding.
from("direct:start").bean("beanName");
// Send message to the bean endpoint
// and invoke given method.
from("direct:start").bean("beanName", "methodName");
您无需向 bean 传递引用(因此 Camel 会在 registry 中查询它),您可以指定 bean 本身:
// Send message to the given bean instance.
from("direct:start").bean(new ExampleBean());
// Explicit selection of bean method to be invoked.
from("direct:start").bean(new ExampleBean(), "methodName");
// Camel will create the instance of bean and cache it for you.
from("direct:start").bean(ExampleBean.class);