Class AbstractPool<T extends PooledObject<?>>

java.lang.Object
io.micronaut.jms.pool.AbstractPool<T>
Type Parameters:
T - the PooledObject type
Direct Known Subclasses:
JMSConnectionPool, MessageProducerPool, SessionPool

public abstract class AbstractPool<T extends PooledObject<?>> extends Object
Base class for object pool implementations.
Since:
1.0.0
Author:
Elliott Pope
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
     
    protected final int
     
    protected final List<T>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractPool(int initialSize, int maxSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract T
    create(Object... args)
    Create an object for the pool.
    void
    release(T pooledObject)
    Release the provided object and return it to the pool.
    request(Object... args)
    Requests an object <T> from the pool.
    protected abstract void
    reset(T pooledObject)
    Reset the provided object so it can be returned to the pool for reuse.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • pool

      protected final List<T extends PooledObject<?>> pool
    • initialSize

      protected final int initialSize
    • maxSize

      protected final int maxSize
  • Constructor Details

    • AbstractPool

      protected AbstractPool(int initialSize, int maxSize)
  • Method Details

    • request

      public T request(Object... args)
      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

      public void release(T pooledObject)
      Release the provided object and return it to the pool.
      Parameters:
      pooledObject - the object to return to the pool
    • create

      protected abstract T create(Object... args)
      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

      protected abstract void reset(T pooledObject)
      Reset the provided object so it can be returned to the pool for reuse.
      Parameters:
      pooledObject - the object