FileDocCategorySizeDatePackage
UnboundedPool.javaAPI DocGlassfish v2 API5154Fri May 04 22:32:18 BST 2007com.sun.enterprise.util.pool

UnboundedPool

public class UnboundedPool extends ArrayListPool
An UnboundedPool can be used to create a pool of unlimited size. All getObject(....) methods are guaranteed to return an object irrespective of the wait flag and wait time. Note that if the objects held in the pool consume a siginificant memory, then maintaining a large UnboundedPool may cause java.lang.OutOfMemory error (which probably would not have occured if there was no pooling!!). If memory is an issue then use SoftUnboundedPool.

The initial size of the pool and the load factor of the pool determine how the pool size adjusts dynamically. For example, if the initial pool size is 100 and if the load factor is 90, then as soon as 90% of the pool objects are used (given out), then the pool size grows by 10.

Fields Summary
private int
initialSize
Constructors Summary
public UnboundedPool(ObjectFactory factory, int initialSize)
Create an Unbounded pool.

param
The ObjectFactory to create objects
param
The initial number of objects to be held in the pool
param
The load factor. This value indicates when and how much the pool should expand / shrink. Both initialSize and loadFactor are used to compute the new size during expansion / shrinking.

        super(factory, initialSize);
        this.initialSize = initialSize;
        super.preload(initialSize);
    
Methods Summary
protected booleancanCreate()
Since this method would be called only if the pool is empty, and since this an unbounded pool, CREATE IT!!

        return true;
    
protected java.lang.Objectcheckin(java.lang.Object object)
Notification when an object is put back into the pool (checkin).

param
The object to be returned back to the pool.
return
Any non null value can be returned to signal that the object was indeed added to the pool. This class always adds the object to the pool (at the end of the list), it returns non-null value. Subclasses can override this behaviour.

		if (waitCount == 0) {
			int diff = arrayList.size() - initialSize;
			if (diff > initialSize) {
				super.destroyPoolObjects(diff);
			}
		}
		
		arrayList.add(object);
    	return this;