use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.
the class PortManager method process.
public String process() throws TransactionFailure {
try {
// if there are no port system-property's -- no point in going on!
if (newServerPorts.getMap().isEmpty())
// all done!
return null;
// make sure user-supplied props are not flaky
PortUtils.checkInternalConsistency(newServer);
// create a list of ALL servers running on the same machine
createServerList();
// create a sorted list of every port on every other server on the same machine.
populateAllPorts();
// we have a list of all possible conflicting server ports.
// let's find some unused ports and reassign the variables inside
// the ServerPorts class
Map<String, Integer> reassigned = reassignPorts();
Set<Map.Entry<String, Integer>> entries = reassigned.entrySet();
List<SystemProperty> sps = newServer.getSystemProperty();
// We want to display EVERY port assignment -- no matter if it overrides or
// not. Tricky to get the display string just right.
// if there are reassignments -- we overwrite the ones in finalPorts.
// if not -- finalPorts contains all the stock ones
// in any case ALL port assignments should be displayed.
Map<String, Integer> finalPorts = newServerPorts.getMap();
if (entries.size() > 0) {
for (Map.Entry<String, Integer> entry : entries) {
String name = entry.getKey();
int port = entry.getValue();
// do not want commas in the int!
changeSystemProperty(sps, name, "" + port);
finalPorts.put(name, port);
}
}
return generateAssignedPortMessage(finalPorts);
} catch (Exception e) {
throw new TransactionFailure(e.toString(), e);
}
}
use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.
the class ServerHelper method translatePortOld.
private static String translatePortOld(String portString, Server server, Config config) {
if (!isToken(portString))
return portString;
// isToken returned true so we are NOT assuming anything below!
String key = portString.substring(2, portString.length() - 1);
// check cluster and the cluster's config if applicable
// bnevins Jul 18, 2010 -- don't botehr this should never be called anymore
SystemProperty prop = server.getSystemProperty(key);
if (prop != null) {
return prop.getValue();
}
prop = config.getSystemProperty(key);
if (prop != null) {
return prop.getValue();
}
return null;
}
use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.
the class ServerPorts method addAll.
private void addAll(List<SystemProperty> propList) {
if (propList == null)
return;
for (SystemProperty sp : propList) {
// we only care about
// 1. the official Port Props that we support
// 2. But only if they also have a value that is a legal port number
String name = sp.getName();
String value = sp.getValue();
if (StringUtils.ok(name) && StringUtils.ok(value) && PORTSLIST.contains(name)) {
try {
int port = Integer.parseInt(value);
if (NetUtils.isPortValid(port))
props.put(name, port);
} catch (Exception e) {
// we're all done here!
}
}
}
}
Aggregations