public void readConfiguration() throws Exception { URL url; url = Thread.currentThread().getContextClassLoader().getResource(configurationUrl); if (url == null) { // trying a different classloader now url = getClass().getClassLoader().getResource(configurationUrl); } if (url == null) { // The URL is outside of the classloader. Trying a pure url now url = new URL(configurationUrl); } // create a reader try (Reader reader = new InputStreamReader(url.openStream())) { String xml = XMLUtil.readerToString(reader); //replace any system props xml = XMLUtil.replaceSystemProps(xml); Element e = XMLUtil.stringToElement(xml); //iterate around all the deployables for (Deployable deployable : deployables.values()) { String root = deployable.getRootElement(); NodeList children = e.getElementsByTagName(root); //if the root element exists then parse it if (root != null && children.getLength() > 0) { Node item = children.item(0); XMLUtil.validate(item, deployable.getSchema()); deployable.parse((Element) item, url); } } } }
if (root != null && children.getLength() > 0) { Node item = children.item(0); XMLUtil.validate(item, ((FileConfiguration) configuration).getSchema()); ((FileConfiguration) configuration).parse((Element) item, url);
/** * test does not pass in eclipse (because it can not find artemis-configuration.xsd). * It runs fine on the CLI with the proper env setting. */ @Test public void testMinimalConfiguration() throws Exception { String xml = "<core xmlns='urn:activemq:core'>" + "</core>"; Element element = XMLUtil.stringToElement(xml); Assert.assertNotNull(element); XMLUtil.validate(element, "schema/artemis-configuration.xsd"); }