commit | author | age
|
9c7249
|
1 |
/* |
U |
2 |
mc2 - Mediacenter neu |
|
3 |
Copyright (C) 2021 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
|
19 |
package de.uhilger.minsrv; |
|
20 |
|
|
21 |
import java.io.IOException; |
|
22 |
import java.util.HashMap; |
|
23 |
import java.util.logging.Level; |
|
24 |
import java.util.logging.Logger; |
|
25 |
|
|
26 |
/** |
|
27 |
* |
|
28 |
* @author ulrich |
|
29 |
* @version 0.1, 25.03.2021 |
|
30 |
*/ |
|
31 |
public class App { |
|
32 |
|
|
33 |
private static final Logger logger = Logger.getLogger(App.class.getName()); |
|
34 |
|
|
35 |
public static final String IP_PORT = "port"; |
|
36 |
public static final String IP_WWW_DATA = "www-data"; |
|
37 |
|
|
38 |
private static HashMap initParams; |
|
39 |
|
|
40 |
/** |
|
41 |
* @param args the command line arguments |
|
42 |
*/ |
|
43 |
public static void main(String[] args) { |
|
44 |
initParams = new HashMap(); |
|
45 |
for(String arg: args) { |
|
46 |
String[] argParts = arg.split("="); |
|
47 |
initParams.put(argParts[0], argParts[1]); |
|
48 |
} |
|
49 |
|
|
50 |
Server server = new Server(Integer.parseInt(getInitParameter(IP_PORT))); |
|
51 |
try { |
|
52 |
server.start(); |
|
53 |
} catch (IOException ex) { |
|
54 |
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
public static void stop() { |
|
59 |
System.exit(0); |
|
60 |
} |
|
61 |
|
|
62 |
public static String getInitParameter(String pname) { |
|
63 |
String param = null; |
|
64 |
Object o = initParams.get(pname); |
|
65 |
if(o != null) { |
|
66 |
param = o.toString(); |
|
67 |
} |
|
68 |
return param; |
|
69 |
} |
|
70 |
} |