Spring-集成将xml配置转换为java配置

Spring-integration convert xml configuration into java config

我想将我的 xml 配置转换为 Java class 配置,但我找不到解决方案。例如我的一段配置:

<file:inbound-channel-adapter id="filesIn" directory="file:${java.io.tmpdir}/spring-integration-samples/input"
                              filename-regex="^.*\.(xml|json)$" >
    <int:poller id="poller" fixed-delay="5000"/>
</file:inbound-channel-adapter>


<int:service-activator input-channel="filesIn"
                       output-channel="filesOut"
                       ref="handler"/>

<file:outbound-channel-adapter id="filesOut" directory="file:${java.io.tmpdir}/spring-integration-samples/output"
                               delete-source-files="true"/>



<file:inbound-channel-adapter id="filesContent" directory="file:${java.io.tmpdir}/spring-integration-samples/output"
                              filename-regex="^.*\.(xml|json)$" prevent-duplicates="true">
    <int:poller id="poller2" fixed-delay="5000"/>
 </file:inbound-channel-adapter>

如何在我的本地机器上使用 sftp(src 目录)做同样的事情,以及如何在 java class 中编写此配置。给我任何建议我正在寻找答案,但我找不到出路。

首先你应该从Spring Integration Java DSL Reference Manual开始。在那里你会找到 Java DSL 的一般概念以及它与 XML 配置的关系。

您可以在相应的参考手册 Chapter 中找到 SFTP Inbound/Outbound 通道适配器配置示例。例如 Java DSL 中的 <int:service-activator> 可能如下所示:

.handle(handler)

如果您在单个 IntegrationFLow 中声明所有内容,则没有频道定义。