本文整理汇总了Java中org.apache.ftpserver.listener.Listener类的典型用法代码示例。如果您正苦于以下问题:Java Listener类的具体用法?Java Listener怎么用?Java Listener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Listener类属于org.apache.ftpserver.listener包,在下文中一共展示了Listener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stop
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
/**
* Stop the server. Stopping the server will close completely and
* it not supported to restart using {@link #start()}.
*/
public void stop() {
if (serverContext == null) {
// we have already been stopped, ignore
return;
}
// stop all listeners
Map<String, Listener> listeners = serverContext.getListeners();
for (Listener listener : listeners.values()) {
listener.stop();
}
// destroy the Ftplet container
serverContext.getFtpletContainer().destroy();
// release server resources
if (serverContext != null) {
serverContext.dispose();
serverContext = null;
}
started = false;
}
示例2: suspend
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
/**
* Suspend further requests
*/
public void suspend() {
if (!started) {
return;
}
LOG.debug("Suspending server");
// stop all listeners
Map<String, Listener> listeners = serverContext.getListeners();
for (Listener listener : listeners.values()) {
listener.suspend();
}
suspended = true;
LOG.debug("Server suspended");
}
示例3: ftpServer
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
@Bean
FtpServer ftpServer(UserManager userManager, Listener nioListener, FileSystemFactory fileSystemFactory) throws FtpException {
FtpServerFactory ftpServerFactory = new FtpServerFactory();
ftpServerFactory.setListeners(Collections.singletonMap("default", nioListener));
ftpServerFactory.setFileSystem(fileSystemFactory);
ftpServerFactory.setUserManager(userManager);
return ftpServerFactory.createServer();
}
示例4: startFtpServer
import org.apache.ftpserver.listener.Listener; //导入依赖的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();
}
示例5: resume
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
/**
* Resume the server handler
*/
public void resume() {
if (!suspended) {
return;
}
LOG.debug("Resuming server");
Map<String, Listener> listeners = serverContext.getListeners();
for (Listener listener : listeners.values()) {
listener.resume();
}
suspended = false;
LOG.debug("Server resumed");
}
示例6: testFailStartingSecondListener
import org.apache.ftpserver.listener.Listener; //导入依赖的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;
}
}
}
示例7: nioListener
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
@Bean
Listener nioListener(@Value("${ftp.port}") int port) throws Exception {
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(port);
return listenerFactory.createListener();
}
示例8: testUploadLoginSSLImplicite
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
/**
* Test method for {@link ch.sdi.core.impl.ftp.FtpExecutor#executeUpload(java.io.InputStream, java.lang.String)}.
*/
@Test
public void testUploadLoginSSLImplicite() throws Throwable
{
myLog.debug( "Testing SSL login (implicite)" );
String targetDir = myTargetDirLocal;
cleanTargetDir( targetDir );
Map<String, InputStream> filesToUpload = createFileUploadMap( targetDir );
List<String> args = new ArrayList<String>();
args.add( "-p" );
args.add( "false" ); // activate implicite SSL
args.add( "localhost" );
args.add( "heri" ); // user
args.add( "heri" ); // pw
ListenerFactory listenerFactory = new ListenerFactory();
// define SSL configuration
SslConfigurationFactory ssl = new SslConfigurationFactory();
ssl.setKeystoreFile(new File("keystore.jks")); // this is in core/test/resources and contains one
// selfsigned certificate
ssl.setKeystorePassword("password");
listenerFactory.setSslConfiguration(ssl.createSslConfiguration());
listenerFactory.setImplicitSsl(false);
// replace the default listener
Listener listenerOrg = myServerFactory.getListener( "default" );
try
{
myServerFactory.addListener("default", listenerFactory.createListener());
registerFtpUser( "heri", "heri" );
FtpServer server = startFtpServer();
try
{
myClassUnderTest.init( args.toArray( new String[args.size()] ) );
myClassUnderTest.connectAndLogin();
myClassUnderTest.uploadFiles( filesToUpload );
myClassUnderTest.logoutAndDisconnect();
assertFilesUploaded( createFileUploadMap( targetDir ) );
}
finally
{
if ( server != null )
{
myLog.debug( "stopping the embedded FTP server" );
server.stop();
} // if myServer != null
}
}
finally
{
myServerFactory.addListener("default", listenerOrg );
}
}
示例9: registerListener
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public FtpServerBuilder registerListener(final String listenerName, final Listener listener) {
ftpServerFactory.addListener(listenerName, listener);
return this;
}
示例10: registerDefaultListener
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public FtpServerBuilder registerDefaultListener(final Listener listener) {
return registerListener("default", listener);
}
示例11: getObjectType
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public Class<?> getObjectType() {
return Listener.class;
}
示例12: getListener
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public Listener getListener() {
return (Listener) getAttribute(ATTRIBUTE_LISTENER);
}
示例13: setListener
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public void setListener(Listener listener) {
setAttribute(ATTRIBUTE_LISTENER, listener);
}
示例14: init
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public void init(final FtpServerContext context, final Listener listener) {
this.context = context;
this.listener = listener;
}
示例15: getListener
import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public Listener getListener(String name) {
return listeners.get(name);
}