FileDocCategorySizeDatePackage
ArrayListPool.javaAPI DocGlassfish v2 API6199Fri May 04 22:32:16 BST 2007com.sun.enterprise.util.pool

ArrayListPool

public abstract class ArrayListPool extends AbstractPool

Abstract pool provides the basic implementation of an object pool. The implementation uses a linked list to maintain a collection 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.

This class does not define the canCreate() method.

Fields Summary
protected ArrayList
arrayList
Constructors Summary
protected ArrayListPool(ObjectFactory factory)

		super.factory = factory;
		super.collection = this.arrayList = new ArrayList(6);	
	
protected ArrayListPool(ObjectFactory factory, int initialCapacity)

		super.factory = factory;
		super.collection = this.arrayList = new ArrayList(initialCapacity);	
	
Methods Summary
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 collection), it returns non-null value. Subclasses can override this behaviour.

		collection.add(object);
		return this;
	
protected java.lang.Objectcheckout()
Notification when an object is given out from the pool (checout).

return
The object that has to be returned to the application. A null value must be returned if no object can be returned to the application. Since this class always returns the last node from the collection, it returns non-null value. Subclasses can override this behaviour.

		return arrayList.remove(arrayList.size() - 1);
	
protected java.lang.Objectcheckout(long param)
Notification when an object is given out from the pool (checout).

return
The object that has to be returned to the application. A null value must be returned if no object can be returned to the application. Since this class always returns the last node from the collection, it returns non-null value. Subclasses can override this behaviour.

		return arrayList.remove(arrayList.size() - 1);
	
protected java.lang.Objectcheckout(java.lang.Object param)
Notification when an object is given out from the pool (checout).

return
The object that has to be returned to the application. A null value must be returned if no object can be returned to the application. Since this class always returns the last node from the collection, it returns non-null value. Subclasses can override this behaviour.

		return arrayList.remove(arrayList.size() - 1);