From 7d31187663154286b4a49beaf49d98ffd004ec06 Mon Sep 17 00:00:00 2001 From: ulrich Date: Sat, 24 Apr 2021 08:33:16 +0000 Subject: [PATCH] UI-Anpassungen --- src/de/uhilger/mediaz/Server.java | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/src/de/uhilger/mediaz/Server.java b/src/de/uhilger/mediaz/Server.java index 2f71fc9..a758078 100644 --- a/src/de/uhilger/mediaz/Server.java +++ b/src/de/uhilger/mediaz/Server.java @@ -19,6 +19,7 @@ import com.sun.net.httpserver.HttpServer; import de.uhilger.mediaz.api.FileHandler; +import de.uhilger.mediaz.api.GeraetSteuerung; import de.uhilger.mediaz.api.ListFileHandler; import de.uhilger.mediaz.api.ListHandler; import de.uhilger.mediaz.api.MediaSteuerung; @@ -51,6 +52,7 @@ public static final String RB_WEBROOT = "webroot"; public static final String RB_STORE = "store"; public static final String RB_STRG = "strg"; + public static final String RB_GSTRG = "gstrg"; public static final String RB_ALIST= "alist"; //public static final String RB_UI_ROOT = "uiroot"; public static final String RB_STOP_SERVER = "stopServer"; @@ -61,6 +63,8 @@ private int port; private String ctx; + + private HttpServer server; /** * Ein neues Objekt der Kalsse Server erzeugen @@ -108,17 +112,27 @@ String wwwData = App.getInitParameter(App.getRs(App.RB_AP_WWW_DATA)); File wwwDir = new File(wwwData); - HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); + server = HttpServer.create(new InetSocketAddress(port), 0); server.createContext(ctx + App.getRs(RB_WEBROOT), new FileHandler(wwwDir.getAbsolutePath())); ablageorteEinklinken(server); server.createContext(ctx + App.getRs(RB_STORE), new StorageHandler()); server.createContext(ctx + App.getRs(RB_STRG), new MediaSteuerung()); + server.createContext(ctx + App.getRs(RB_GSTRG), new GeraetSteuerung()); server.createContext(ctx + App.getRs(RB_ALIST), new ListHandler()); server.createContext(ctx + App.getRs(RB_STOP_SERVER), new StopServerHandler()); server.setExecutor(Executors.newFixedThreadPool(20)); server.start(); } + + public void ablageortEntfernen(String url) { + server.removeContext(ctx + url); + } + public void ablageortHinzufuegen(Ablageort ort) { + server.createContext(ctx + ort.getUrl(), + new ListFileHandler(new File(ort.getOrt()).getAbsolutePath())); + } + private void ablageorteEinklinken(HttpServer server) throws ClassNotFoundException, IOException { String typ = Ablageort.class.getSimpleName(); -- Gitblit v1.9.3