use of org.apache.commons.configuration2.io.CombinedLocationStrategy in project zeppelin by apache.
the class ZeppelinConfiguration method loadXMLConfig.
private void loadXMLConfig(@Nullable String filename) throws ConfigurationException {
if (StringUtils.isBlank(filename)) {
filename = ZEPPELIN_SITE_XML;
}
List<FileLocationStrategy> subs = Arrays.asList(new ZeppelinLocationStrategy(), new ClasspathLocationStrategy());
FileLocationStrategy strategy = new CombinedLocationStrategy(subs);
Parameters params = new Parameters();
FileBasedConfigurationBuilder<XMLConfiguration> xmlbuilder = new FileBasedConfigurationBuilder<XMLConfiguration>(XMLConfiguration.class).configure(params.xml().setLocationStrategy(strategy).setFileName(filename).setBasePath(File.separator + "conf" + File.separator));
XMLConfiguration xmlConfig = xmlbuilder.getConfiguration();
List<ImmutableNode> nodes = xmlConfig.getNodeModel().getRootNode().getChildren();
if (nodes != null && !nodes.isEmpty()) {
for (ImmutableNode p : nodes) {
String name = String.valueOf(p.getChildren("name").get(0).getValue());
String value = String.valueOf(p.getChildren("value").get(0).getValue());
if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
setProperty(name, value);
}
}
}
}
Aggregations