diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java
index 7ec3bf25eb..61b35d8d44 100644
--- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java
+++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParser.java
@@ -49,7 +49,7 @@ public class FtpOutboundChannelAdapterParser extends AbstractOutboundChannelAdap
boolean hasDirectoryExpression = StringUtils.hasText(remoteDirectoryExpression);
if (!(hasDirectory ^ hasDirectoryExpression)) {
throw new BeanDefinitionStoreException("exactly one of 'remote-directory' or 'remote-directory-expression' " +
- "is required on the SFTP outbound adapter");
+ "is required on the FTP outbound adapter");
}
BeanDefinition expressionDef = null;
if (hasDirectory) {
@@ -61,8 +61,24 @@ public class FtpOutboundChannelAdapterParser extends AbstractOutboundChannelAdap
expressionDef.getConstructorArgumentValues().addGenericArgumentValue(remoteDirectoryExpression);
}
handlerBuilder.addPropertyValue("remoteDirectoryExpression", expressionDef);
+ String remoteFileExpression = element.getAttribute("remote-filename-generator-expression");
+ String fileNameGenerator = element.getAttribute("remote-filename-generator");
+ boolean hasRemoteFileExpression = StringUtils.hasText(remoteFileExpression);
+ boolean hasFileNameGenerator = StringUtils.hasText(fileNameGenerator);
+ if (hasRemoteFileExpression || hasFileNameGenerator) {
+ if (hasRemoteFileExpression && hasFileNameGenerator) {
+ throw new BeanDefinitionStoreException("at most one of 'remote-filename-generator-expression' or 'remote-filename-generator' " +
+ "is allowed on the FTP outbound adapter");
+ }
+ if (StringUtils.hasText(remoteFileExpression)) {
+ BeanDefinitionBuilder fileNameGeneratorBuilder = BeanDefinitionBuilder.genericBeanDefinition(
+ "org.springframework.integration.file.DefaultFileNameGenerator");
+ fileNameGeneratorBuilder.addPropertyValue("expression", remoteFileExpression);
+ handlerBuilder.addPropertyValue("fileNameGenerator", fileNameGeneratorBuilder.getBeanDefinition());
+ }
+ }
+ IntegrationNamespaceUtils.setReferenceIfAttributeDefined(handlerBuilder, element, "remote-filename-generator", "fileNameGenerator");
IntegrationNamespaceUtils.setValueIfAttributeDefined(handlerBuilder, element, "charset");
- IntegrationNamespaceUtils.setReferenceIfAttributeDefined(handlerBuilder, element,"filename-generator", "fileNameGenerator");
return handlerBuilder.getBeanDefinition();
}
diff --git a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd
index 4265fcc3f8..36ff36a7b7 100644
--- a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd
+++ b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.0.xsd
@@ -24,19 +24,19 @@
-
-
-
- Allows you to specify a reference to
- [org.springframework.integration.file.FileNameGenerator] implementation.
-
-
-
-
-
-
-
-
+
+
+
+ A reference to an implementation of org.springframework.integration.file.FileNameGenerator.
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserOutboundTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserOutboundTests-context.xml
index 0504712fc3..a908d59ba9 100644
--- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserOutboundTests-context.xml
+++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/FtpParserOutboundTests-context.xml
@@ -9,7 +9,6 @@
-
@@ -24,7 +23,7 @@
session-factory="ftpSessionFactory"
remote-directory="foo/bar"
channel="ftpOutbound"
- filename-generator="fileNameGenerator"/>
+ remote-filename-generator="fileNameGenerator"/>
diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml
index 7cbe392f57..304a2a0a82 100644
--- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml
+++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml
@@ -22,7 +22,7 @@
session-factory="ftpSessionFactory"
remote-directory="foo/bar"
charset="UTF-8"
- filename-generator="fileNameGenerator"/>
+ remote-filename-generator="fileNameGenerator"/>
diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests-context.xml
index 593adf783d..507994a3dc 100644
--- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests-context.xml
+++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests-context.xml
@@ -40,11 +40,12 @@
session-factory="ftpSessionFactory"
charset="UTF-8"
remote-directory="foo/bar"
- filename-generator="fileNameGenerator"/>
+ remote-filename-generator="fileNameGenerator"/>
+