Class AbstractPool
- All Implemented Interfaces:
Pool
- Direct Known Subclasses:
NonBlockingPool
Abstract pool provides the basic implementation of an object pool. The implementation uses a linked list to maintain a list of (available) objects. If the pool is empty it simply creates one using the ObjectFactory instance. Subclasses can change this behaviour by overriding getObject(...) and returnObject(....) methods. This class provides basic support for synchronization, event notification, pool shutdown and pool object recycling. It also does some very basic bookkeeping like the number of objects created, number of threads waiting for object.
Subclasses can make use of these book-keeping data to provide complex pooling mechanism like LRU / MRU / Random. Also, note that AbstractPool does not have a notion of pool limit. It is upto to the derived classes to implement these features.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Loggerprotected Stringprotected longprotected Stringprotected ClassLoaderprotected intprotected intprotected Stringprotected intprotected intprotected longprotected Stringprotected ObjectFactoryprotected Stringprotected EjbPoolProbeProviderprotected intprotected intprotected intprotected intprotected int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractPool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendStats(StringBuffer sbuf) voidclose()Close the poolvoiddestroyObject(Object object) Destroys an Object.intintintintintlongintintGet an object from the pool within the specified time.intintintgetSize()intintintintprotected voidinitializePool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader) protected voidpreload(int count) Preload the pool with objects.protected voidremove(int count) protected abstract voidvoidreturnObject(Object object) Return an object back to the pool.voidsetConfigData(String configData) voidsetContainerClassLoader(ClassLoader loader) voidprotected void
-
Field Details
-
_logger
-
pooledObjects
-
pooledObjectFactory
-
waitCount
protected int waitCount -
createdCount
protected int createdCount -
steadyPoolSize
protected int steadyPoolSize -
resizeQuantity
protected int resizeQuantity -
maxPoolSize
protected int maxPoolSize -
maxWaitTimeInMillis
protected long maxWaitTimeInMillis -
idleTimeoutInSeconds
protected int idleTimeoutInSeconds -
containerClassLoader
-
destroyedCount
protected int destroyedCount -
poolSuccess
protected int poolSuccess -
poolName
-
poolReturned
protected int poolReturned -
configData
-
poolProbeNotifier
-
appName
-
modName
-
ejbName
-
beanId
protected long beanId
-
-
Constructor Details
-
AbstractPool
protected AbstractPool() -
AbstractPool
protected AbstractPool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader)
-
-
Method Details
-
initializePool
protected void initializePool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader) -
setContainerClassLoader
-
setInfo
-
getObject
Description copied from interface:PoolGet an object from the pool within the specified time.- Specified by:
getObjectin interfacePool- Returns:
- an Object or null if an object could not be returned in 'waitForMillis' millisecond.
- Throws:
PoolException
-
returnObject
Return an object back to the pool. An object that is obtained through getObject() must always be returned back to the pool using either returnObject(obj) or through destroyObject(obj).- Specified by:
returnObjectin interfacePool
-
destroyObject
Destroys an Object. Note that applications should not ignore the reference to the object that they got from getObject(). An object that is obtained through getObject() must always be returned back to the pool using either returnObject(obj) or through destroyObject(obj). This method tells that the object should be destroyed and cannot be reused.- Specified by:
destroyObjectin interfacePool
-
preload
protected void preload(int count) Preload the pool with objects.- Parameters:
count- the number of objects to be added.
-
close
public void close()Close the pool -
remove
protected void remove(int count) -
removeIdleObjects
protected abstract void removeIdleObjects() -
getCreatedCount
public int getCreatedCount() -
getDestroyedCount
public int getDestroyedCount() -
getPoolSuccess
public int getPoolSuccess() -
getSize
public int getSize() -
getWaitCount
public int getWaitCount() -
getSteadyPoolSize
public int getSteadyPoolSize() -
getResizeQuantity
public int getResizeQuantity() -
getMaxPoolSize
public int getMaxPoolSize() -
getMaxWaitTimeInMillis
public long getMaxWaitTimeInMillis() -
getIdleTimeoutInSeconds
public int getIdleTimeoutInSeconds() -
setConfigData
-
appendStats
-
getJmsMaxMessagesLoad
public int getJmsMaxMessagesLoad() -
getNumBeansInPool
public int getNumBeansInPool() -
getNumThreadsWaiting
public int getNumThreadsWaiting() -
getTotalBeansCreated
public int getTotalBeansCreated() -
getTotalBeansDestroyed
public int getTotalBeansDestroyed() -
getAllMonitoredAttrbuteValues
-
getAllAttrValues
-
unregisterProbeProvider
protected void unregisterProbeProvider()
-