简体   繁体   English

如何为spring集成ftp网关接口添加自定义方法?

[英]How to add custom method to spring integration ftp gateway interface?

Following the Spring integration ftp doc , I have managed to send files to ftp server through the java config way: 在Spring集成ftp doc之后 ,我已经设法通过java配置方式将文件发送到ftp服务器:

@MessagingGateway
public interface MyGateway {

     @Gateway(requestChannel = "toFtpChannel")
     void sendToFtp(File file);

}

ss SS

    public static void main(String[] args) {
    ConfigurableApplicationContext context =
                new SpringApplicationBuilder(FtpJavaApplication.class)
                    .web(false)
                    .run(args);
    MyGateway gateway = context.getBean(MyGateway.class);
     // sending file to ftp server
    gateway.sendToFtp(new File("/foo/bar.txt"));
}

It seems to me that the code above is using the custom method 'sendToFtp()' to send file to target ftp server. 在我看来,上面的代码使用自定义方法'sendToFtp()'将文件发送到目标ftp服务器。 My question is that how to add other methods to the MyGateway interface to implement the operations? 我的问题是如何将其他方法添加到MyGateway接口来实现操作?

ls (list files)
get (retrieve file)
mget (retrieve file(s))
rm (remove file(s))
mv (move/rename file)
put (send file)
mput (send multiple files)

Each FTP gateway can only handle one method. 每个FTP网关只能处理一种方法。

You need to declare one for each, then... 你需要为每个声明一个,然后......

@MessagingGateway
public interface MyGateway {

     @Gateway(requestChannel = "toFtpGetChannel")
     void sendToFtpGet(...);

     @Gateway(requestChannel = "toFtpPutChannel")
     void sendToFtpPut(...);

    ...

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM