Tabnine Logo
XMLUtil.replaceSystemProps
Code IndexAdd Tabnine to your IDE (free)

How to use
replaceSystemProps
method
in
org.apache.activemq.artemis.utils.XMLUtil

Best Java code snippets using org.apache.activemq.artemis.utils.XMLUtil.replaceSystemProps (Showing top 8 results out of 315)

origin: apache/activemq-artemis

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));
 }
}
origin: apache/activemq-artemis

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;
}
origin: apache/activemq-artemis

 @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();
    }
   }
 }
}
origin: apache/activemq-artemis

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);
    }
   }
 }
}
origin: apache/activemq-artemis

@Test
public void testReplaceSystemProperties() {
 String before = "<configuration>\n" + "   <test name=\"${sysprop1}\">content1</test>\n" + "   <test name=\"test2\">content2</test>\n" + "   <test name=\"test3\">content3</test>\n" + "   <test name=\"test4\">${sysprop2}</test>\n" + "   <test name=\"test5\">content5</test>\n" + "   <test name=\"test6\">content6</test>\n" + "</configuration>";
 String after = "<configuration>\n" + "   <test name=\"test1\">content1</test>\n" + "   <test name=\"test2\">content2</test>\n" + "   <test name=\"test3\">content3</test>\n" + "   <test name=\"test4\">content4</test>\n" + "   <test name=\"test5\">content5</test>\n" + "   <test name=\"test6\">content6</test>\n" + "</configuration>";
 System.setProperty("sysprop1", "test1");
 System.setProperty("sysprop2", "content4");
 String replaced = XMLUtil.replaceSystemProps(before);
 Assert.assertEquals(after, replaced);
}
origin: apache/activemq-artemis

reader = new InputStreamReader(url.openStream());
String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
Element e = XMLUtil.stringToElement(xml);
origin: org.apache.activemq.rest/artemis-rest

Reader reader = new InputStreamReader(url.openStream());
String xml = XMLUtil.readerToString(reader);
xml = XMLUtil.replaceSystemProps(xml);
configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
origin: apache/activemq-artemis

try (Reader reader = new InputStreamReader(url.openStream())) {
  String xml = XMLUtil.readerToString(reader);
  xml = XMLUtil.replaceSystemProps(xml);
  configuration = (MessageServiceConfiguration) jaxb.createUnmarshaller().unmarshal(new StringReader(xml));
org.apache.activemq.artemis.utilsXMLUtilreplaceSystemProps

Popular methods of XMLUtil

  • assertEquivalent
  • elementToString
  • findResource
  • getTextContent
    Note: if the content is another element or set of elements, it returns a string representation of th
  • filter
  • readerToElement
  • stringToElement
  • readerToString
  • validate
  • parseBoolean
  • parseDouble
  • parseInt
  • parseDouble,
  • parseInt,
  • parseLong,
  • stripCDATA

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • setScale (BigDecimal)
  • compareTo (BigDecimal)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Reference (javax.naming)
  • JComboBox (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now