Search in sources :

Example 1 with StartupOptions

use of alma.acs.commandcenter.app.CommandCenterLogic.StartupOptions in project ACS by ACS-Community.

the class CommandCenter method main.

public static void main(String[] args) {
    for (Handler h : Logger.getLogger("").getHandlers()) {
        if (h instanceof ConsoleHandler) {
            h.setFormatter(new Formatter() {

                DateFormat df = new SimpleDateFormat("HH:mm:ss ");

                @Override
                public String format(LogRecord record) {
                    String s = df.format(new Date(record.getMillis()));
                    s += record.getMessage() + "\n";
                    return s;
                }
            });
        }
    }
    // --- parse the command line
    StartupOptions startupOptions = new StartupOptions();
    for (int i = 0; i < args.length; i++) {
        if (i == 0 && equalsOneOf(args[i], new String[] { "-h", "-help", "--help" })) {
            printUsage(System.out);
            return;
        }
        try {
            if (equalsOneOf(args[i], new String[] { "-r", "-retrieve", "--retrieve" })) {
                startupOptions.project = new File(args[++i]);
                continue;
            }
            if (equalsOneOf(args[i], new String[] { "-g", "-geometry", "--geometry" })) {
                StringTokenizer toky = new StringTokenizer(args[++i], "x+");
                int w = Integer.parseInt(toky.nextToken());
                int h = Integer.parseInt(toky.nextToken());
                int x = Integer.parseInt(toky.nextToken());
                int y = Integer.parseInt(toky.nextToken());
                startupOptions.geometry = new Rectangle(x, y, w, h);
                continue;
            }
            if (equalsOneOf(args[i], new String[] { "-x", "-noexit", "--noexit" })) {
                startupOptions.doExitOnClose = false;
                continue;
            }
            if (equalsOneOf(args[i], new String[] { "-useNativeSSH", "--useNativeSSH" })) {
                log.warning("command line option '-useNativeSSH' no longer supported.");
                continue;
            }
            if (equalsOneOf(args[i], new String[] { "-killNativeSSH", "--killNativeSSH" })) {
                log.warning("command line option '-killNativeSSH' no longer supported.");
                continue;
            }
            // msc (Oct 24, 2005): stand-alone argument should be considered a project name
            // msc (Apr 28, 2006): alternatively it could be a manager location
            String standalone = args[i];
            if (standalone.length() > 8 && standalone.substring(0, 8).equalsIgnoreCase("corbaloc")) {
                startupOptions.manager = standalone;
                continue;
            }
            String mgrArg = MiscUtils.convertShortNotationToCorbaloc(standalone);
            if (mgrArg != null) {
                startupOptions.manager = mgrArg;
                continue;
            }
            startupOptions.project = new File(standalone);
        } catch (Exception exc) {
            // ArrayIndexOutOfBounds, NumberFormat, ...
            startupOptions = new StartupOptions();
            log.warning("command line argument(s) invalid, some arguments may be ignored: " + Arrays.asList(args));
            printUsage(System.err);
        }
    }
    // --- instantiate appropriate logic
    commandCenterLogic = new CommandCenterLogic();
    commandCenterLogic.prepare(startupOptions);
    if (startupOptions.project != null) {
        commandCenterLogic.loadProject(startupOptions.project);
    }
    commandCenterLogic.go();
}
Also used : CommandCenterLogic(alma.acs.commandcenter.app.CommandCenterLogic) Formatter(java.util.logging.Formatter) Rectangle(java.awt.Rectangle) ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) ConsoleHandler(java.util.logging.ConsoleHandler) Date(java.util.Date) StringTokenizer(java.util.StringTokenizer) LogRecord(java.util.logging.LogRecord) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) StartupOptions(alma.acs.commandcenter.app.CommandCenterLogic.StartupOptions)

Aggregations

CommandCenterLogic (alma.acs.commandcenter.app.CommandCenterLogic)1 StartupOptions (alma.acs.commandcenter.app.CommandCenterLogic.StartupOptions)1 Rectangle (java.awt.Rectangle)1 File (java.io.File)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 StringTokenizer (java.util.StringTokenizer)1 ConsoleHandler (java.util.logging.ConsoleHandler)1 Formatter (java.util.logging.Formatter)1 Handler (java.util.logging.Handler)1 LogRecord (java.util.logging.LogRecord)1