Search code examples
spring-integrationspring-integration-sftp

Spring-integration convert xml configuration into java config


I want to convert my xml config into Java class config but i can't find a solution. For example a piece of my config:

<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>

How can i made the same thing but with use sftp (src directory) on my local machine and also how to write this config in java class. Give me any suggestion i looking for answer but i can't find the way out.


Solution

  • First of all you should start from the Spring Integration Java DSL Reference Manual. There you will find general concepts of the Java DSL and how that is related to the XML config.

    The SFTP Inbound/Outbound Channel Adapter configuration samples you can find in the appropriate Reference Manual Chapter. For example that <int:service-activator> in Java DSL may look like:

    .handle(handler)
    

    Where you don't have channel definitions if you declare everything in a single IntegrationFLow.