public void parseConfiguration(final InputStream input) throws Exception { Reader reader = new InputStreamReader(input); String xml = XMLUtil.readerToString(reader); xml = XMLUtil.replaceSystemProps(xml); Element e = XMLUtil.stringToElement(xml); // only parse elements from <jms> NodeList children = e.getElementsByTagName(CONFIGURATION_SCHEMA_ROOT_ELEMENT); if (children.getLength() > 0) { parseConfiguration(children.item(0)); } }
public Configuration parseMainConfig(final InputStream input) throws Exception { Reader reader = new InputStreamReader(input); String xml = XMLUtil.readerToString(reader); xml = XMLUtil.replaceSystemProps(xml); Element e = XMLUtil.stringToElement(xml); SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd")); Validator validator = schema.newValidator(); try { validator.validate(new DOMSource(e)); } catch (Exception ex) { ActiveMQServerLogger.LOGGER.error(ex.getMessage()); } Configuration config = new ConfigurationImpl(); parseMainConfig(e, config); return config; }
@Override public void reload(URL url) throws Exception { ActiveMQServerLogger.LOGGER.reloadingConfiguration("jms"); InputStream input = url.openStream(); String xml; try (Reader reader = new InputStreamReader(input)) { xml = XMLUtil.readerToString(reader); } xml = XMLUtil.replaceSystemProps(xml); Element e = XMLUtil.stringToElement(xml); if (config instanceof FileJMSConfiguration) { NodeList children = e.getElementsByTagName("jms"); //if the "jms" element exists then parse it if (children.getLength() > 0) { ((FileJMSConfiguration) config).parse((Element) children.item(0), url); JMSServerManagerImpl.this.deploy(); } } } }
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); } } } }
url = configFile.toURI().toURL(); reader = new InputStreamReader(url.openStream()); String xml = XMLUtil.readerToString(reader); xml = XMLUtil.replaceSystemProps(xml); Element e = XMLUtil.stringToElement(xml);
String xml = XMLUtil.readerToString(reader); xml = XMLUtil.replaceSystemProps(xml); configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
String xml = XMLUtil.readerToString(reader); xml = XMLUtil.replaceSystemProps(xml); configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));