I am working on a patch to allow listeners to be added to pools that
will receive notifications on various events. Does anyone object to
having this functionality included?
Here is the design -
I was thinking about adding support for a PoolListener interface for the
pool component. Object which implement this interface could be added to
any ObjectPool or KeyedObjectPool. The listener would be notified on
the following events:
- An object is borrowed from the pool
- An object is returned to the pool
- An new object is created and added to the pool
- An object is removed from the pool
addListener(PoolListener) would be defined in ObjectPool and
KeyedObjectPool. It would be implemented in BaseObjectPool and
BaseKeyedObjectPool. Also in the previous two Base* classes, protected
methods would be added to handle sending out the notifications to the
list of listeners.
public interface PoolListener
{
/**
* Executed immediatedly before an object is returned from the pool.
*
* @param obj The object being returned
* @throws Exception generic exception
*/
void onBorrow(Object obj) throws Exception;
/**
* Executed immediately after an object is returned to the pool.
*
* @param obj the object being returned
* @throws Exception generic exception
*/
void onReturn(Object obj) throws Exception;
/**
* Executed immediately after a new object is created but before it
* is added to the pool.
*
* @param obj the newly created object
* @throws Exception generic exception
*/
void onCreate(Object obj) throws Exception;
/**
* Executed when an object is removed from the pool.
*
* @param obj The object being removed.
* @throws Exception generic exception
*/
void onDestroy(Object obj) throws Exception;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]