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

Pool

public interface Pool
Pool defines the methods that can be used by the application to access pooled objects. The basic assumption is that all objects in the pool are identical (homogeneous). This interface defines methods for a) getting an object from the pool, b) returning an object back to the pool and, c) destroying (instead of reusing) an object. In addition to these methods, the Pool has methods for adding and removing PoolEventListeners. There are six overloaded methods for getting objects from a pool.

Fields Summary
Constructors Summary
Methods Summary
public booleanaddPoolListener(PoolListener listener)
Add a PoolListener

param
listener The pool listener

public voiddestroyObject(java.lang.Object obj)
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.

public java.lang.ObjectgetObject(boolean toWait, java.lang.Object param)
Get an object.

param
toWait - true indicates that the calling thread agrees to wait indefinitely false if not.
param
param - some value that might be used while creating the object
return
an Object or null if an object could not be returned in 'waitForMillis' millisecond.
exception
Throws InterruptedException if the calling thread was interrupted during the call.
exception
Throws PoolException if the underlying pool implementation throws specific exception (for example, the pool is closed etc.)

public java.lang.ObjectgetObject(long waitForMillis, java.lang.Object param)
Get an object from the pool within the specified time.

param
The amount of time the calling thread agrees to wait.
param
Some value that might be used while creating the object
return
an Object or null if an object could not be returned in 'waitForMillis' millisecond.
exception
Throws InterruptedException if the calling thread was interrupted during the call.
exception
Throws PoolException if the underlying pool implementation throws specific exception (for example, the pool is closed etc.)

public booleanremovePoolListener(PoolListener listener)
Add a PoolListener

param
listener The pool listener

public voidreturnObject(java.lang.Object obj)
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).