Class AbstractPool<T extends PooledObject<?>>
java.lang.Object
io.micronaut.jms.pool.AbstractPool<T>
- Type Parameters:
T- thePooledObjecttype
- Direct Known Subclasses:
JMSConnectionPool, MessageProducerPool, SessionPool
Base class for object pool implementations.
- Since:
- 1.0.0
- Author:
- Elliott Pope
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TCreate an object for the pool.protected voidReleases the resources of an invalid object, which leaves the pool.protected booleanvoidRelease the provided object and return it to the pool.Requests an object<T>from the pool.protected abstract voidReset the provided object so it can be returned to the pool for reuse.
-
Field Details
-
pool
-
initialSize
protected final int initialSize -
maxSize
protected final int maxSize
-
-
Constructor Details
-
AbstractPool
protected AbstractPool(int initialSize, int maxSize)
-
-
Method Details
-
request
Requests an object<T>from the pool. Adds a new instance to the pool if the pool is empty.- Parameters:
args- the arguments to pass to the create method, or to help select an object from the pool.- Returns:
- a
PooledObjectfrom the pool. - Throws:
IllegalStateException- if the number of active instances exceeds the configured size
-
release
Release the provided object and return it to the pool.- Parameters:
pooledObject- the object to return to the pool
-
isValid
- Parameters:
pooledObject- a pooled object- Returns:
- whether the object can still be used. Invalid objects are discarded instead of being handed out or returned to the pool.
- Since:
- 5.2.0
-
discard
Releases the resources of an invalid object, which leaves the pool.- Parameters:
pooledObject- the invalid object- Since:
- 5.2.0
-
create
-
reset
Reset the provided object so it can be returned to the pool for reuse.- Parameters:
pooledObject- the object
-