|
对于最新稳定版本,请使用 Spring Integration 7.0.0! |
Apache Mina SFTP 服务器活动
这ApacheMinaSftpEventListener,在5.2版本中添加,监听某些Apache Mina SFTP服务器事件,并将其发布为ApplicationEvent可以被任意接收ApplicationListener豆@EventListenerBean方法,或事件入站通道适配器。
目前支持的活动有:
-
SessionOpenedEvent- 客户端会话已打开 -
目录创建事件- 创建目录 -
FileWrittenEvent- 文件被写入 -
路径移动事件- 文件或目录被重命名 -
PathRemovedEvent- 文件或目录被移除 -
SessionClosedEvent- 客户端已断线
这些都是 的一个子类阿帕奇MinaSftpEvent;你可以配置一个监听器来接收所有类型的事件。
这源每个事件的属性是ServerSession你可以从中获取诸如客户地址等信息;一个方便的getSession()方法在抽象事件上提供。
要配置服务器,使用监听器(必须是 Spring Bean),只需将其添加到SftpSubsystemFactory:
server = SshServer.setUpDefaultServer();
...
SftpSubsystemFactory sftpFactory = new SftpSubsystemFactory();
sftpFactory.addSftpEventListener(apacheMinaSftpEventListenerBean);
...
使用Spring Integration事件适配器获取这些事件:
@Bean
public ApplicationEventListeningMessageProducer eventsAdapter() {
ApplicationEventListeningMessageProducer producer =
new ApplicationEventListeningMessageProducer();
producer.setEventTypes(ApacheMinaSftpEvent.class);
producer.setOutputChannel(eventChannel());
return producer;
}