From 10e79ba618e10f39b15631503b0b3732e328a32b Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Mon, 18 Sep 2023 16:32:49 -0400 Subject: [PATCH] GH-8713: Add support for custom `SftpClient` Fixes https://github.com/spring-projects/spring-integration/issues/8713 * Introduce `DefaultSftpSessionFactory.createSftpClient()` factory method which can be overridden for any custom `SftpClient` use-case * Add changes to the docs * Some code clean up **Cherry-pick to `6.1.x`** --- .../session/DefaultSftpSessionFactory.java | 34 +++++++++++++++---- .../ROOT/pages/sftp/session-factory.adoc | 15 +++++++- .../antora/modules/ROOT/pages/whats-new.adoc | 6 ++++ 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java index 98a117228b..3934e71d9b 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/DefaultSftpSessionFactory.java @@ -53,6 +53,10 @@ import org.springframework.util.Assert; /** * Factory for creating {@link SftpSession} instances. + *

+ * The {@link #createSftpClient(ClientSession, SftpVersionSelector, SftpErrorDataHandler)} + * can be overridden to provide a custom {@link SftpClient}. + * The {@link ConcurrentSftpClient} is used by default. * * @author Josh Long * @author Mario Gray @@ -65,6 +69,7 @@ import org.springframework.util.Assert; * @author Krzysztof Debski * @author Auke Zaaiman * @author Christian Tzolov + * @author Adama Sorho * * @since 2.0 */ @@ -282,9 +287,7 @@ public class DefaultSftpSessionFactory implements SessionFactory ...); + return sftpChannelSubsystem; +} +---- + [[sftp-session-factory-properties]] == Configuration Properties diff --git a/src/reference/antora/modules/ROOT/pages/whats-new.adoc b/src/reference/antora/modules/ROOT/pages/whats-new.adoc index 40e73c67e7..a573c495f5 100644 --- a/src/reference/antora/modules/ROOT/pages/whats-new.adoc +++ b/src/reference/antora/modules/ROOT/pages/whats-new.adoc @@ -72,3 +72,9 @@ See xref:mongodb.adoc#mongodb-message-store[MongoDB Message Store] for an exampl `FtpLastModifiedFileListFilter`, `SftpLastModifiedFileListFilter` and `SmbLastModifiedFileListFilter` have been introduced to allow files filtering based on a last-modified strategy respectively for `FTP`, `SFTP` and `SMB`. See xref:ftp/inbound.adoc#ftp-inbound[FTP Inbound Channel Adapter], xref:sftp/inbound.adoc#sftp-inbound[SFTP Inbound Channel Adapter], and xref:smb.adoc#smb-inbound[SMB Inbound Channel Adapter] for more information. + +[[x6.2-sftp-changes]] +=== SFTP Support Changes + +A new `DefaultSftpSessionFactory.createSftpClient(...)` method has been introduced to support a custom `SftpClient` when overridden. +See xref:sftp/session-factory.adoc#sftp-session-factory[SFTP Session Factory] for more information.