Package io.micronaut.jms.pool
Class AbstractPool<T extends PooledObject<?>>
java.lang.Object
io.micronaut.jms.pool.AbstractPool<T>
- Type Parameters:
T
- thePooledObject
type
- Direct Known Subclasses:
JMSConnectionPool
,MessageProducerPool
,SessionPool
Base class for object pool implementations.
- Since:
- 1.0.0
- Author:
- Elliott Pope
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
Create an object for the pool.void
Release the provided object and return it to the pool.Requests an object<T>
from the pool.protected abstract void
Reset 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
PooledObject
from 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
-
create
Create an object for the pool.- Parameters:
args
- the arguments to be provided to the create method.- Returns:
- a new object of type
<T>
for the pool.
-
reset
Reset the provided object so it can be returned to the pool for reuse.- Parameters:
pooledObject
- the object
-