本文整理汇总了Java中org.apache.ftpserver.listener.ListenerFactory.createListener方法的典型用法代码示例。如果您正苦于以下问题:Java ListenerFactory.createListener方法的具体用法?Java ListenerFactory.createListener怎么用?Java ListenerFactory.createListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ftpserver.listener.ListenerFactory
的用法示例。
在下文中一共展示了ListenerFactory.createListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startFtpServer
import org.apache.ftpserver.listener.ListenerFactory; //导入方法依赖的package包/类
@BeforeClass
public static void startFtpServer() throws FtpException {
FtpServerFactory serverFactory = new FtpServerFactory();
BaseUser user = new BaseUser();
user.setName("ftp");
user.setPassword("secret");
serverFactory.getUserManager().save(user);
ListenerFactory factory = new ListenerFactory();
factory.setPort(0);
Listener listener = factory.createListener();
serverFactory.addListener("default", listener);
ftpServer = serverFactory.createServer();
ftpServer.start();
ftpPort = listener.getPort();
}
示例2: testFailStartingSecondListener
import org.apache.ftpserver.listener.ListenerFactory; //导入方法依赖的package包/类
public void testFailStartingSecondListener() throws Exception {
// FTPSERVER-197
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(0);
// let's create two listeners on the same port, second should not start
Listener defaultListener = listenerFactory.createListener();
Listener secondListener = listenerFactory.createListener();
serverFactory.addListener("default", defaultListener);
serverFactory.addListener("second", secondListener);
FtpServer server = serverFactory.createServer();
try {
server.start();
// Windows seems to allow for both listeners to bind on the same port...
//fail("Must throw FtpServerConfigurationException");
} catch(FtpServerConfigurationException e) {
if(e.getCause() instanceof BindException) {
// OK!
// we failed to start, make sure things are shut down correctly
assertTrue(defaultListener.isStopped());
assertTrue(secondListener.isStopped());
assertTrue(server.isStopped());
} else {
throw e;
}
}
}
示例3: nioListener
import org.apache.ftpserver.listener.ListenerFactory; //导入方法依赖的package包/类
@Bean
Listener nioListener(@Value("${ftp.port}") int port) throws Exception {
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(port);
return listenerFactory.createListener();
}