如何在 Spring XML 中使用 Camel 消息过滤器 Bean [英] How to use Camel Message Filter Bean in Spring XML
本文介绍了如何在 Spring XML 中使用 Camel 消息过滤器 Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Camel 消息过滤器文档 展示了几个使用过滤器 bean"的 Java DSL 示例" 像这样:
The Camel documentation for Message Filter shows several Java DSL examples using a "filter bean" like so:
from("direct:start")
.filter().method(MyBean.class, "isGoldCustomer").to("mock:result").end()
.to("mock:end");
public static class MyBean {
public boolean isGoldCustomer(@Header("level") String level) {
return level.equals("gold");
}
}
但是该页面没有显示如何在 Spring XML 中调用该 bean:
But that page doesn't show how to invoke that bean in Spring XML:
<route id="my-route">
<from uri="direct:a" />
<filter>
<method>??? how to call MyBean#isGoldCustomer from here???</method>
<to uri="direct:b" />
</filter>
</route>
在上面的代码片段中,我如何将我的 <filter/>
与 Java bean 连接,以及该 Java bean 需要实现/扩展什么接口?
In the above snippet, how do I wire my <filter/>
with a Java bean, and what interface does that Java bean need to implement/extend?
推荐答案
你应该可以这样做:
<bean id="myCustomPredicate" class="com.hveiga.test.MyCustomPredicate"/>
<route id="my-route">
<from uri="direct:a" />
<filter>
<method ref="myCustomPredicate" />
<to uri="direct:b" />
</filter>
</route>
这篇关于如何在 Spring XML 中使用 Camel 消息过滤器 Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文