Class SimplePool<T>
java.lang.Object
org.springframework.integration.util.SimplePool<T>
- Type Parameters:
- T- pool element type.
- All Implemented Interfaces:
- Pool<T>
Implementation of 
Pool supporting dynamic resizing and a variable
 timeout when attempting to obtain an item from the pool. Pool grows on
 demand up to the limit.- Since:
- 2.2
- Author:
- Gary Russell, Sergey Bogatyrev, Artem Bilan, Christian Tzolov
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceUser of the pool provide an implementation of this interface; called during various pool operations.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionSimplePool(int poolSize, SimplePool.PoolItemCallback<T> callback) Create a SimplePool with a specific limit.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Close the pool; returned items will be destroyed.intReturn the number of allocated items that are currently checked out of the pool.intReturn the current count of allocated items (in use and idle).intReturn the number of items that have been allocated but are not currently in use.getItem()Obtain an item from the pool; waits up to waitTime milliseconds (default infinity).intReturn the current size of the pool; may be greater than the target pool size if it was recently reduced and too many items were in use to allow the new size to be set.voidreleaseItem(T item) Return an item to the pool.voidRemove all idle items from the pool.voidsetPoolSize(int poolSize) Adjust the current pool size.voidsetWaitTimeout(long waitTimeout) Adjust the wait timeout - the time for which getItem() will wait if no idle entries are available.
- 
Field Details- 
logger
 
- 
- 
Constructor Details- 
SimplePoolCreate a SimplePool with a specific limit.- Parameters:
- poolSize- The maximum number of items the pool supports.
- callback- A- SimplePool.PoolItemCallbackimplementation called during various pool operations.
 
 
- 
- 
Method Details- 
setPoolSizepublic void setPoolSize(int poolSize) Adjust the current pool size. When reducing the pool size, attempts to remove the delta from the pool. If there are not enough unused items in the pool, the actual pool size will decrease to the specified size as in-use items are returned.- Parameters:
- poolSize- The desired target pool size.
 
- 
getPoolSizepublic int getPoolSize()Return the current size of the pool; may be greater than the target pool size if it was recently reduced and too many items were in use to allow the new size to be set.- Specified by:
- getPoolSizein interface- Pool<T>
- Returns:
- the size.
 
- 
getIdleCountpublic int getIdleCount()Description copied from interface:PoolReturn the number of items that have been allocated but are not currently in use.- Specified by:
- getIdleCountin interface- Pool<T>
- Returns:
- The number of items.
 
- 
getActiveCountpublic int getActiveCount()Description copied from interface:PoolReturn the number of allocated items that are currently checked out of the pool.- Specified by:
- getActiveCountin interface- Pool<T>
- Returns:
- The number of items.
 
- 
getAllocatedCountpublic int getAllocatedCount()Description copied from interface:PoolReturn the current count of allocated items (in use and idle). May be less than the pool size, and reflects the high watermark of pool usage.- Specified by:
- getAllocatedCountin interface- Pool<T>
- Returns:
- the number of items.
 
- 
setWaitTimeoutpublic void setWaitTimeout(long waitTimeout) Adjust the wait timeout - the time for which getItem() will wait if no idle entries are available.
 Default: infinity.- Parameters:
- waitTimeout- The wait timeout in milliseconds.
 
- 
getItemObtain an item from the pool; waits up to waitTime milliseconds (default infinity).- Specified by:
- getItemin interface- Pool<T>
- Returns:
- the item.
- Throws:
- PoolItemNotAvailableException- if no items become available in time.
 
- 
releaseItemReturn an item to the pool.- Specified by:
- releaseItemin interface- Pool<T>
- Parameters:
- item- the item.
 
- 
removeAllIdleItemspublic void removeAllIdleItems()Description copied from interface:PoolRemove all idle items from the pool.- Specified by:
- removeAllIdleItemsin interface- Pool<T>
 
- 
closepublic void close()Description copied from interface:PoolClose the pool; returned items will be destroyed.
 
-