/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package de.uhilger.mediaz; import java.io.IOException; import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author ulrich */ public class App { private static final Logger logger = Logger.getLogger(App.class.getName()); public static final String IP_PORT = "port"; public static final String IP_WWW_DATA = "www-data"; public static final String IP_CTX = "ctx"; private static HashMap initParams; /** *
Start-Methode dieser Anwendung
* * @param args Kommandozeilenparameter */ public static void main(String[] args) { initParams = new HashMap(); for (String arg : args) { String[] argParts = arg.split("="); initParams.put(argParts[0], argParts[1]); } String portStr = getInitParameter(IP_PORT); if (portStr != null) { Server server = new Server(Integer.parseInt(portStr)); try { String ctxName = getInitParameter(IP_CTX); if (ctxName != null) { server.setContextName(ctxName); server.start(); } else { logger.severe("Der Parameter " + IP_CTX + " muss angegeben werden."); } } catch (IOException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } } else { logger.severe("Der Parameter " + IP_PORT + " muss angegeben werden."); } } /** * Diese Anwendung stoppen */ public static void stop() { System.exit(0); } /** * Einen Kommandozeilenparameter ermitteln * * @param pname Names des Parameters * @return Inhalt des Parameters oder null, wenn der Parameter nicht gefunden * wurde */ public static String getInitParameter(String pname) { String param = null; Object o = initParams.get(pname); if (o != null) { param = o.toString(); } return param; } }