789 |
23 Oct 06 |
olle |
1 |
/* |
789 |
23 Oct 06 |
olle |
$Id$ |
789 |
23 Oct 06 |
olle |
3 |
|
1916 |
31 Aug 07 |
jari |
Copyright (C) 2006 Olle Mansson |
1916 |
31 Aug 07 |
jari |
Copyright (C) 2007 Gregory Vincic, Olle Mansson |
789 |
23 Oct 06 |
olle |
6 |
|
789 |
23 Oct 06 |
olle |
This file is part of Proteios. |
789 |
23 Oct 06 |
olle |
Available at http://www.proteios.org/ |
789 |
23 Oct 06 |
olle |
9 |
|
789 |
23 Oct 06 |
olle |
Proteios is free software; you can redistribute it and/or modify it |
789 |
23 Oct 06 |
olle |
under the terms of the GNU General Public License as published by |
789 |
23 Oct 06 |
olle |
the Free Software Foundation; either version 2 of the License, or |
789 |
23 Oct 06 |
olle |
(at your option) any later version. |
789 |
23 Oct 06 |
olle |
14 |
|
789 |
23 Oct 06 |
olle |
Proteios is distributed in the hope that it will be useful, but |
789 |
23 Oct 06 |
olle |
WITHOUT ANY WARRANTY; without even the implied warranty of |
789 |
23 Oct 06 |
olle |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
789 |
23 Oct 06 |
olle |
General Public License for more details. |
789 |
23 Oct 06 |
olle |
19 |
|
789 |
23 Oct 06 |
olle |
You should have received a copy of the GNU General Public License |
789 |
23 Oct 06 |
olle |
along with this program; if not, write to the Free Software |
789 |
23 Oct 06 |
olle |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
789 |
23 Oct 06 |
olle |
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 |
* This class Starts the Xerver FTP Server. |
789 |
23 Oct 06 |
olle |
33 |
* |
789 |
23 Oct 06 |
olle |
* @author Olle |
789 |
23 Oct 06 |
olle |
* @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 |
* 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 |
* 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 |
* 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 |
* Start FTPServer at specified port (as default port 21 is normally |
1148 |
30 Jan 07 |
gregory |
* 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 |
* 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 |
// 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 |
} |