String newNameServerHostName = "";
Properties defaultNodeArgs = experiment.getDefaultNodeArguments(); String oldNameServer = defaultNodeArgs.getProperty("org.cougaar.name.server"); String newNameServer = null; String dfltNameServer = null; String nameServerHost = null; if (oldNameServer != null) { int colon = oldNameServer.indexOf(':'); if (colon >= 0) { nameServerHost = oldNameServer.substring(0, colon); } else { nameServerHost = oldNameServer; } }
  private void setNameServerHostName() {    String newNameServerHostName = "";    HostComponent[] hosts = experiment.getHosts();    for (int i = 0; i < hosts.length; i++) {      NodeComponent[] nodes = hosts[i].getNodes();      for (int j = 0; j < nodes.length; j++) {	AgentComponent[] agents = nodes[j].getAgents();	// skip nodes that have no agents	if (agents == null || agents.length == 0)	  continue;        newNameServerHostName = hosts[i].getShortName();        break;      }    }    // set new server host name in all nodes    nameServerHostName = newNameServerHostName;    NodeComponent[] nodes = experiment.getNodes();    for (int i = 0; i < nodes.length; i++) {      NodeComponent node = nodes[i];      Properties arguments = node.getArguments();      // Insure no per-node override exists      arguments.remove("org.cougaar.name.server");    }    // Now install experiment-wide setting.    experiment.getDefaultNodeArguments().put("org.cougaar.name.server",                                             nameServerHostName + ":" +                                             CSMARTConsole.NAME_SERVER_PORTS);  }