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/api/StopServerHandler.java |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/de/uhilger/tango/api/StopServerHandler.java b/src/de/uhilger/tango/api/StopServerHandler.java
index 33b9d61..bcad82c 100644
--- a/src/de/uhilger/tango/api/StopServerHandler.java
+++ b/src/de/uhilger/tango/api/StopServerHandler.java
@@ -22,6 +22,7 @@
 import de.uhilger.tango.App;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.ResourceBundle;
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.logging.Logger;
@@ -41,6 +42,8 @@
   public static final String RB_SERVER_STOPPED = "serverStopped";
   public static final String RB_MEDIAZ_END = "mediazEnd";
 
+  private ResourceBundle rb;
+  
   /**
    * Den Server geordnet herunterfahren und 
    * dann die Anwendung beenden.
@@ -52,13 +55,13 @@
   @Override
   public void handle(HttpExchange e) throws IOException {
     Logger.getLogger(StopServerHandler.class.getName()).info(e.getRequestURI().toString());
-    String response = App.getRs(RB_SERVER_STOPPED);
+    String response = getResString(RB_SERVER_STOPPED);
     e.sendResponseHeaders(200, response.length());
     OutputStream os = e.getResponseBody();
     os.write(response.getBytes());
     os.flush();
     os.close();
-    logger.info(App.getRs(RB_STOPPING_SERVER));
+    logger.info(getResString(RB_STOPPING_SERVER));
     e.getHttpContext().getServer().stop(1);
     Timer timer = new Timer();
     timer.schedule(new AppStopper(), 2000);
@@ -72,9 +75,15 @@
 
     @Override
     public void run() {
-      logger.info(App.getRs(RB_MEDIAZ_END));
-      App.stop();
+      logger.info(getResString(RB_MEDIAZ_END));
+      System.exit(0);
     }
   }
 
+  protected String getResString(String key) {
+    if(rb == null) {
+      rb = ResourceBundle.getBundle(App.RB_NAME);
+    }
+    return rb.getString(key);
+  }
 }

--
Gitblit v1.9.3