public void bootOptionsReceived(BootEvent bootEvent) {
    log.info(" boot options received " + bootEvent.getNewSessionOptions());

    // reload setting, to ensure correct bootstraps
    ConfigureFactory.getInstance().reloadSettings();

    // If the options are not equal to the string 'null' then we have boot options
    if (!bootEvent.getNewSessionOptions().equals("null")) {
      // check if a session parameter is specified on the command line
      String[] args = new String[TN5250jConstants.NUM_PARMS];
      parseArgs(bootEvent.getNewSessionOptions(), args);

      if (isSpecified("-s", args)) {

        String sd = getParm("-s", args);
        if (sessions.containsKey(sd)) {
          parseArgs(sessions.getProperty(sd), args);
          final String[] args2 = args;
          final String sd2 = sd;
          SwingUtilities.invokeLater(() -> newSession(sd2, args2));
        }
      } else {

        if (args[0].startsWith("-")) {
          SwingUtilities.invokeLater(() -> startNewSession());
        } else {
          final String[] args2 = args;
          final String sd2 = args[0];
          SwingUtilities.invokeLater(() -> newSession(sd2, args2));
        }
      }
    } else {
      SwingUtilities.invokeLater(() -> startNewSession());
    }
  }
 private static String getDefaultSession() {
   String defaultSession = sessions.getProperty("emul.default");
   if (defaultSession != null && !defaultSession.trim().isEmpty()) {
     return defaultSession;
   }
   return null;
 }
  public SessionPanel startNewSession() {
    String sel = "";
    if (containsNotOnlyNullValues(sessionArgs) && !sessionArgs[0].startsWith("-")) {
      sel = sessionArgs[0];
    } else {
      sel = getDefaultSession();
    }

    Sessions sess = manager.getSessions();

    if (sel != null && sess.getCount() == 0 && sessions.containsKey(sel)) {
      sessionArgs = new String[TN5250jConstants.NUM_PARMS];
      parseArgs(sessions.getProperty(sel), sessionArgs);
    }

    return newSession(sel, sessionArgs);
  }
  protected void closingDown(TerminalViewInterface view) {

    Sessions sess = manager.getSessions();

    if (log.isDebugEnabled()) {
      log.debug("number of active sessions is " + sess.getCount());
    }

    if (viewNamesForNextStartBuilder == null) {
      // preserve sessions for next boot
      viewNamesForNextStartBuilder = new StringBuilder();
    }
    while (view.getSessionViewCount() > 0) {
      SessionPanel sesspanel = view.getSessionAt(0);
      viewNamesForNextStartBuilder.append("-s ").append(sesspanel.getSessionName()).append(" ");
      closeSessionInternal(sesspanel);
    }

    sessions.setProperty(
        "emul.frame" + view.getFrameSequence(),
        view.getX() + "," + view.getY() + "," + view.getWidth() + "," + view.getHeight());

    frames.remove(view);
    view.dispose();

    log.debug("number of active sessions we have after shutting down " + sess.getCount());

    log.info("view settings " + viewNamesForNextStartBuilder);
    if (sess.getCount() == 0) {

      sessions.setProperty("emul.width", Integer.toString(view.getWidth()));
      sessions.setProperty("emul.height", Integer.toString(view.getHeight()));
      sessions.setProperty("emul.view", viewNamesForNextStartBuilder.toString());

      // save off the session settings before closing down
      ConfigureFactory.getInstance()
          .saveSettings(
              ConfigureFactory.SESSIONS, ConfigureFactory.SESSIONS, "------ Defaults --------");
      if (controller != null) {
        controller.interrupt();
      }
      System.exit(0);
    }
  }
 public static List<String> loadLastSessionViewNames() {
   List<String> sessionNames = new ArrayList<String>();
   if (sessions.containsKey("emul.startLastView")) {
     String emulview = sessions.getProperty("emul.view", "");
     int idxstart = 0;
     int idxend = emulview.indexOf(PARAM_START_SESSION, idxstart);
     for (; idxend > -1; idxend = emulview.indexOf(PARAM_START_SESSION, idxstart)) {
       String sessname = emulview.substring(idxstart, idxend).trim();
       if (sessname.length() > 0) {
         sessionNames.add(sessname);
       }
       idxstart = idxend + PARAM_START_SESSION.length();
     }
     if (idxstart + PARAM_START_SESSION.length() < emulview.length()) {
       String sessname = emulview.substring(idxstart + PARAM_START_SESSION.length() - 1).trim();
       if (sessname.length() > 0) {
         sessionNames.add(sessname);
       }
     }
   }
   return sessionNames;
 }
  private void setDefaultLocale() {

    if (sessions.containsKey("emul.locale")) {
      Locale.setDefault(parseLocal(sessions.getProperty("emul.locale")));
    }
  }
  protected synchronized SessionPanel newSession(String sel, String[] args) {

    Properties sesProps = new Properties();

    String propFileName = null;
    String session = args[0];

    // Start loading properties
    sesProps.put(TN5250jConstants.SESSION_HOST, session);

    if (isSpecified("-e", args)) sesProps.put(TN5250jConstants.SESSION_TN_ENHANCED, "1");

    if (isSpecified("-p", args)) {
      sesProps.put(TN5250jConstants.SESSION_HOST_PORT, getParm("-p", args));
    }

    if (isSpecified("-f", args)) propFileName = getParm("-f", args);

    //  TODO: remove default codepage behavior and replace it with 870

    if (isSpecified("-cp", args))
      sesProps.put(TN5250jConstants.SESSION_CODE_PAGE, getParm("-cp", args));

    sesProps.put(TN5250jConstants.SESSION_USE_GUI, "1");

    if (isSpecified("-t", args)) sesProps.put(TN5250jConstants.SESSION_TERM_NAME_SYSTEM, "1");

    sesProps.put(TN5250jConstants.SESSION_SCREEN_SIZE, TN5250jConstants.SCREEN_SIZE_24X80_STR);

    //  TODO: are we to use a ssl and if we are what type
    sesProps.put(TN5250jConstants.SSL_TYPE, TN5250jConstants.SSL_TYPE_TLS);

    // check if device name is specified
    if (isSpecified("-dn=hostname", args)) {
      String dnParam;

      // use IP address as device name
      try {
        dnParam = InetAddress.getLocalHost().getHostName();
      } catch (UnknownHostException uhe) {
        dnParam = "UNKNOWN_HOST";
      }

      sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, dnParam);
    } else if (isSpecified("-dn", args)) {

      sesProps.put(TN5250jConstants.SESSION_DEVICE_NAME, getParm("-dn", args));
    }

    if (isSpecified("-hb", args)) sesProps.put(TN5250jConstants.SESSION_HEART_BEAT, "1");

    int sessionCount = manager.getSessions().getCount();

    // here we open a new 5250 session on the current session manager
    Session5250 s2 = manager.openSession(sesProps, propFileName, sel);
    // ... and a panel containing it
    SessionPanel s = new SessionPanel(s2);

    newView();
    frame.setVisible(true);
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    if (isSpecified("-t", args)) frame.addSessionView(sel, s);
    else frame.addSessionView(session, s);

    s.connect();

    s.addEmulatorActionListener(this);

    return s;
  }