From 2f2aa7d344d41c6d4083149b1ea6b41e7fb1f683 Mon Sep 17 00:00:00 2001
From: undisclosed
Date: Sat, 07 Jan 2023 15:24:26 +0000
Subject: [PATCH] Baustelle: Calypso 'ins Reine' bauen
---
src/de/uhilger/calypso/neu/AppProperties.java | 93 +++++++++++++++++++++++++++++++
src/de/uhilger/calypso/neu/App.java | 27 +++++++++
src/de/uhilger/calypso/neu/Server.java | 35 +++++++++++
3 files changed, 155 insertions(+), 0 deletions(-)
diff --git a/src/de/uhilger/calypso/neu/App.java b/src/de/uhilger/calypso/neu/App.java
new file mode 100644
index 0000000..603f4ea
--- /dev/null
+++ b/src/de/uhilger/calypso/neu/App.java
@@ -0,0 +1,27 @@
+package de.uhilger.calypso.neu;
+
+import java.util.HashMap;
+
+/**
+ *
+ * @author Ulrich Hilger
+ */
+public class App {
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ HashMap<String, String> initParams = new HashMap();
+ for (String arg : args) {
+ String[] argParts = arg.split(Server.EQUAL);
+ initParams.put(argParts[0], argParts[1]);
+ }
+ String conf = initParams.get(Server.CONF);
+ AppProperties einst = new AppProperties();
+ einst.readFile(conf);
+ Server server;
+ server = new Server();
+ server.start(einst);
+ }
+
+}
diff --git a/src/de/uhilger/calypso/neu/AppProperties.java b/src/de/uhilger/calypso/neu/AppProperties.java
new file mode 100644
index 0000000..f80c4b8
--- /dev/null
+++ b/src/de/uhilger/calypso/neu/AppProperties.java
@@ -0,0 +1,93 @@
+/*
+ Helix - Dateiverwaltung
+ Copyright (C) 2021 Ulrich Hilger
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+package de.uhilger.calypso.neu;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Ulrich Hilger
+ * @version 1, 01.06.2021
+ */
+public class AppProperties extends Properties {
+
+ public static final String EMPTY_STR = "";
+ public static final int INT_ZERO = 0;
+
+ public String getString(String key) {
+ Object o = this.get(key);
+ if(o instanceof String) {
+ return (String) o;
+ } else {
+ return EMPTY_STR;
+ }
+ }
+
+ public int getInt(String key) {
+ Object o = this.get(key);
+ if(o instanceof String) {
+ String intStr = (String) o;
+ return Integer.parseInt(intStr);
+ } else {
+ return INT_ZERO;
+ }
+ }
+
+ public void readFile(String fName) {
+ Logger.getLogger(AppProperties.class.getName()).log(Level.INFO, fName);
+ InputStream in = null;
+ try {
+ // Einstellungen aus Datei lesen
+ //AppProperties einst = new AppProperties();
+ File einstellungenDatei = new File(fName);
+ in = new FileInputStream(einstellungenDatei);
+
+ //BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ //String line = br.readLine();
+ //while(line != null) {
+ // System.out.println(line);
+ // line = br.readLine();
+ //}
+ //br.close();
+
+
+ load(in);
+ in.close();
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(AppProperties.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(AppProperties.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ try {
+ in.close();
+ } catch (IOException ex) {
+ Logger.getLogger(AppProperties.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+
+ }
+
+}
diff --git a/src/de/uhilger/calypso/neu/Server.java b/src/de/uhilger/calypso/neu/Server.java
new file mode 100644
index 0000000..db467ba
--- /dev/null
+++ b/src/de/uhilger/calypso/neu/Server.java
@@ -0,0 +1,35 @@
+package de.uhilger.calypso.neu;
+
+import java.io.File;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author Ulrich Hilger
+ */
+public class Server {
+
+ private static final Logger logger = Logger.getLogger(de.uhilger.calypso.Server.class.getName());
+
+ public static final String CONF = "conf";
+ public static final String PORT = "port";
+ public static final String SKRIPTE = "skripte";
+
+ public static final String EQUAL = "=";
+
+ private AppProperties einst;
+
+ public void start(AppProperties einst) {
+ logger.log(Level.INFO, "Server startet auf Port {0}", einst.getString(PORT));
+ this.einst = einst;
+ String skripte = einst.getString(SKRIPTE);
+ File playSkript = new File(skripte, "play");
+ if(playSkript.exists()) {
+ logger.log(Level.INFO, "Skripte gefunden in {0}", playSkript.getParentFile().getAbsolutePath());
+ } else {
+ logger.log(Level.INFO, "Skripte nicht gefunden, Ordner laut Einstellungen: {0}", skripte);
+ }
+ }
+
+}
--
Gitblit v1.9.3