package de.uhilger.avdirektor.handler; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import de.uhilger.avdirektor.App; import java.io.IOException; import java.io.OutputStream; import java.util.logging.Logger; /** * * @author ulrich */ public class StopServerHandler implements HttpHandler { @Override public void handle(HttpExchange exchange) throws IOException { Logger.getLogger(StopServerHandler.class.getName()).info(exchange.getRequestURI().toString()); String response = "Server stopped"; exchange.sendResponseHeaders(200, response.length()); OutputStream os = exchange.getResponseBody(); os.write(response.getBytes()); os.close(); Logger.getLogger(StopServerHandler.class.getName()).info("stopping app."); App.stop(); //exchange.getHttpContext().getServer().stop(5); } }