2017-07-17 37 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 –