From cfa85894465dbf2d286e083d962babdf14641582 Mon Sep 17 00:00:00 2001 From: ulrich Date: Sun, 04 Apr 2021 14:30:21 +0000 Subject: [PATCH] UI begonnen --- src/de/uhilger/mediaz/Server.java | 35 ++++++++++++++++++++++++++--------- 1 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/de/uhilger/mediaz/Server.java b/src/de/uhilger/mediaz/Server.java index ebaf91d..4bc3286 100644 --- a/src/de/uhilger/mediaz/Server.java +++ b/src/de/uhilger/mediaz/Server.java @@ -18,12 +18,16 @@ package de.uhilger.mediaz; import com.sun.net.httpserver.HttpServer; -import de.uhilger.mediaz.handler.FileHandler; -import de.uhilger.mediaz.handler.StopServerHandler; +import de.uhilger.mediaz.api.AblageTestHandler; +import de.uhilger.mediaz.api.FileHandler; +import de.uhilger.mediaz.api.StopServerHandler; +import de.uhilger.mediaz.api.StoreTestHandler; +import java.io.File; import java.io.IOException; import java.util.logging.Logger; import java.net.InetSocketAddress; import java.util.concurrent.Executors; +import java.util.logging.Level; /** * Die Klasse Server stellt Methoden zur Ausführung eines @@ -36,8 +40,13 @@ private static final Logger logger = Logger.getLogger(Server.class.getName()); - public static final String STR_SLASH = "/"; - public static final String CMD_SERVER_STOP = "/server/stop"; + public static final String RB_SERVER_START_MSG = "msgServerStart"; + public static final String RB_WEBROOT = "webroot"; + public static final String RB_UI_ROOT = "uiroot"; + public static final String RB_STOP_SERVER = "stopServer"; + public static final String RB_ABLAGE_TEST = "testAblage"; + public static final String RB_STORE_TEST = "testStore"; + public static final String RB_SLASH = "slash"; private int port; @@ -66,8 +75,9 @@ * @param ctxName Name des Kontexts, unter dem der Server aufrufbar sein soll */ public void setContextName(String ctxName) { - if(!ctxName.startsWith(STR_SLASH)) { - this.ctx = STR_SLASH + ctxName; + String slash = App.getRs(RB_SLASH); + if(!ctxName.startsWith(slash)) { + this.ctx = slash + ctxName; } else { this.ctx = ctxName; } @@ -81,11 +91,18 @@ * in diesem Objekt */ public void start() throws IOException { - logger.info("Server starting on port " + port); + logger.log(Level.INFO, App.getRs(RB_SERVER_START_MSG), Integer.toString(port)); + + String ui = App.getInitParameter(App.getRs(App.RB_AP_UI)); + + File uiDir = new File(ui); HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); - server.createContext(ctx + STR_SLASH, new FileHandler(App.getInitParameter(App.IP_WWW_DATA))); - server.createContext(ctx + CMD_SERVER_STOP, new StopServerHandler()); + server.createContext(ctx + App.getRs(RB_WEBROOT), new FileHandler(App.getInitParameter(App.getRs(App.RB_AP_WWW_DATA)))); + server.createContext(ctx + App.getRs(RB_UI_ROOT), new FileHandler(uiDir.getAbsolutePath())); + server.createContext(ctx + App.getRs(RB_STOP_SERVER), new StopServerHandler()); + server.createContext(ctx + App.getRs(RB_ABLAGE_TEST), new AblageTestHandler()); + server.createContext(ctx + App.getRs(RB_STORE_TEST), new StoreTestHandler()); server.setExecutor(Executors.newFixedThreadPool(20)); server.start(); } -- Gitblit v1.9.3