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
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
restore
(DocumentBuilder documentBuilder) Returns a document builder (previously gained viatake()
) to the pool.static DocumentBuilder
take()
Returns a document builder instance.static <R> R
Takes a document builder object from the pool, uses it to execute the given Groovy closure, and returns it to the pool.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.
-
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,null
values 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
-