【问题标题】:Spring Integration - Java DSL alternative for XML Validating FilterSpring Integration - XML 验证过滤器的 Java DSL 替代方案
【发布时间】:2017-06-27 09:32:36
【问题描述】:

我想知道 Spring Integration 的 XML 验证过滤器是否有 Java DSL 或至少配置替代方法

<int-xml:validating-filter discard-channel=""                    1
                           id=""                                 2
                           input-channel=""                      3
                           output-channel=""                     4
                           schema-location=""                    5
                           schema-type="xml-schema"              6
                           throw-exception-on-rejection="false"  7
                           xml-validator="">                     8
    <int:poller .../>                                            9
</int-xml:validating-filter>

提前感谢您的支持!

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

    参考手册suggests examining the XML schema 回答此类问题。

    如果您已经熟悉 Spring Integration XML 配置,从 4.3 版本开始,我们在 XSD 元素定义中提供了带有指针的描述,其中目标类用于为适配器或网关生成 bean...

    在这种情况下...

    <xsd:element name="validating-filter">
        <xsd:annotation>
            <xsd:documentation>
                Configures a Consumer Endpoint for the
                'org.springframework.integration.filter.MessageFilter'
                with an 'org.springframework.integration.xml.selector.XmlValidatingMessageSelector'
            </xsd:documentation>
        </xsd:annotation>
    ...
    

    所以,使用 DSL...

    .filter(new XmlValidatingMessageSelector(...))
    

    并使用 java 配置

    @Bean
    @ServiceActivator(inputChannel = "...")
    public MessageFilter filter() {
        return new MessageFilter(new XmlValidatingMessageSelector(...));
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-13
    • 1970-01-01
    • 2018-08-18
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 1970-01-01
    • 2012-04-24
    相关资源
    最近更新 更多