Class DomBuildersPool

java.lang.Object
org.openehealth.ipf.commons.core.DomBuildersPool

public class DomBuildersPool extends Object
Pool for DOM document builders (which are not thread-safe).
Since:
3.5.1 TODO shouldn't this be in ipf-commons-xml
Author:
Dmytro Rud
  • Field Details

    • POOL_SIZE_PROPERTY

      public static final String POOL_SIZE_PROPERTY
  • Method Details

    • take

      public static DocumentBuilder take()
      Returns a document builder instance.
    • restore

      public static void restore(DocumentBuilder documentBuilder)
      Returns a document builder (previously gained via take()) to the pool. This method MUST be called as soon as the use of the document builder is finished.
      Parameters:
      documentBuilder - document builder, null values are safe.
    • use

      public static <R> R use(Function<DocumentBuilder,R> operation)
      Takes a document builder object from the pool, uses it to execute the given operation, and returns it to the pool.
      Type Parameters:
      R - operation return type
      Parameters:
      operation - operation to execute using a document builder
      Returns:
      result of the execution of the operation
    • use

      public static <R> R use(Closure<R> closure)
      Takes a document builder object from the pool, uses it to execute the given Groovy closure, and returns it to the pool.
      Type Parameters:
      R - closure return type
      Parameters:
      closure - closure to execute using a document builder
      Returns:
      result of the execution of the closure