1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.maxur.perfmodel.backend.service;
17
18 import org.slf4j.Logger;
19
20 import javax.inject.Named;
21
22 import static org.slf4j.LoggerFactory.getLogger;
23
24
25
26
27
28
29
30
31 public abstract class WebServer {
32
33 private static final Logger LOGGER = getLogger(WebServer.class);
34
35 protected static final String WEB_APP_URL = "/";
36
37 @SuppressWarnings("unused")
38 @Named("webapp.folderName")
39 private String webappUrl;
40
41
42
43
44 public void start() {
45 LOGGER.info("Start Web Server ({})", version());
46 launch();
47 LOGGER.info("Starting on " + webappUrl);
48 }
49
50
51
52
53 public void restart() {
54 LOGGER.info("Restart Web Server");
55 launch();
56 LOGGER.info("Starting on " + webappUrl);
57 }
58
59
60
61
62 public void stop() {
63 LOGGER.info("Stop Web Server");
64 shutdown();
65 }
66
67 protected abstract String version();
68
69 protected abstract void launch();
70
71 protected abstract void shutdown();
72
73 public abstract boolean isStarted();
74
75 }