commit | author | age
|
8e2038
|
1 |
package de.uhilger.avdirektor.handler; |
U |
2 |
|
|
3 |
import com.sun.net.httpserver.HttpExchange; |
|
4 |
import com.sun.net.httpserver.HttpHandler; |
|
5 |
import de.uhilger.avdirektor.App; |
|
6 |
import java.io.IOException; |
|
7 |
import java.io.OutputStream; |
|
8 |
import java.util.logging.Logger; |
|
9 |
|
|
10 |
/** |
|
11 |
* |
|
12 |
* @author ulrich |
|
13 |
*/ |
|
14 |
public class StopServerHandler implements HttpHandler { |
|
15 |
|
|
16 |
@Override |
|
17 |
public void handle(HttpExchange exchange) throws IOException { |
|
18 |
Logger.getLogger(StopServerHandler.class.getName()).info(exchange.getRequestURI().toString()); |
|
19 |
String response = "Server stopped"; |
|
20 |
exchange.sendResponseHeaders(200, response.length()); |
|
21 |
OutputStream os = exchange.getResponseBody(); |
|
22 |
os.write(response.getBytes()); |
|
23 |
os.close(); |
|
24 |
Logger.getLogger(StopServerHandler.class.getName()).info("stopping app."); |
|
25 |
App.stop(); |
|
26 |
//exchange.getHttpContext().getServer().stop(5); |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
} |