|
该版本仍在开发中,尚未被视为稳定。对于最新的稳定版本,请使用 Spring Integration 7.0.0! |
Apache Mina FTP 服务器活动
这阿帕奇MinaFtplet(阿帕奇MinaFtplet),在5.2版本中添加,监听某些Apache Mina FTP服务器事件并发布为ApplicationEvent可以被任意接收ApplicationListener豆@EventListenerBean方法,或事件入站通道适配器。
目前支持的活动有:
-
SessionOpenedEvent- 客户端会话已打开 -
目录创建事件- 创建目录 -
FileWrittenEvent- 文件被写入 -
路径移动事件- 文件或目录被重命名 -
PathRemovedEvent- 文件或目录被移除 -
SessionClosedEvent- 客户端已断线
这些都是 的一个子类阿帕奇MinaFtp事件;你可以配置一个监听器来接收所有类型的事件。
这源每个事件的属性是FtpSession你可以从中获取诸如客户地址等信息;一个方便的getSession()方法在抽象事件上提供。
除会话开闭外,其他事件还有其他属性FtpRequest该系统具有命令和参数等属性。
要配置带有监听器的服务器(必须是 Spring Bean),请将其添加到服务器工厂:
FtpServerFactory serverFactory = new FtpServerFactory();
...
ListenerFactory factory = new ListenerFactory();
...
serverFactory.addListener("default", factory.createListener());
serverFactory.setFtplets(new HashMap<>(Collections.singletonMap("springFtplet", apacheMinaFtpletBean)));
server = serverFactory.createServer();
server.start();
使用Spring Integration事件适配器获取这些事件:
@Bean
public ApplicationEventListeningMessageProducer eventsAdapter() {
ApplicationEventListeningMessageProducer producer =
new ApplicationEventListeningMessageProducer();
producer.setEventTypes(ApacheMinaFtpEvent.class);
producer.setOutputChannel(eventChannel());
return producer;
}