*/
private ArrayList pickNonConflictingPorts(Server server, ArrayList portsInUse)
throws ConfigException
{
Properties props = new Properties();
PortInUse portInUse;
int port;
//We only want to check for port conflicts if the node agent specified has rendezvous'd;
//otherwise, the host name on which it is residing is unknown (defaulting to "localhost").
//Before we can indicate whether a port is in use, we must know the valid host name.
final boolean isBoundToHost = getPortConflictCheckerConfigBean().isBoundToHost(server);
//Iterate through all the conflicting ports and pick new values.
for (int i = 0; i < portsInUse.size(); i++) {
portInUse = (PortInUse)portsInUse.get(i);
port = portInUse.getPort();
int newPort = 0;
if (isBoundToHost) {
newPort = NetUtils.getNextFreePort(portInUse.getHostName(), port);
} else {
newPort = port + 1;
}
//Keep track of the newly assigned and non-conflicting port. WARNING: we are
//side affecting the incoming ArrayList.
portInUse.setNewPort(newPort);
//Build the list of system properties to add to the server instance
props.put(portInUse.getPropertyName(), new Integer(newPort).toString());
}
addServerProperties(server, props);
return portsInUse;
}