INT-1945 (S)FTP Outbound Gateway Samples

Samples execute ls, get and rm commands.
This commit is contained in:
Gary Russell
2011-08-29 13:23:26 -04:00
parent a24994dc1c
commit 6131356619
12 changed files with 340 additions and 3 deletions

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp-2.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder location="classpath:user.properties"/>
<int:gateway id="gw" service-interface="org.springframework.integration.samples.sftp.ToSftpFlowGateway"
default-request-channel="inbound"/>
<bean id="sftpSessionFactory"
class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="localhost"/>
<property name="privateKey" value="${private.keyfile}"/>
<property name="privateKeyPassphrase" value="${passphrase}"/>
<property name="port" value="22"/>
<property name="user" value="${user}"/>
</bean>
<int-sftp:outbound-gateway id="gatewayLS"
session-factory="sftpSessionFactory"
request-channel="inbound"
command="ls"
command-options=""
expression="payload"
reply-channel="toSplitter1"/>
<int:splitter input-channel="toSplitter1" output-channel="toGet"/>
<int-sftp:outbound-gateway id="gatewayGET"
local-directory="#{ T(System).getProperty('java.io.tmpdir')}"
session-factory="sftpSessionFactory"
request-channel="toGet"
reply-channel="toRm"
command="get"
command-options="-P"
expression="payload.remoteDir + '/' + payload.filename"/>
<int-sftp:outbound-gateway id="gatewayRM" reply-channel="aggregateResultsChannel"
session-factory="sftpSessionFactory"
expression="headers['file_remote_dir'] + '/' + headers['file_remote_file']"
request-channel="toRm"
command="rm"/>
<int:aggregator input-channel="aggregateResultsChannel"/>
</beans>

View File

@@ -5,5 +5,6 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n
log4j.category.org.springframework=WARN
log4j.category.org.springframework.integration=DEBUG
log4j.category.org.springframework.integration.sftp=TRACE
log4j.category.org.springframework.integration.samples.sftp=TRACE

View File

@@ -1,2 +1,4 @@
user=
passphrase=
passphrase=
#private.keyfile=file:/home/someuser/.ssh/id_rsa
private.keyfile=classpath:META-INF/keys/sftp_rsa