I have completed the work on implementing pool listeners. I also corrected a few small defects. Unit tests have been modified to include testing using listeners as well. I am attaching a compressed tar file.
Here are the changes: StackObjectPool.borrowObject(): - Implement listener notification StackObjectPool.returnObject(): - Implement listener notification - restructured to improve readability (IMHO) - Fixed slight defect where _factory.destroyObject(obj) was called when _factory==null. This was probabley never noticed because the statement in a try/catch block with the exception being ignored. - _totActive can no longer be set to negative numbers as a result of returning objects to the pool that were never borrowed. StackObjectPool.invalidateObject(): - Implement listener notification StackObjectPool.clear(): - Implement listener notification - Switched from using Enum in a while loop to an Iterator in a for loop. --------------------------------------------------- StackKeyedObjectPool.borrowObject(): - Implement listener notification StackKeyedObjectPool.returnObject(): - Implement listener notification - restructured to improve readability (IMHO) - The counters for the total active and active per key can no longer be set to negative numbers as a result of returning objects to the pool that were never borrowed. StackKeyedObjectPool.invalidateObject(): - Implement listener notification StackKeyedObjectPool.clear(): - Switch from a while loop to a for loop for the iteration. StackObjectPool.destoryStack(): - Implement listener notification - Switched from using Enum in a while loop to an Iterator in a for loop. StackObjectPool - general: - Added a few javadocs - made the declaration of synchronized methods consistent. ---------------------------------------------------- SoftReferenceObjectPool(PoolableObjectFactory,int): - Implement listener notification SoftReferenceObjectPool.borrowObject(): - Implement listener notification SoftReferenceObjectPool.returnObject(): - Implement listener notification - restructured to improve readability (IMHO) - Fixed slight defect where _factory.destroyObject(obj) was called when _factory==null. This was probabley never noticed because the statement in a try/catch block with the exception being ignored. - _totActive can no longer be set to negative numbers as a result of returning objects to the pool that were never borrowed. SoftReferenceObjectPool.invalidateObject(): - Implement listener notification SoftReferenceObjectPool.clear(): - Implement listener notification - Switched from using Enum in a while loop to an Iterator in a for loop. ------------------------------------------------------ GenericObjectPool.borrowObject(): - Implement listener notification - object creation is now done in one place. - If validation fails (testOnBorrow=true), the object will not be passivated. It will just be destroyed instead. According to the factory docs, passivation only occurs when being returned to the pool. Also - the call to destroy() object was not surrounded in a try/catch block. If an exception was thrown the entire call to borrowObject() would have failed. GenericObjectPool.returnObject(): - Implement listener notification - restructured to improve readability (IMHO) GenericObjectPool.invalidateObject(): - Implement listener notification GenericObjectPool.clear(): - Implement listener notification - Switched from using Enum in a while loop to an Iterator in a for loop. GenericObjectPool.evict(): - Implement listener notification - restructured the code so that code to remove the object from the pool is not duplicated. - If activation fails, the object will not be passivated. It will just be destroyed. - There were two places during the validation of the object where on failure, the object would be destroyed. The call to destoryObject() was not in a try/catch block. This has been corrected. ------------------------------------------------------------ GenericKeyedObjectPool.borrowObject(): - Implement listener notification - object creation is now done in one place. - If validation fails (testOnBorrow=true), the object will not be passivated. It will just be destroyed instead. According to the factory docs, passivation only occurs when being returned to the pool. Also - the call to destroy() object was not surrounded in a try/catch block. If an exception was thrown the entire call to borrowObject() would have failed. GenericKeyedObjectPool.clear(): - Implement listener notification - Switch from a while loop to a for loop for the iteration. GenericKeyedObjectPool.clear(key): - Implement listener notification - Switch from a while loop to a for loop for the iteration. GenericKeyedObjectPool.returnObject(): - Implement listener notification - restructured to improve readability (IMHO) GenericKeyedObjectPool.invalidateObject(): - Implement listener notification GenericKeyedObjectPool.evict(): - Implement listener notification - restructured the code so that code to remove the object from the pool is not duplicated. - If activation fails, the object will not be passivated. It will just be destroyed. - There were two places during the validation of the object where on failure, the object would be destroyed. The call to destoryObject() was not in a try/catch block. This has been corrected. - If activation failed, the object was being dropped from the pool but no check was being done to remove the pool if that was the last object. This has been corrected. GenericKeyedObjectPool - general: - made the declaration of synchronized methods consistent. ----------------------------------------------------------------- BaseKeyedObjectPool: - Added listener manager - added notify*() methods - added addListener() ----------------------------------------------------------------- BaseObjectPool: - Added listener manager - added notify*() methods - added addListener() ----------------------------------------------------------------- KeyedObjectPool: - Added addListener() declaration ----------------------------------------------------------------- ObjectPool: - Added addListener() declaration ----------------------------------------------------------------- New class: PoolAdapter Default implementation of PoolListener ----------------------------------------------------------------- New class: PoolEvent Wrapper for the object which the event is about. ----------------------------------------------------------------- New class: PoolListener Interface for listener classes ----------------------------------------------------------------- New class: PoolListenerManager Manages the listeners for the pools.
patch.tar.gz
Description: patch.tar.gz
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]