Package generic.cache
Class CachingPool<T>
- java.lang.Object
-
- generic.cache.CachingPool<T>
-
- Type Parameters:
T
- the type of object to pool
public class CachingPool<T> extends java.lang.Object
A thread-safe pool class that knows how to create instances as needed. When clients are done with the pooled item they then callrelease(Object)
.
-
-
Constructor Summary
Constructors Constructor Description CachingPool(BasicFactory<T> factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
T
get()
Returns a cached or newCachingPool
void
release(T t)
void
setCleanupTimeout(long timeout)
Sets the time to wait for released items to be automatically disposed.
-
-
-
Constructor Detail
-
CachingPool
public CachingPool(BasicFactory<T> factory)
-
-
Method Detail
-
setCleanupTimeout
public void setCleanupTimeout(long timeout)
Sets the time to wait for released items to be automatically disposed. The default isTIMEOUT
.- Parameters:
timeout
- the new timeout.
-
get
public T get() throws java.lang.Exception
Returns a cached or newCachingPool
- Returns:
- a cached or new
CachingPool
- Throws:
java.lang.Exception
- if there is a problem instantiating a new instance
-
release
public void release(T t)
-
dispose
public void dispose()
-
-