此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Integration 6.5.1spring-doc.cadn.net.cn

Apache Mina FTP 服务器事件

ApacheMinaFtplet,在 5.2 版中添加,监听某些 Apache Mina FTP 服务器事件并将它们发布为ApplicationEvent可以由任何ApplicationListener@EventListenerbean 方法或事件入站通道适配器spring-doc.cadn.net.cn

目前,支持的事件包括:spring-doc.cadn.net.cn

其中每一个都是ApacheMinaFtpEvent;您可以配置单个侦听器来接收所有事件类型。 这source每个事件的属性是FtpSession,您可以从中获取客户地址等信息;一个方便的getSession()方法。spring-doc.cadn.net.cn

会话打开/关闭以外的事件具有另一个属性FtpRequest它具有命令和参数等属性。spring-doc.cadn.net.cn

要使用侦听器(必须是 Spring bean)配置服务器,请将其添加到服务器工厂:spring-doc.cadn.net.cn

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 事件适配器使用这些事件:spring-doc.cadn.net.cn

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