Class Dom4jTools

java.lang.Object
io.jmix.core.common.xmlparsing.Dom4jTools

@Component("core_Dom4jTools") public class Dom4jTools extends Object
Helper bean for XML parsing with DOM4J.

Caches SAXParser instances in the pool.

The pool size and timeout to borrow can be configured with the jmix.core.dom4jMaxPoolSize and jmix.core.dom4jMaxBorrowWaitMillis application properties.

  • Field Details

    • properties

      protected CoreProperties properties
    • servletContext

      protected javax.servlet.ServletContext servletContext
    • pool

      protected org.apache.commons.pool2.impl.GenericObjectPool<SAXParser> pool
  • Constructor Details

    • Dom4jTools

      @Autowired public Dom4jTools(CoreProperties properties, @Nullable javax.servlet.ServletContext servletContext)
      INTERNAL
  • Method Details

    • initPool

      protected void initPool()
    • shutdown

      public void shutdown()
      Shuts down the pool, unregisters JMX.
    • writeDocument

      public String writeDocument(org.dom4j.Document doc, boolean prettyPrint)
    • writeDocument

      public void writeDocument(org.dom4j.Document doc, boolean prettyPrint, Writer writer)
    • writeDocument

      public void writeDocument(org.dom4j.Document doc, boolean prettyPrint, OutputStream stream)
    • readDocument

      public org.dom4j.Document readDocument(File file)
    • readDocument

      public org.dom4j.Document readDocument(InputStream stream)
    • readDocument

      public org.dom4j.Document readDocument(Reader reader)
    • readDocument

      public org.dom4j.Document readDocument(String xmlString)
    • storeMap

      public void storeMap(org.dom4j.Element parentElement, Map<String,String> map)
    • loadMap

      public void loadMap(org.dom4j.Element mapElement, Map<String,String> map)
    • walkAttributesRecursive

      public void walkAttributesRecursive(org.dom4j.Element element, Dom4j.ElementAttributeVisitor visitor)
    • walkAttributes

      public void walkAttributes(org.dom4j.Element element, Dom4j.ElementAttributeVisitor visitor)
    • getSaxReader

      protected org.dom4j.io.SAXReader getSaxReader(SAXParser saxParser)
    • withSAXParserFromPool

      protected <T> T withSAXParserFromPool(Function<SAXParser,T> action)