Package org.apache.ftpserver

Examples of org.apache.ftpserver.FtpServer


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


    /**
     * 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

       
       
        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;
            }
        }
    }
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

        AddUser addUser = new AddUser();
       
        try {

            // get configuration
            FtpServer server = addUser.getConfiguration(args);
            if (server == null) {
                return;
            }
           
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
View Full Code Here

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

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

        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) {
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.