FileDocCategorySizeDatePackage
BoundedPool.javaAPI DocGlassfish v2 API4278Fri May 04 22:33:00 BST 2007com.sun.ejb.containers.util.pool

BoundedPool

public class BoundedPool extends AbstractPool

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.

Fields Summary
protected int
previousSize
Constructors Summary
public BoundedPool(ObjectFactory factory, int steadyPoolSize, int resizeQuantity, int maxPoolsize, long maxWaitTimeInMillis, int idleTimeoutInSeconds, ClassLoader loader)

    
         
              
           
    
    	super(factory, steadyPoolSize, resizeQuantity, maxPoolsize,
              maxWaitTimeInMillis, idleTimeoutInSeconds, loader);
        super.poolName="BoundedPool";
    
Methods Summary
protected voidremoveIdleObjects()

        int curSize = 0;
        int count = 0;
        synchronized (list) {
            curSize = list.size();
        }

        if(curSize <= steadyPoolSize)
            return; // no need to trim the pool beyond steadyPoolSize
        count = (curSize > (steadyPoolSize + resizeQuantity) ) ? 
            resizeQuantity: (curSize - steadyPoolSize);
        previousSize = curSize;
        
        if (count > 0) {
            _logger.log(Level.FINE,
                        "BoundedPool removing " + count + " objects");
            super.remove(count);
        }