2017-07-17 36 views
2

我想将我的xml配置转换为Java类配置,但我找不到解决方案。比如我的一块配置的:Spring-integration将xml配置转换为java配置

<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类。给我任何建议我寻找答案,但我找不到出路。

回答

1

首先你应该从Spring Integration Java DSL Reference Manual开始。在那里你会发现Java DSL的一般概念,以及它如何与XML配置相关。

您可以在相应的参考手册Chapter中找到的SFTP入站/出站通道适配器配置示例。例如说<int:service-activator>在Java的DSL可能看起来像:

.handle(handler) 

如果你没有渠道的定义,如果你在一个单一的IntegrationFLow声明的一切。

+0

好吧,但我想使用注释。你可以给我任何建议如何使用注释相同的事情?因为我可以找到替代我的出站通道适配器的方式。 @ArtemBilan – djdecks8767

+0

我现在解决我的问题。 – djdecks8767

+0

出站通道适配器是一个'@ ServiceActivator'。请参阅相同的SFTP章节:http://docs.spring.io/spring-integration/reference/html/sftp.html#_configuring_with_java_configuration_19 –