當前位置: 首頁>>代碼示例>>Java>>正文


Java FtpServer.start方法代碼示例

本文整理匯總了Java中org.apache.ftpserver.FtpServer.start方法的典型用法代碼示例。如果您正苦於以下問題:Java FtpServer.start方法的具體用法?Java FtpServer.start怎麽用?Java FtpServer.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.ftpserver.FtpServer的用法示例。


在下文中一共展示了FtpServer.start方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: startFtpServer

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
public static FtpServer startFtpServer(String homePath, int port, String user, String pass) {
    FtpServerFactory serverFactory = new FtpServerFactory();
    ListenerFactory listenerFactory = new ListenerFactory();
    listenerFactory.setPort(port);

    serverFactory.addListener("default", listenerFactory.createListener());
    serverFactory.setUserManager(new FtpUserManager(homePath, user, pass));

    FtpServer ftpServer = serverFactory.createServer();
    try {
        ftpServer.start();
        return ftpServer;
    } catch (FtpException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:bingoohuang,項目名稱:aoc,代碼行數:17,代碼來源:TestUtils.java

示例2: contextInitialized

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
public void contextInitialized(ServletContextEvent sce) {
    System.out.println("Starting FtpServer");   

    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
    
    FtpServer server = (FtpServer) ctx.getBean("myServer");
    
    sce.getServletContext().setAttribute(FTPSERVER_CONTEXT_NAME, server);
    
    try {
        server.start();
        System.out.println("FtpServer started");
    } catch (Exception e) {
        throw new RuntimeException("Failed to start FtpServer", e);
    }
}
 
開發者ID:saaconsltd,項目名稱:mina-ftpserver,代碼行數:17,代碼來源:FtpServerListener.java

示例3: main

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
/**
 * This method is the FtpServer starting point when running by using the
 * command line mode.
 * 
 * @param args
 *            The first element of this array must specify the kind of
 *            configuration to be used to start the server.
 */
public static void main(String args[]) {

    CommandLine cli = new CommandLine();
    try {

        // get configuration
        FtpServer server = cli.getConfiguration(args);
        if (server == null) {
            return;
        }

        // start the server
        server.start();
        System.out.println("FtpServer started");

        // add shutdown hook if possible
        cli.addShutdownHook(server);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:saaconsltd,項目名稱:mina-ftpserver,代碼行數:30,代碼來源:CommandLine.java

示例4: startServer

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
/**
 * Start the FTP server.
 */
public void startServer() {
    //Set the user factory
    PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
    String filename = mContext.getExternalCacheDir().getAbsolutePath() + "/users.properties";
    File files = new File(filename);
    userManagerFactory.setFile(files);

    //Set the server factory
    FtpServerFactory serverFactory = new FtpServerFactory();
    serverFactory.setUserManager(userManagerFactory.createUserManager());

    //Set the port number
    ListenerFactory factory = new ListenerFactory();
    factory.setPort(PORT_NUMBER);
    try {
        serverFactory.addListener("default", factory.createListener());
        FtpServer server = serverFactory.createServer();
        mFtpServer = server;

        //Start the server
        server.start();
    } catch (FtpException e) {
        e.printStackTrace();
    }

    Log.d(TAG, "onCreate: FTP server started. IP address: " + getLocalIpAddress() + " and Port:" + PORT_NUMBER);
}
 
開發者ID:kevalpatel2106,項目名稱:remote-storage-android-things,代碼行數:31,代碼來源:FTPManager.java

示例5: Config2

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
void Config2() {
//		Now, let's make it possible for a client to use FTPS (FTP over SSL) for the default listener.


        FtpServerFactory serverFactory = new FtpServerFactory();

        ListenerFactory factory = new ListenerFactory();

        // set the port of the listener
        factory.setPort(2221);

        // define SSL configuration
        SslConfigurationFactory ssl = new SslConfigurationFactory();
        ssl.setKeystoreFile(new File(ftpConfigDir + "ftpserver.jks"));
        ssl.setKeystorePassword("password");

        // set the SSL configuration for the listener
        factory.setSslConfiguration(ssl.createSslConfiguration());
        factory.setImplicitSsl(true);

        // replace the default listener
        serverFactory.addListener("default", factory.createListener());

        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(new File(ftpConfigDir + "users.properties"));

        serverFactory.setUserManager(userManagerFactory.createUserManager());

        // start the server
        FtpServer server = serverFactory.createServer();
        this.mFtpServer = server;
        try {
            server.start();
        } catch (FtpException e) {
            e.printStackTrace();
        }
    }
 
開發者ID:lucky-code,項目名稱:Practice,代碼行數:38,代碼來源:FtpActivity.java

示例6: startServer

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
private void startServer() {
  try {
    DefaultFtpServerContext context = new DefaultFtpServerContext(false);
    MinaListener listener = new MinaListener();
    // Set port to 0 for OS to give a free port
    listener.setPort(0);
    context.setListener("default", listener);

    // Create a test user.
    UserManager userManager = context.getUserManager();
    BaseUser adminUser = new BaseUser();
    adminUser.setName("admin");
    adminUser.setPassword("admin");
    adminUser.setEnabled(true);
    adminUser.setAuthorities(new Authority[] { new WritePermission() });

    Path adminUserHome = new Path(ftpServerRoot, "user/admin");
    adminUser.setHomeDirectory(adminUserHome.toUri().getPath());
    adminUser.setMaxIdleTime(0);
    userManager.save(adminUser);

    // Initialize the server and start.
    server = new FtpServer(context);
    server.start();

  } catch (Exception e) {
    throw new RuntimeException("FTP server start-up failed", e);
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:30,代碼來源:TestFTPFileSystem.java

示例7: startFtpServer

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
/**
 * @return
 * @throws FtpException
 */
private FtpServer startFtpServer() throws FtpException
{
    FtpServer result;
    result = myServerFactory.createServer();

    myLog.debug( "starting an embedded FTP server" );
    result.start();
    return result;
}
 
開發者ID:heribender,項目名稱:SocialDataImporter,代碼行數:14,代碼來源:FtpExecutorTest.java

示例8: main

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    
    ListenerFactory factory = new ListenerFactory();
    
    // set the port of the listener
    factory.setPort(2221);

    // define SSL configuration
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(new File("src/test/resources/ftpserver.jks"));
    ssl.setKeystorePassword("password");

    // set the SSL configuration for the listener
    factory.setSslConfiguration(ssl.createSslConfiguration());
    factory.setImplicitSsl(true);

    // replace the default listener
    serverFactory.addListener("default", factory.createListener());
    
    PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
    userManagerFactory.setFile(new File("myusers.properties"));
    
    serverFactory.setUserManager(userManagerFactory.createUserManager());
    
    // start the server
    FtpServer server = serverFactory.createServer(); 
    
    server.start();
}
 
開發者ID:saaconsltd,項目名稱:mina-ftpserver,代碼行數:31,代碼來源:EmbeddingFtpServer.java

示例9: testFailStartingSecondListener

import org.apache.ftpserver.FtpServer; //導入方法依賴的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

示例10: createSftpServer

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
private static FtpServer createSftpServer(String user, String pass, File home, int port)
    throws FtpException {
  FtpServer server = TestSftpServer.createSftpServer(user, pass, null, port, home);
  server.start();
  return server;
}
 
開發者ID:google,項目名稱:nomulus,代碼行數:7,代碼來源:SftpServerRule.java

示例11: ftpServerFactory

import org.apache.ftpserver.FtpServer; //導入方法依賴的package包/類
public static FtpServer ftpServerFactory(String name, HashMap<String, ConfigurationItem> all_instances_confs, HashMap<String, Ftplet> ftplets) throws Exception {
	FtpServerFactory server_factory = new FtpServerFactory();
	
	LinkedHashMap<String, Object> log = new LinkedHashMap<String, Object>();
	
	DataConnectionConfigurationFactory dccf = new DataConnectionConfigurationFactory();
	dccf.setActiveEnabled(true);
	dccf.setActiveIpCheck(true);
	log.put("active", dccf.isActiveEnabled());
	log.put("active IP check", dccf.isActiveIpCheck());
	
	ConfigurationClusterItem local = Configuration.getClusterConfiguration(all_instances_confs, name, "active", "0.0.0.0", 20).get(0);
	dccf.setActiveLocalAddress(local.address);
	dccf.setActiveLocalPort(local.port);
	log.put("active local", dccf.getActiveLocalAddress() + ":" + dccf.getActiveLocalPort());
	
	int idle = Configuration.getValue(all_instances_confs, name, "idle", 300);
	dccf.setIdleTime(idle);
	log.put("Idle time", dccf.getIdleTime());
	
	dccf.setImplicitSsl(false);
	dccf.setPassiveAddress(Configuration.getValue(all_instances_confs, name, "passive-internal", "0.0.0.0"));
	dccf.setPassiveExternalAddress(Configuration.getValue(all_instances_confs, name, "passive-external", "0.0.0.0"));
	dccf.setPassivePorts(Configuration.getValue(all_instances_confs, name, "passive-ports", "30000-40000"));
	log.put("passive", dccf.getPassiveAddress() + ">" + dccf.getPassiveExternalAddress());
	log.put("passive ports", dccf.getPassivePorts());
	
	ListenerFactory factory = new ListenerFactory();
	factory.setPort(Configuration.getValue(all_instances_confs, name, "listen", 21));
	factory.setIpFilter(FTPIpFilter.getFilter());
	factory.setIdleTimeout(idle);
	log.put("port", factory.getPort());
	
	factory.setDataConnectionConfiguration(dccf.createDataConnectionConfiguration());
	
	server_factory.addListener("default", factory.createListener());
	
	FTPUserManager ftpum;
	if (name == "default") {
		ftpum = new FTPUserManager("");
	} else {
		ftpum = new FTPUserManager(name);
		server_factory.setUserManager(ftpum);
	}
	server_factory.setUserManager(ftpum);
	log.put("User Manager", ftpum);
	
	server_factory.setFtplets(ftplets);
	
	Loggers.FTPserver.info("Start FTP Server: " + log);
	
	FtpServer server = server_factory.createServer();
	server.start();
	return server;
}
 
開發者ID:hdsdi3g,項目名稱:MyDMAM,代碼行數:56,代碼來源:FTPOperations.java


注:本文中的org.apache.ftpserver.FtpServer.start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。