throw new IOException(e);
}
}
public static HaDescriptor load(InputStream inputStream) throws IOException {
HaDescriptor descriptor = HaDescriptorFactory.createDescriptor();
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document document = builder.parse(inputStream);
NodeList nodeList = document.getElementsByTagName(SERVICE_ELEMENT);
if (nodeList != null && nodeList.getLength() > 0) {
for (int i = 0; i < nodeList.getLength(); i++) {
Element element = (Element) nodeList.item(i);
HaServiceConfig config = HaDescriptorFactory.createServiceConfig(element.getAttribute(SERVICE_NAME_ATTRIBUTE),
element.getAttribute(ENABLED_ATTRIBUTE),
element.getAttribute(MAX_FAILOVER_ATTEMPTS),
element.getAttribute(FAILOVER_SLEEP),
element.getAttribute(MAX_RETRY_ATTEMPTS),
element.getAttribute(RETRY_SLEEP));
descriptor.addServiceConfig(config);
}
}
} catch (ParserConfigurationException e) {
LOG.failedToLoadHaDescriptor(e);
throw new IOException(e);