当前位置: 首页>>代码示例>>Java>>正文


Java Listener类代码示例

本文整理汇总了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;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:28,代码来源:DefaultFtpServer.java

示例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");
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:19,代码来源:DefaultFtpServer.java

示例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();
}
 
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:9,代码来源:FtpServerConfiguration.java

示例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();
}
 
开发者ID:Alexey1Gavrilov,项目名称:ExpectIt,代码行数:16,代码来源:AntHarnessTest.java

示例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");
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:DefaultFtpServer.java

示例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;
        }
    }
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:38,代码来源:DefaultFtpServerTest.java

示例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();
}
 
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:7,代码来源:FtpServerConfiguration.java

示例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 );
    }
}
 
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:61,代码来源:FtpExecutorTest.java

示例9: registerListener

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public FtpServerBuilder registerListener(final String listenerName, final Listener listener) {
    ftpServerFactory.addListener(listenerName, listener);
    return this;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:5,代码来源:CamelFtpBaseTest.java

示例10: registerDefaultListener

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public FtpServerBuilder registerDefaultListener(final Listener listener) {
    return registerListener("default", listener);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:4,代码来源:CamelFtpBaseTest.java

示例11: getObjectType

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public Class<?> getObjectType() {
    return Listener.class;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:4,代码来源:ListenerFactoryBean.java

示例12: getListener

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public Listener getListener() {
return (Listener) getAttribute(ATTRIBUTE_LISTENER);
   }
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:4,代码来源:FtpIoSession.java

示例13: setListener

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public void setListener(Listener listener) {
setAttribute(ATTRIBUTE_LISTENER, listener);
   }
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:4,代码来源:FtpIoSession.java

示例14: init

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public void init(final FtpServerContext context, final Listener listener) {
    this.context = context;
    this.listener = listener;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:5,代码来源:DefaultFtpHandler.java

示例15: getListener

import org.apache.ftpserver.listener.Listener; //导入依赖的package包/类
public Listener getListener(String name) {
    return listeners.get(name);
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:4,代码来源:DefaultFtpServerContext.java


注:本文中的org.apache.ftpserver.listener.Listener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。