Example #1
0
  private Main(String[] arguments) {
    //
    // check for debug and trace cli options
    //

    String[] args = arguments;

    if (CLIHelper.isOptionPresent(args, "-trace")) {
      args = CLIHelper.consolidate(args, "-trace");
      System.setProperty("dpml.trace", "true");
      m_trace = true;
    }

    if (CLIHelper.isOptionPresent(args, "-debug")) {
      args = CLIHelper.consolidate(args, "-debug");
      System.setProperty("dpml.debug", "true");
      m_debug = true;
    }

    args = processSystemProperties(args);

    //
    // handle cli sub-system establishment
    //

    Command command = getCommand(args);
    if (Command.STATION.equals(command)) {
      handleStation(args);
    } else {
      if (null == System.getProperty("dpml.logging.config")) {
        if (m_trace) {
          System.setProperty("dpml.logging.config", "local:properties:dpml/transit/trace");
        } else if (m_debug) {
          System.setProperty("dpml.logging.config", "local:properties:dpml/transit/debug");
        } else {
          System.setProperty("dpml.logging.config", "local:properties:dpml/transit/default");
        }
      }

      if (m_debug || m_trace) {
        for (int i = 0; i < arguments.length; i++) {
          getLogger().debug("arg[" + i + "]: " + arguments[i]);
        }
      }

      if (Command.BUILD.equals(command)) {
        handleBuild(args);
      } else if (Command.TRANSIT.equals(command)) {
        handleTransit(args);
      } else if (Command.METRO.equals(command)) {
        handleMetro(args);
      } else {
        final String error = "Missing application key '" + APPLICATION_KEY + "'.";
        System.err.println(error);
        System.exit(1);
      }
    }
  }
Example #2
0
 private void handleStation(String[] args) {
   new File(Transit.DPML_DATA, "logs/station").mkdirs();
   if (CLIHelper.isOptionPresent(args, "-server")) {
     if (m_trace) {
       System.setProperty("dpml.logging.level", "FINEST");
     } else if (m_debug) {
       System.setProperty("dpml.logging.level", "FINE");
     }
     if (getLogger().isTraceEnabled()) {
       getLogger().trace("launching station in server mode");
     }
     String name = "station";
     args = CLIHelper.consolidate(args, "-server");
     String spec = "@DEPOT-STATION-SERVER-URI@";
     handlePlugin(name, spec, args, true);
   } else {
     if (getLogger().isTraceEnabled()) {
       getLogger().trace("launching station in client mode");
     }
     String name = "station";
     String spec = "@DEPOT-STATION-URI@";
     handlePlugin(name, spec, args, false);
   }
 }