使用 RemoteFileTemplate

Spring Integration 3.0 版本在 SftpSession 对象之上提供了一个新的抽象。该模板提供了发送、检索(作为 InputStream)、删除和重命名文件的方法。此外,我们还提供了一个 execute 方法,允许调用者在会话上运行多个操作。在所有情况下,模板都会负责可靠地关闭会话。有关更多信息,请参阅 RemoteFileTemplate 的 Javadoc,SFTP 有一个子类:SftpRemoteFileTemplate

我们在 4.1 版本中添加了额外的方法,包括 getClientInstance()。它提供了对底层 ChannelSftp 的访问,从而可以访问低级 API。

版本 5.0 引入了 RemoteFileOperations.invoke(OperationsCallback<F, T> action) 方法。此方法允许在同一线程绑定的 Session 范围内调用多个 RemoteFileOperations 调用。当您需要将 RemoteFileTemplate 的多个高级操作作为工作单元执行时,这非常有用。例如,AbstractRemoteFileOutboundGateway 将其用于 mput 命令实现,其中我们对所提供目录中的每个文件及其子目录递归执行 put 操作。有关更多信息,请参阅 Javadoc

© . This site is unofficial and not affiliated with VMware.