client/ftpd/src/se/lu/thep/coreftpd/FTPServerStart.java

Code
Comments
Other
Rev Date Author Line
789 23 Oct 06 olle 1 /*
789 23 Oct 06 olle 2  $Id$
789 23 Oct 06 olle 3
1916 31 Aug 07 jari 4  Copyright (C) 2006 Olle Mansson
1916 31 Aug 07 jari 5  Copyright (C) 2007 Gregory Vincic, Olle Mansson
789 23 Oct 06 olle 6
789 23 Oct 06 olle 7  This file is part of Proteios.
789 23 Oct 06 olle 8  Available at http://www.proteios.org/
789 23 Oct 06 olle 9
789 23 Oct 06 olle 10  Proteios is free software; you can redistribute it and/or modify it
789 23 Oct 06 olle 11  under the terms of the GNU General Public License as published by
789 23 Oct 06 olle 12  the Free Software Foundation; either version 2 of the License, or
789 23 Oct 06 olle 13  (at your option) any later version.
789 23 Oct 06 olle 14
789 23 Oct 06 olle 15  Proteios is distributed in the hope that it will be useful, but
789 23 Oct 06 olle 16  WITHOUT ANY WARRANTY; without even the implied warranty of
789 23 Oct 06 olle 17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
789 23 Oct 06 olle 18  General Public License for more details.
789 23 Oct 06 olle 19
789 23 Oct 06 olle 20  You should have received a copy of the GNU General Public License
789 23 Oct 06 olle 21  along with this program; if not, write to the Free Software
789 23 Oct 06 olle 22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
789 23 Oct 06 olle 23  02111-1307, USA.
789 23 Oct 06 olle 24  */
791 23 Oct 06 olle 25 package se.lu.thep.coreftpd;
789 23 Oct 06 olle 26
789 23 Oct 06 olle 27 import org.proteios.core.Application;
1687 28 May 07 gregory 28 import org.proteios.core.Config;
791 23 Oct 06 olle 29 import se.lu.thep.coreftpd.webserver.ClassChooser;
789 23 Oct 06 olle 30
789 23 Oct 06 olle 31 /**
789 23 Oct 06 olle 32  * This class Starts the Xerver FTP Server.
789 23 Oct 06 olle 33  * 
789 23 Oct 06 olle 34  * @author Olle
789 23 Oct 06 olle 35  * @version 2.0
789 23 Oct 06 olle 36  */
1687 28 May 07 gregory 37 public class FTPServerStart
1687 28 May 07 gregory 38 {
789 23 Oct 06 olle 39   /**
789 23 Oct 06 olle 40    * Logger used. Used to log specific events.
789 23 Oct 06 olle 41    */
789 23 Oct 06 olle 42   private static final org.apache.log4j.Logger log = org.apache.log4j.LogManager
1687 28 May 07 gregory 43     .getLogger("se.lu.thep.coreftpd");
789 23 Oct 06 olle 44
1687 28 May 07 gregory 45
789 23 Oct 06 olle 46   /**
789 23 Oct 06 olle 47    * Start Xerver FTP Server for Proteios
789 23 Oct 06 olle 48    */
1687 28 May 07 gregory 49   public static void main(String[] s)
1687 28 May 07 gregory 50   {
789 23 Oct 06 olle 51     /*
1676 25 May 07 olle 52      * Start Application
789 23 Oct 06 olle 53      */
1687 28 May 07 gregory 54     Config.setConfigFileName("/ftp.properties");
1676 25 May 07 olle 55     Application.start();
789 23 Oct 06 olle 56     /*
1148 30 Jan 07 gregory 57      * Start FTPServer at specified port (as default port 21 is normally
1148 30 Jan 07 gregory 58      * used).
789 23 Oct 06 olle 59      */
1067 13 Dec 06 olle 60     int portNo = -1;
1687 28 May 07 gregory 61     if (s.length > 0)
1687 28 May 07 gregory 62     {
1687 28 May 07 gregory 63       if (s[0].equals("-h") || s[0].equals("-help"))
1687 28 May 07 gregory 64       {
789 23 Oct 06 olle 65         System.out.println("FTPServerStart [portNo|-h]");
789 23 Oct 06 olle 66         System.exit(0);
1687 28 May 07 gregory 67       }
1687 28 May 07 gregory 68       else
1687 28 May 07 gregory 69       {
789 23 Oct 06 olle 70         /*
789 23 Oct 06 olle 71          * Use first argument as port number.
789 23 Oct 06 olle 72          */
789 23 Oct 06 olle 73         portNo = Integer.valueOf(s[0]).intValue();
789 23 Oct 06 olle 74       }
789 23 Oct 06 olle 75     }
1148 30 Jan 07 gregory 76     // String[] argStrings = { "FTPServer", "-p1234" };
1067 13 Dec 06 olle 77     String[] argStrings;
1687 28 May 07 gregory 78     if (portNo < 1)
1687 28 May 07 gregory 79     {
1067 13 Dec 06 olle 80       argStrings = new String[1];
1067 13 Dec 06 olle 81       argStrings[0] = "FTPServer";
1687 28 May 07 gregory 82     }
1687 28 May 07 gregory 83     else
1687 28 May 07 gregory 84     {
1067 13 Dec 06 olle 85       argStrings = new String[2];
1067 13 Dec 06 olle 86       argStrings[0] = "FTPServer";
1148 30 Jan 07 gregory 87       argStrings[1] = "-p" + portNo;
1067 13 Dec 06 olle 88     }
1148 30 Jan 07 gregory 89     log
1687 28 May 07 gregory 90       .info("--------------------------------------------------------------------");
1676 25 May 07 olle 91     ClassChooser.main(argStrings);
1148 30 Jan 07 gregory 92     log
1687 28 May 07 gregory 93       .info("--------------------------------------------------------------------");
789 23 Oct 06 olle 94   }
789 23 Oct 06 olle 95 }