com.sun.ejb.containers.util.pool
Class NonBlockingPool

java.lang.Object
  extended by com.sun.ejb.containers.util.pool.AbstractPool
      extended by com.sun.ejb.containers.util.pool.NonBlockingPool
All Implemented Interfaces:
Pool, EJBPoolStatsProvider, StatsProvider

public class NonBlockingPool
extends AbstractPool

NonBlockingPool 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
protected  boolean addedIdleBeanWork
           
protected  boolean addedResizeTask
           
protected  boolean inResizing
           
 
Fields inherited from class com.sun.ejb.containers.util.pool.AbstractPool
_logger, appName, beanId, configData, containerClassLoader, createdCount, destroyedCount, ejbName, factory, idleTimeoutInSeconds, list, maxPoolSize, maxWaitTimeInMillis, modName, poolProbeNotifier, poolReturned, poolSuccess, resizeQuantity, steadyPoolSize, waitCount
 
Constructor Summary
protected NonBlockingPool()
           
  NonBlockingPool(long beanId, String poolName, ObjectFactory factory, int steadyPoolSize, int resizeQuantity, int maxPoolSize, int idleTimeoutInSeconds, ClassLoader loader)
           
  NonBlockingPool(long beanId, String poolName, ObjectFactory factory, int steadyPoolSize, int resizeQuantity, int maxPoolSize, int idleTimeoutInSeconds, ClassLoader loader, boolean singletonBeanPool)
           
 
Method Summary
 void close()
          Close the pool
 void destroyObject(Object object)
          Destroys an Object.
protected  void doResize()
           
 String getAllAttrValues()
           
 Object getObject(boolean canWait, Object param)
          Get an object.
 Object getObject(long maxWaitTime, Object param)
           
 Object getObject(Object param)
          Get an object from the pool within the specified time.
protected  void initializePool(ObjectFactory factory, int steadyPoolSize, int resizeQuantity, int maxPoolSize, int idleTimeoutInSeconds, ClassLoader loader)
           
protected  void preload(int count)
          Preload the pool with objects.
 void prepopulate(int count)
          Prepopulate the pool with objects.
protected  void remove(int count)
           
protected  void removeIdleObjects()
           
 void returnObject(Object object)
          Return an object back to the pool.
 void setContainerClassLoader(ClassLoader loader)
           
 
Methods inherited from class com.sun.ejb.containers.util.pool.AbstractPool
appendStats, getAllMonitoredAttrbuteValues, getCreatedCount, getDestroyedCount, getIdleTimeoutInSeconds, getJmsMaxMessagesLoad, getMaxPoolSize, getMaxWaitTimeInMillis, getNumBeansInPool, getNumThreadsWaiting, getPoolSuccess, getResizeQuantity, getSize, getSteadyPoolSize, getTotalBeansCreated, getTotalBeansDestroyed, getWaitCount, initializePool, setConfigData, setInfo, unregisterProbeProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addedResizeTask

protected boolean addedResizeTask

addedIdleBeanWork

protected volatile boolean addedIdleBeanWork

inResizing

protected boolean inResizing
Constructor Detail

NonBlockingPool

protected NonBlockingPool()

NonBlockingPool

public NonBlockingPool(long beanId,
                       String poolName,
                       ObjectFactory factory,
                       int steadyPoolSize,
                       int resizeQuantity,
                       int maxPoolSize,
                       int idleTimeoutInSeconds,
                       ClassLoader loader)

NonBlockingPool

public NonBlockingPool(long beanId,
                       String poolName,
                       ObjectFactory factory,
                       int steadyPoolSize,
                       int resizeQuantity,
                       int maxPoolSize,
                       int idleTimeoutInSeconds,
                       ClassLoader loader,
                       boolean singletonBeanPool)
Method Detail

initializePool

protected void initializePool(ObjectFactory factory,
                              int steadyPoolSize,
                              int resizeQuantity,
                              int maxPoolSize,
                              int idleTimeoutInSeconds,
                              ClassLoader loader)

setContainerClassLoader

public void setContainerClassLoader(ClassLoader loader)
Overrides:
setContainerClassLoader in class AbstractPool

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:
getObject in interface Pool
Overrides:
getObject in class AbstractPool
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:
getObject in interface Pool
Overrides:
getObject in class AbstractPool
Throws:
PoolException

getObject

public Object getObject(Object param)
Description copied from interface: Pool
Get an object from the pool within the specified time.

Specified by:
getObject in interface Pool
Overrides:
getObject in class AbstractPool
Returns:
an Object or null if an object could not be returned in 'waitForMillis' millisecond.

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:
returnObject in interface Pool
Overrides:
returnObject in class AbstractPool

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:
destroyObject in interface Pool
Overrides:
destroyObject in class AbstractPool

preload

protected void preload(int count)
Preload the pool with objects.

Overrides:
preload in class AbstractPool
Parameters:
count - the number of objects to be added.

prepopulate

public void prepopulate(int count)
Prepopulate the pool with objects.

Parameters:
count - the number of objects to be added.

close

public void close()
Close the pool

Overrides:
close in class AbstractPool

remove

protected void remove(int count)
Overrides:
remove in class AbstractPool

removeIdleObjects

protected void removeIdleObjects()
Specified by:
removeIdleObjects in class AbstractPool

doResize

protected void doResize()

getAllAttrValues

public String getAllAttrValues()
Overrides:
getAllAttrValues in class AbstractPool


Copyright © 2012 GlassFish Community. All Rights Reserved.