Class ConnectionPool


  • public class ConnectionPool
    extends Object
    Implements a pool of connection resulting of a unique ConnectionFactory object. Connections are sorted by identity.
    • Field Detail

      • maxFreeConnections

        int maxFreeConnections
        Maximum number of free connections for an identity in the pool
    • Constructor Detail

      • ConnectionPool

        public ConnectionPool​(int maxFreeConnections)
        Creates a new pool of connections.
        Parameters:
        maxFreeConnections - the maximum number of free connections for an identity in the pool.
    • Method Detail

      • getMaxFreeConnections

        public int getMaxFreeConnections()
        Gets the maximum number of free connections for an identity in the pool.
        Returns:
        the maxFreeConnections
      • setMaxFreeConnections

        public void setMaxFreeConnections​(int maxFreeConnections)
        Returns the maximum number of free connections for an identity in the pool.
        Parameters:
        maxFreeConnections - the maxFreeConnections to set
      • alloc

        public PooledConnection alloc​(String name,
                                      String password)
        Allocates a Connection for the specified identity.
        Parameters:
        name - name of user.
        password - password of user.
        Returns:
        A connection for the specified identity.
      • free

        public void free​(PooledConnection cnx)
                  throws JMSException
        Frees the specified connection, depending of the number of free connections in the pool this connection is closed or inserted in the pool.
        Parameters:
        cnx - The connection to free.
        Throws:
        JMSException - an error occurs during the cleanup of the connection.