Package org.openehealth.ipf.commons.core
Class DomBuildersPool
java.lang.Object
org.openehealth.ipf.commons.core.DomBuildersPool
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidrestore(DocumentBuilder documentBuilder) Returns a document builder (previously gained viatake()) to the pool.static DocumentBuildertake()Returns a document builder instance.static <R> RTakes a document builder object from the pool, uses it to execute the given Groovy closure, and returns it to the pool.static <R> Ruse(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.
-
Field Details
-
POOL_SIZE_PROPERTY
-
-
Method Details
-
take
Returns a document builder instance. -
restore
Returns a document builder (previously gained viatake()) to the pool. This method MUST be called as soon as the use of the document builder is finished.- Parameters:
documentBuilder- document builder,nullvalues are safe.
-
use
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
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
-