本文整理匯總了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();
}