如何使用骆驼的消息在Spring XML筛选豆 [英] How to use Camel Message Filter Bean in Spring XML

查看:159
本文介绍了如何使用骆驼的消息在Spring XML筛选豆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关邮件过滤器的骆驼文档显示了使用滤镜豆多个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");
    }
}

不过,该页面的显示如何调用该bean在Spring XML:

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>

在上面的代码中,我如何电线我&LT;过滤器/&GT; 有一个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?

推荐答案

您应该能够做到这一点是这样的:

You should be able to do it like this:

<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筛选豆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆