ro.isdc.wro.extensions.processor.support
Class ObjectPoolHelper<T>

java.lang.Object
  extended by ro.isdc.wro.extensions.processor.support.ObjectPoolHelper<T>

public class ObjectPoolHelper<T>
extends Object

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
ObjectPoolHelper(ObjectFactory<T> objectFactory)
           
 
Method Summary
 T getObject()
           
protected  org.apache.commons.pool.impl.GenericObjectPool<T> newObjectPool(ObjectFactory<T> objectFactory)
          Creates a GenericObjectPool.
 void returnObject(T engine)
           
 void setObjectPool(org.apache.commons.pool.impl.GenericObjectPool<T> objectPool)
          Use a custom GenericObjectPool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPoolHelper

public ObjectPoolHelper(ObjectFactory<T> objectFactory)
Method Detail

newObjectPool

protected org.apache.commons.pool.impl.GenericObjectPool<T> newObjectPool(ObjectFactory<T> objectFactory)
Creates a GenericObjectPool. Override this method to set custom objectPool configurations.


getObject

public T getObject()
Returns:
object from the pool.

returnObject

public void returnObject(T engine)

setObjectPool

public final void setObjectPool(org.apache.commons.pool.impl.GenericObjectPool<T> objectPool)
Use a custom GenericObjectPool.

Parameters:
objectPool - to use.


Copyright © 2008-2013. All Rights Reserved.