From b5cc80f43d78a4fef88a06449f218b30517fa117 Mon Sep 17 00:00:00 2001 From: ulrich Date: Tue, 23 Mar 2021 14:16:23 +0000 Subject: [PATCH] AbstractHandler hinzugefuegt --- src/de/uhilger/avdirektor/handler/CmdHandler.java | 39 +-------------------------------------- 1 files changed, 1 insertions(+), 38 deletions(-) diff --git a/src/de/uhilger/avdirektor/handler/CmdHandler.java b/src/de/uhilger/avdirektor/handler/CmdHandler.java index 7e3193e..38f2b6f 100644 --- a/src/de/uhilger/avdirektor/handler/CmdHandler.java +++ b/src/de/uhilger/avdirektor/handler/CmdHandler.java @@ -1,10 +1,6 @@ package de.uhilger.avdirektor.handler; import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -12,23 +8,12 @@ * * @author ulrich */ -public class CmdHandler extends OMXPlayer implements HttpHandler { +public class CmdHandler extends AbstractHandler { private static final Logger logger = Logger.getLogger(CmdHandler.class.getName()); - protected String cmd; - protected Map map; - public CmdHandler(String cmd) { this.cmd = cmd; - } - - @Override - public void handle(HttpExchange t) throws IOException { - logger.log(Level.FINE, "RequestURI: {0}", t.getRequestURI().toString()); - StringBuilder params = buildParams(t); - String antwort = process(t, params.toString()); - sendResponse(t, cmd, antwort); } protected String process(HttpExchange t, String params) { @@ -37,26 +22,4 @@ return antwort; } - protected StringBuilder buildParams(HttpExchange t) { - map = getQueryMap(t); - StringBuilder params = new StringBuilder(); - return params; - } - - protected void sendResponse(HttpExchange t, String cmd, String antwort) throws IOException { - String response = getResponseString(map, cmd, antwort); - t.sendResponseHeaders(200, response.length()); - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); - } - - public void setCmd(String cmd) { - this.cmd = cmd; - } - - public String getCmd(String cmd) { - return this.cmd; - } - } -- Gitblit v1.9.3