对于最新稳定版本,请使用 Spring Integration 7.0.0spring-doc.cadn.net.cn

Apache Mina SFTP 服务器活动

ApacheMinaSftpEventListener,在5.2版本中添加,监听某些Apache Mina SFTP服务器事件,并将其发布为ApplicationEvent可以被任意接收ApplicationListener@EventListenerBean方法,或事件入站通道适配器spring-doc.cadn.net.cn

目前支持的活动有:spring-doc.cadn.net.cn

这些都是 的一个子类阿帕奇MinaSftpEvent;你可以配置一个监听器来接收所有类型的事件。 这每个事件的属性是ServerSession你可以从中获取诸如客户地址等信息;一个方便的getSession()方法在抽象事件上提供。spring-doc.cadn.net.cn

要配置服务器,使用监听器(必须是 Spring Bean),只需将其添加到SftpSubsystemFactory:spring-doc.cadn.net.cn

server = SshServer.setUpDefaultServer();
...
SftpSubsystemFactory sftpFactory = new SftpSubsystemFactory();
sftpFactory.addSftpEventListener(apacheMinaSftpEventListenerBean);
...

使用Spring Integration事件适配器获取这些事件:spring-doc.cadn.net.cn

@Bean
public ApplicationEventListeningMessageProducer eventsAdapter() {
    ApplicationEventListeningMessageProducer producer =
        new ApplicationEventListeningMessageProducer();
    producer.setEventTypes(ApacheMinaSftpEvent.class);
    producer.setOutputChannel(eventChannel());
    return producer;
}