forked from steve-community/steve
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.java
More file actions
88 lines (72 loc) · 2.69 KB
/
Copy pathApplication.java
File metadata and controls
88 lines (72 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2025 SteVe Community Team
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.rwth.idsg.steve;
import de.rwth.idsg.steve.utils.LogFileRetriever;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.nio.file.Path;
import java.util.Optional;
import java.util.TimeZone;
/**
* @author Sevket Goekay <sevketgokay@gmail.com>
* @since 14.01.2015
*/
@Slf4j
public class Application {
private final JettyServer server;
public Application(SteveConfiguration config) {
server = new JettyServer(config);
}
public static void main(String[] args) throws Exception {
// For Hibernate validator
System.setProperty("org.jboss.logging.provider", "slf4j");
SteveConfiguration sc = SteveConfiguration.CONFIG;
log.info("Loaded the properties. Starting with the '{}' profile", sc.getProfile());
TimeZone.setDefault(TimeZone.getTimeZone(sc.getTimeZoneId()));
DateTimeZone.setDefault(DateTimeZone.forID(sc.getTimeZoneId()));
log.info("Date/time zone of the application is set to {}. Current date/time: {}", sc.getTimeZoneId(), DateTime.now());
Optional<Path> path = LogFileRetriever.INSTANCE.getPath();
boolean loggingToFile = path.isPresent();
if (loggingToFile) {
System.out.println("Log file: " + path.get().toAbsolutePath());
}
Application app = new Application(sc);
try {
app.start();
app.join();
} catch (Exception e) {
log.error("Application failed to start", e);
if (loggingToFile) {
System.err.println("Application failed to start");
e.printStackTrace();
}
app.stop();
}
}
public void start() throws Exception {
server.start();
}
public void join() throws Exception {
server.join();
}
public void stop() throws Exception {
server.stop();
}
}