作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Camel documentation for Message Filter显示了几个使用“filter bean”的 Java DSL 示例,如下所示:
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:
<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 需要实现/扩展什么接口(interface)?
最佳答案
你应该能够这样做:
<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>
关于java - 如何在 Spring XML 中使用 Camel 消息过滤器 Bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21762743/
我是一名优秀的程序员,十分优秀!