Groovy嵌入式Apache FTP服务器示例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Groovy嵌入式Apache FTP服务器示例相关的知识,希望对你有一定的参考价值。
http://mina.apache.org/ftpserver/
#!/usr/bin/env groovy // file: FtpSvr.groovy /* Laurence Toenjes Jan 12, 2013 Standalone Groovy ftp server script (no jars to download if Groovy is properly installed). The default user is guest with password of guest and the ftp home/base directory is the home folder of the account running this script. A root account is also created with the ftp home/base dir set to / and the password is root (for root to fully work you would obviously have to run it under an account with expanded file permissions). Optional command line args: arg0 defaults to port 8021. arg1 (ftp base dir) defaults to the home directory of the user running this script. */ // See http://mina.apache.org/ftpserver/ for more details. // for OS X/*nix // don't forget to do: chmod +x FtpServer.groovy // also run as sudo ./FtpSvr.groovy for when using a port number < 1024 @Grapes([ @Grab(group='org.apache.ftpserver', module='ftpserver-core', version='1.0.6') , @Grab(group='ch.qos.logback', module='logback-classic', version='1.0.9') ]) println "### ftp port : $port" println "### ftp homeDir: $homeDir" println '' // the basics // FtpServerFactory serverFactory = new FtpServerFactory(); // FtpServer server = serverFactory.createServer(); // server.start(); // setup users myusersPropsFile.createNewFile(); } userManagerFactory.setFile( myusersPropsFile ); UserManager um = userManagerFactory.createUserManager(); users << [ uid:'guest', pwd:'guest', home:homeDir ] users << [ uid:'root' , pwd:'root' , home:'/' ] user.setName( map.uid ); user.setPassword( map.pwd ); user.setHomeDirectory( map.home ); auths.add(auth); user.setAuthorities(auths); // gi user; // gi user.getAuthorities(); um.save(user); } serverFactory.setUserManager( um ); // set the port of the listener factory.setPort( port ); // replace the default listener serverFactory.addListener("default", factory.createListener()); // start the server FtpServer server = serverFactory.createServer(); // groovy.inspect.swingui.ObjectBrowser.inspect( server ); // groovy.inspect.swingui.ObjectBrowser.inspect( server.userManager ); // gi server.userManager.getAllUserNames() as List; } mo.go(args) } }
以上是关于Groovy嵌入式Apache FTP服务器示例的主要内容,如果未能解决你的问题,请参考以下文章
Groovy集合遍历 ( 使用集合的 find 方法查找集合元素 | 闭包中使用 == 作为查找匹配条件 | 闭包中使用 is 作为查找匹配条件 | 闭包使用 true 作为条件 | 代码示例 )(代
虚拟用户登录FTP错误 500 OOPS: bad bool value in config file for: anon_world_readable_only Login failed.(示例代
Groovy循环控制 ( Java 语法循环 | 默认的 IntRange 构造函数 | 可设置翻转属性的 IntRange 构造函数 | 可设置是否包含 to 的构造函数 | 0..9 简写 )(代
apache开源java ftp文件服务器mina ftpserver安装部署,Windows
ideMyBatis报错: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):(示例代
Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration(示例代