Class AbstractPool
- java.lang.Object
-
- com.sun.ejb.containers.util.pool.AbstractPool
-
- All Implemented Interfaces:
Pool
- Direct Known Subclasses:
NonBlockingPool
public abstract class AbstractPool extends Object implements Pool
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
Fields Modifier and Type Field Description protected static Logger_loggerprotected StringappNameprotected longbeanIdprotected StringconfigDataprotected ClassLoadercontainerClassLoaderprotected intcreatedCountprotected intdestroyedCountprotected StringejbNameprotected ObjectFactoryfactoryprotected intidleTimeoutInSecondsprotected ArrayListlistprotected intmaxPoolSizeprotected longmaxWaitTimeInMillisprotected StringmodNameprotected StringpoolNameprotected EjbPoolProbeProviderpoolProbeNotifierprotected intpoolReturnedprotected intpoolSuccessprotected intresizeQuantityprotected intsteadyPoolSizeprotected intwaitCount
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPool()protectedAbstractPool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidappendStats(StringBuffer sbuf)voidclose()Close the poolvoiddestroyObject(Object object)Destroys an Object.StringgetAllAttrValues()StringgetAllMonitoredAttrbuteValues()intgetCreatedCount()intgetDestroyedCount()intgetIdleTimeoutInSeconds()intgetJmsMaxMessagesLoad()intgetMaxPoolSize()longgetMaxWaitTimeInMillis()intgetNumBeansInPool()intgetNumThreadsWaiting()ObjectgetObject(boolean canWait, Object param)Get an object.ObjectgetObject(long maxWaitTime, Object param)ObjectgetObject(Object param)Get an object from the pool within the specified time.intgetPoolSuccess()intgetResizeQuantity()intgetSize()intgetSteadyPoolSize()intgetTotalBeansCreated()intgetTotalBeansDestroyed()intgetWaitCount()protected 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 voidremoveIdleObjects()voidreturnObject(Object object)Return an object back to the pool.voidsetConfigData(String configData)voidsetContainerClassLoader(ClassLoader loader)voidsetInfo(String appName, String modName, String ejbName)protected voidunregisterProbeProvider()
-
-
-
Field Detail
-
_logger
protected static final Logger _logger
-
list
protected ArrayList list
-
factory
protected ObjectFactory factory
-
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
protected ClassLoader containerClassLoader
-
destroyedCount
protected int destroyedCount
-
poolSuccess
protected int poolSuccess
-
poolName
protected String poolName
-
poolReturned
protected int poolReturned
-
configData
protected String configData
-
poolProbeNotifier
protected EjbPoolProbeProvider poolProbeNotifier
-
appName
protected String appName
-
modName
protected String modName
-
ejbName
protected String ejbName
-
beanId
protected long beanId
-
-
Constructor Detail
-
AbstractPool
protected AbstractPool()
-
AbstractPool
protected AbstractPool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader)
-
-
Method Detail
-
initializePool
protected void initializePool(ObjectFactory factory, long beanId, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader)
-
setContainerClassLoader
public void setContainerClassLoader(ClassLoader loader)
-
getObject
public Object getObject(boolean canWait, Object param) throws PoolException
Get an object. Application can use pool.getObject() to get an object instead of using new XXX().- Specified by:
getObjectin interfacePool- Parameters:
canWait- Must be true if the calling thread is willing to wait for infinite time to get an object, false if the calling thread does not want to wait at all.- Throws:
PoolException
-
getObject
public Object getObject(long maxWaitTime, Object param) throws PoolException
- Specified by:
getObjectin interfacePool- Throws:
PoolException
-
getObject
public Object getObject(Object param) throws PoolException
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
public void returnObject(Object object)
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
public void destroyObject(Object object)
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
public void setConfigData(String configData)
-
appendStats
public void appendStats(StringBuffer sbuf)
-
getJmsMaxMessagesLoad
public int getJmsMaxMessagesLoad()
-
getNumBeansInPool
public int getNumBeansInPool()
-
getNumThreadsWaiting
public int getNumThreadsWaiting()
-
getTotalBeansCreated
public int getTotalBeansCreated()
-
getTotalBeansDestroyed
public int getTotalBeansDestroyed()
-
getAllMonitoredAttrbuteValues
public String getAllMonitoredAttrbuteValues()
-
getAllAttrValues
public String getAllAttrValues()
-
unregisterProbeProvider
protected void unregisterProbeProvider()
-
-