1 /*
2 * Copyright (c) 2015 Maxim Yunusov
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
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 * This Abstract class represents interface of Web Server.
26 *
27 * @author myunusov
28 * @version 1.0
29 * @since <pre>30.08.2015</pre>
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 * Start Web server.
43 */
44 public void start() {
45 LOGGER.info("Start Web Server ({})", version());
46 launch();
47 LOGGER.info("Starting on " + webappUrl);
48 }
49
50 /**
51 * Restart Web server.
52 */
53 public void restart() {
54 LOGGER.info("Restart Web Server");
55 launch();
56 LOGGER.info("Starting on " + webappUrl);
57 }
58
59 /**
60 * Stop Web server.
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 }