From f9dd4f3a00efe7581e9bd620a9b968f122090f7a Mon Sep 17 00:00:00 2001 From: undisclosed Date: Sun, 22 Jan 2023 13:50:46 +0000 Subject: [PATCH] Experimentell: JavaScript-Player fuer 'hier spielen' bei Abspiellisten --- src/de/uhilger/tango/Server.java | 48 ++++++++++++++++++++++++++++-------------------- 1 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/de/uhilger/tango/Server.java b/src/de/uhilger/tango/Server.java index 7c47baf..d5d445a 100644 --- a/src/de/uhilger/tango/Server.java +++ b/src/de/uhilger/tango/Server.java @@ -25,6 +25,7 @@ import de.uhilger.tango.api.MediaSteuerung; import de.uhilger.tango.api.StopServerHandler; import de.uhilger.tango.api.StorageHandler; +import de.uhilger.tango.api.StreamHandler; import de.uhilger.tango.store.FileStorage; import de.uhilger.tango.entity.Ablageort; import java.io.File; @@ -36,6 +37,7 @@ import de.uhilger.tango.entity.Entity; import java.util.Iterator; import java.util.List; +import java.util.ResourceBundle; /** * Die Klasse Server stellt Methoden zur Ausführung eines HTTP-Servers @@ -53,7 +55,8 @@ 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_ALIST = "alist"; + public static final String RB_STRM = "strm"; //public static final String RB_UI_ROOT = "uiroot"; public static final String RB_STOP_SERVER = "stopServer"; //public static final String RB_ABLAGE_TEST = "testAblage"; @@ -64,7 +67,7 @@ private String ctx; - private HttpServer server; + //private HttpServer server; /** * Ein neues Objekt der Kalsse Server erzeugen @@ -73,7 +76,7 @@ */ public Server(int port) { this.port = port; - } + } /** * Den Port angeben, unter dem der Server erreichbar sein soll @@ -106,37 +109,42 @@ * Objekt * @throws java.lang.ClassNotFoundException */ - public void start() throws IOException, ClassNotFoundException { - logger.log(Level.INFO, App.getRs(RB_SERVER_START_MSG), Integer.toString(port)); + public void start(String wwwData, String conf) throws IOException, ClassNotFoundException { + ResourceBundle rb = ResourceBundle.getBundle(App.RB_NAME); + logger.log(Level.INFO, rb.getString(RB_SERVER_START_MSG), Integer.toString(port)); - String wwwData = App.getInitParameter(App.getRs(App.RB_AP_WWW_DATA)); + //String wwwData = App.getInitParameter(rb.getString(App.RB_AP_WWW_DATA)); File wwwDir = new File(wwwData); - 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)); + HttpServer server = HttpServer.create(new InetSocketAddress(port), 0); + server.createContext(ctx + rb.getString(RB_WEBROOT), new FileHandler(wwwDir.getAbsolutePath())); + ablageorteEinklinken(server, rb, conf); + server.createContext(ctx + rb.getString(RB_STORE), new StorageHandler(conf)); + server.createContext(ctx + rb.getString(RB_STRG), new MediaSteuerung(conf)); + server.createContext(ctx + rb.getString(RB_GSTRG), new GeraetSteuerung(conf)); + server.createContext(ctx + rb.getString(RB_ALIST), new ListHandler(conf)); + server.createContext(ctx + rb.getString(RB_STRM), new StreamHandler(conf)); + server.createContext(ctx + rb.getString(RB_STOP_SERVER), new StopServerHandler()); + //server.setExecutor(Executors.newFixedThreadPool(20)); + server.setExecutor(Executors.newFixedThreadPool(5)); server.start(); } + /* public void ablageortEntfernen(String url) { server.removeContext(ctx + url); } - public void ablageortHinzufuegen(Ablageort ort) { + public void ablageortHinzufuegen(Ablageort ort, String conf) { server.createContext(ctx + ort.getUrl(), - new ListFileHandler(new File(ort.getOrt()).getAbsolutePath())); + new ListFileHandler(new File(ort.getOrt()).getAbsolutePath(), conf)); } + */ - private void ablageorteEinklinken(HttpServer server) + private void ablageorteEinklinken(HttpServer server, ResourceBundle rb, String conf) throws ClassNotFoundException, IOException { String typ = Ablageort.class.getSimpleName(); - FileStorage store = new FileStorage(App.getInitParameter(App.getRs(App.RB_AP_CONF))); + FileStorage store = new FileStorage(conf); List<String> orte = store.list(typ); Iterator<String> i = orte.iterator(); while(i.hasNext()) { @@ -147,7 +155,7 @@ logger.log(Level.FINE, "{0}{1}", new Object[]{ctx, ablageort.getUrl()}); logger.fine(ablageort.getOrt()); server.createContext(ctx + ablageort.getUrl(), - new ListFileHandler(new File(ablageort.getOrt()).getAbsolutePath())); + new ListFileHandler(new File(ablageort.getOrt()).getAbsolutePath(), conf)); } } } -- Gitblit v1.9.3