Package org.apache.ftpserver

Examples of org.apache.ftpserver.FtpServer


    /**
     * Get the configuration object.
     */
    protected FtpServer getConfiguration(String[] args) throws Exception {

        FtpServer server = null;
        if (args.length == 0) {
            System.out.println("Using default configuration");
            server = new FtpServerFactory().createServer();
        } else if ((args.length == 1) && args[0].equals("-default")) {
            // supported for backwards compatibility, but not documented
View Full Code Here


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
       
        FtpServer server = (FtpServer) getServletContext().getAttribute(FtpServerListener.FTPSERVER_CONTEXT_NAME);
       
        PrintWriter wr = resp.getWriter();
       
        wr.print("<html>");
        wr.print("<head>");
        wr.print("<title>FtpServer status servlet</title>");
        wr.print("</head>");
        wr.print("<body>");
        wr.print("<form method='post'>");


        if(server.isStopped()) {
            wr.print("<p>FtpServer is stopped.</p>");
        } else {
            if(server.isSuspended()) {
                wr.print("<p>FtpServer is suspended.</p>");
                wr.print("<p><input type='submit' name='resume' value='Resume'></p>");
                wr.print("<p><input type='submit' name='stop' value='Stop'></p>");
            } else {
                wr.print("<p>FtpServer is running.</p>");
View Full Code Here

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
       
        FtpServer server = (FtpServer) getServletContext().getAttribute(FtpServerListener.FTPSERVER_CONTEXT_NAME);
       
        if(req.getParameter("stop") != null) {
            server.stop();
        } else if(req.getParameter("resume") != null) {
            server.resume();
        } else if(req.getParameter("suspend") != null) {
            server.suspend();
        }
       
        resp.sendRedirect("/");
    }
View Full Code Here

    public static final String FTPSERVER_CONTEXT_NAME = "org.apache.ftpserver";
   
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("Stopping FtpServer");
       
        FtpServer server = (FtpServer) sce.getServletContext().getAttribute(FTPSERVER_CONTEXT_NAME);
       
        if(server != null) {
            server.stop();
           
            sce.getServletContext().removeAttribute(FTPSERVER_CONTEXT_NAME);
           
            System.out.println("FtpServer stopped");
        } else {
View Full Code Here

    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);
        }
    }
View Full Code Here

        userManagerFactory.setFile(new File("myusers.properties"));
       
        serverFactory.setUserManager(userManagerFactory.createUserManager());
       
        // start the server
        FtpServer server = serverFactory.createServer();
       
        server.start();
    }
View Full Code Here

        // create servce context
        FtpServerContext ftpConfig = new ConfigurableFtpServerContext(config);

        // create the server object and start it
        return new FtpServer(ftpConfig);
    }
View Full Code Here

      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);
    }
View Full Code Here

      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);
    }
View Full Code Here

        // create service context
        FtpServerContext ftpConfig = new ConfigurableFtpServerContext(config);

        // create the server object and start it
        ftpServer = new FtpServer(ftpConfig);
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.FtpServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.