Class ObjectPoolHelper<T>
java.lang.Object
ro.isdc.wro.extensions.processor.support.ObjectPoolHelper<T>
A generic aware object pool wrapper. Probably not the best name, but it can be changed later. It helps you to avoid
the cast and hides the exception handling by throwing
RuntimeException when borrowing or returning object to
the pool fails.- Since:
- 1.4.2
- Author:
- Alex Objelean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Close the object pool to avoid the memory leak.protected org.apache.commons.pool2.impl.GenericObjectPool<T>newObjectPool(ObjectFactory<T> objectFactory) Creates aGenericObjectPool.voidreturnObject(T engine) final voidsetObjectPool(org.apache.commons.pool2.impl.GenericObjectPool<T> objectPool) Use a customGenericObjectPool.
-
Constructor Details
-
ObjectPoolHelper
-
-
Method Details
-
newObjectPool
protected org.apache.commons.pool2.impl.GenericObjectPool<T> newObjectPool(ObjectFactory<T> objectFactory) Creates aGenericObjectPool. Override this method to set custom objectPool configurations. -
getObject
- Returns:
- object from the pool.
-
returnObject
-
setObjectPool
Use a customGenericObjectPool.- Parameters:
objectPool- to use.
-
destroy
Close the object pool to avoid the memory leak.- Throws:
Exception- if the close operation failed.
-