From c2c1fd263b9a72779df397f28c5bdd8f4d934524 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Sat, 24 Apr 2021 10:49:55 +0000
Subject: [PATCH] Umbenannt zu Calypso

---
 src/de/uhilger/calypso/App.java    |   11 +++++++++--
 resources/start                    |    2 +-
 resources/logging.properties       |    4 ++--
 src/de/uhilger/calypso/Server.java |   28 +++++++++++++++++++---------
 4 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/resources/logging.properties b/resources/logging.properties
index 95c6897..947d664 100644
--- a/resources/logging.properties
+++ b/resources/logging.properties
@@ -68,5 +68,5 @@
 # de.uhilger.filecms.level = FINEST
 # de.uhilger.wbx.handlers = java.util.logging.ConsoleHandler
 # de.uhilger.wbx.level = FINEST
-de.uhilger.avdirektor.handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
-de.uhilger.avdirektor.level = FINEST
+de.uhilger.calypso.handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
+de.uhilger.calypso.level = FINEST
diff --git a/resources/start b/resources/start
index 9c4469f..e1da2e7 100755
--- a/resources/start
+++ b/resources/start
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-java -Domx.wd=/mnt/store/avd -Djava.util.logging.config.file=logging.properties -jar av-direktor.jar port=9090 player=omx &
+java -Domx.wd=/mnt/store/avd -Djava.util.logging.config.file=logging.properties -jar calypso.jar port=9090 player=omx ctx=/calypso &
\ No newline at end of file
diff --git a/src/de/uhilger/calypso/App.java b/src/de/uhilger/calypso/App.java
index 8cf84c5..1de8ffc 100644
--- a/src/de/uhilger/calypso/App.java
+++ b/src/de/uhilger/calypso/App.java
@@ -30,7 +30,7 @@
  * Hauptklasse des av-director
  * 
  * Aufruf mit
- * java -jar av-director.jar port=9000
+ * java -jar av-director.jar port=9000 ctx="/calypso"
  * java -jar av-director.jar nfs-prefix="/media/mc" port=9000
  * java -Djava.util.logging.config.file=logging.properties -jar ..
  * 
@@ -52,12 +52,13 @@
   public static final String VLC_PLAYER = "vlc";
   public static final String OMX_PLAYER = "omx";
   public static final String OMX_WD = "omx.wd";
+  public static final String CTX = "ctx";
   
+  public static final String DEFAULT_CTX = "/calypso";
   
   private static HashMap initParams;  
   private static Process playerproc;
   private static Player player;
-  
   
   /**
    * @param args the command line arguments
@@ -79,6 +80,12 @@
         break;
     }
     Server server = new Server(Integer.parseInt(getInitParameter(IP_PORT)));
+    String ctx = getInitParameter(CTX);
+    if(ctx != null && ctx.length() > 0) {
+      server.setContextName(ctx);    
+    } else {
+      server.setContextName(DEFAULT_CTX);
+    }
     try {
       server.start();
     } catch (IOException ex) {
diff --git a/src/de/uhilger/calypso/Server.java b/src/de/uhilger/calypso/Server.java
index d1064a1..a4dce04 100644
--- a/src/de/uhilger/calypso/Server.java
+++ b/src/de/uhilger/calypso/Server.java
@@ -43,6 +43,8 @@
 
   private int port;
   
+  private String contextName;
+  
   public Server(int port) {
     this.port = port;
   }
@@ -51,19 +53,27 @@
     this.port = port;
   }
   
+  /**
+   * 
+   * @param contextName e.g. '/calypso' or '/cal'
+   */
+  public void setContextName(String contextName) {
+    this.contextName = contextName;
+  }
+  
   public void start() throws IOException {
     logger.info("Server starting on port " + port);
 
     HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
-    server.createContext("/avd/play", new PlayHandler(OMXPlayer.F_PLAY));
-    server.createContext("/avd/seek", new SeekHandler(OMXPlayer.F_SEEK));
-    server.createContext("/avd/stop", new CmdHandler(OMXPlayer.CMD_STOP));
-    server.createContext("/avd/pause", new CmdHandler(OMXPlayer.CMD_PAUSE_RESUME));
-    server.createContext("/avd/ping", new PingHandler(OMXPlayer.F_PING));
-    server.createContext("/avd/server/stop", new StopServerHandler());
-    server.createContext("/avd/log", new LogHandler());
-    server.createContext("/avd/playon", new PlayOnHandler(OMXPlayer.F_PLAY_ON));
-    server.createContext("/avd/ui", new FileHandler(App.getInitParameter(App.IP_WWW_DATA)));
+    server.createContext(contextName + "/play", new PlayHandler(OMXPlayer.F_PLAY));
+    server.createContext(contextName + "/seek", new SeekHandler(OMXPlayer.F_SEEK));
+    server.createContext(contextName + "/stop", new CmdHandler(OMXPlayer.CMD_STOP));
+    server.createContext(contextName + "/pause", new CmdHandler(OMXPlayer.CMD_PAUSE_RESUME));
+    server.createContext(contextName + "/ping", new PingHandler(OMXPlayer.F_PING));
+    server.createContext(contextName + "/server/stop", new StopServerHandler());
+    server.createContext(contextName + "/log", new LogHandler());
+    server.createContext(contextName + "/playon", new PlayOnHandler(OMXPlayer.F_PLAY_ON));
+    server.createContext(contextName + "/ui", new FileHandler(App.getInitParameter(App.IP_WWW_DATA)));
     //server.setExecutor(null); // creates a default executor
     server.setExecutor(Executors.newFixedThreadPool(20));
     server.start();

--
Gitblit v1.9.3