use of org.openntf.openliberty.domino.util.xml.XMLNode in project openliberty-domino by OpenNTF.
the class LibertyServerInstance method getListeningPorts.
@Override
public Collection<Integer> getListeningPorts() {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Path serverXml = getWlpRoot().resolve("usr").resolve("servers").resolve(serverName).resolve("server.xml");
if (Files.isRegularFile(serverXml)) {
// Parse the server.xml for port information
try {
XMLDocument xml = new XMLDocument();
try (InputStream is = Files.newInputStream(serverXml)) {
xml.loadInputStream(is);
}
// $NON-NLS-1$
XMLNodeList nodes = xml.selectNodes("/server/httpEndpoint");
if (!nodes.isEmpty()) {
// Last one wins in WLP
XMLNode node = nodes.get(nodes.size() - 1);
// $NON-NLS-1$
String host = node.getAttribute("host");
if (StringUtil.isEmpty(host)) {
host = InetAddress.getLocalHost().getHostName();
}
// $NON-NLS-1$
String httpPort = node.getAttribute("httpPort");
if (StringUtil.isEmpty(httpPort)) {
// This seems to be the default when unspecified
// $NON-NLS-1$
httpPort = "9080";
}
// $NON-NLS-1$
String httpsPort = node.getAttribute("httpsPort");
return Stream.of(httpPort, httpsPort).filter(StringUtil::isNotEmpty).filter(// $NON-NLS-1$
p -> !"-1".equals(p)).map(port -> Integer.parseInt(port)).collect(Collectors.toList());
}
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (SAXException | ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
return Collections.emptyList();
}
use of org.openntf.openliberty.domino.util.xml.XMLNode in project openliberty-domino by OpenNTF.
the class LibertyServerInstance method getListeningHost.
@Override
public String getListeningHost() {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Path serverXml = getWlpRoot().resolve("usr").resolve("servers").resolve(serverName).resolve("server.xml");
if (Files.isRegularFile(serverXml)) {
// Parse the server.xml for port information
try {
XMLDocument xml = new XMLDocument();
try (InputStream is = Files.newInputStream(serverXml)) {
xml.loadInputStream(is);
}
// $NON-NLS-1$
XMLNodeList nodes = xml.selectNodes("/server/httpEndpoint");
if (!nodes.isEmpty()) {
// Last one wins in WLP
XMLNode node = nodes.get(nodes.size() - 1);
// $NON-NLS-1$
String host = node.getAttribute("host");
if (StringUtil.isEmpty(host)) {
// $NON-NLS-1$
return "localhost";
} else {
return host;
}
}
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (SAXException | ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
// $NON-NLS-1$
return "*";
}
Aggregations