## org.firebirdsql.pool
Class AbstractConnectionPool

    java.lang.Object
      org.firebirdsql.pool.AbstractConnectionPool

All Implemented Interfaces:
  PooledObjectListener

Direct Known Subclasses:
  BasicAbstractConnectionPool

    public abstract class AbstractConnectionPool

extends Object
implements PooledObjectListener

Abstract class for creating connection pools. Subclasses must implement factory method to produce physical connections to the database (method `getConnectionManager()` and few utility methods (`getLogger()` and `getPoolName()`).

Author:
  Roman Rokytskyy

Nested Class Summary
`protected static class` `AbstractConnectionPool.UserPasswordPair` Structure class to store user name and password.

Constructor Summary
`protected` `AbstractConnectionPool()` Create instance of this class.

Method Summary
`protected void` `finalize()` Shutdown pool if object is garbage collected.
`abstract ConnectionPoolConfiguration` `getConfiguration()` Get configuration of this data source.
`protected abstract PooledConnectionManager` `getConnectionManager()` Get instance of `PooledConnectionManager` responsible for instantiating pooled connections.
`abstract int` `getFreeSize()` Get number of free connections in this pool.
`protected abstract Logger` `getLogger()` Get logger for this instance.
`protected PooledObject` `getPooledConnection(org.firebirdsql.pool.PooledConnectionQueue queue)` Get pooled connection.
`protected abstract String` `getPoolName()` Get name of the pool.
`org.firebirdsql.pool.PooledConnectionQueue` `getQueue(Object key)` Get queue for the specified user name and password.
`abstract int` `getTotalSize()` Get total size of physical connections opened to the database.
`abstract int` `getWorkingSize()` Get number of connections that are in use.
`protected void` `physicalConnectionDeallocated(PooledObjectEvent event)` Notify about the deallocation of the physical connection (for example, when connection is removed by the idle remover thread).
`void` `pooledObjectReleased(PooledObjectEvent event)` Notify about new available connection.
`void` `restart()` Restart this JDBC pool.
`void` `shutdown()` Shutdown this JDBC pool.

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractConnectionPool

    protected AbstractConnectionPool()

  Create instance of this class.

Method Detail

### getLogger

    protected abstract Logger getLogger()

  Get logger for this instance. By default all log messages belong to this class. Subclasses can override this behavior.

  Returns:
    instance of `Logger`.

### finalize

    protected void finalize()
                     throws Throwable

  Shutdown pool if object is garbage collected.

  Overrides:
    `finalize` in class `Object`
  Throws:
    `Throwable` - if something bad happened.

### restart

    public void restart()

  Restart this JDBC pool. This method restarts all JDBC connections.

### shutdown

    public void shutdown()

  Shutdown this JDBC pool. This method closes all JDBC connections and marks pool as shut down.

### getQueue

    public org.firebirdsql.pool.PooledConnectionQueue getQueue(Object key)
                                                        throws SQLException

  Get queue for the specified user name and password.

  Parameters:
    `key` - key identifying pool.
  Returns:
    instance of `PooledConnectionQueue`.
  Throws:
    `SQLException` - if something went wrong.

### getPooledConnection

    protected PooledObject getPooledConnection(org.firebirdsql.pool.PooledConnectionQueue queue)
                                        throws SQLException

  Get pooled connection. This method will block until there will be free connection to return.

  Parameters:
    `queue` - instance of `PooledConnectionQueue` where connection will be obtained.
  Returns:
    instance of `PooledObject`.
  Throws:
    `SQLException` - if pooled connection cannot be obtained.

### pooledObjectReleased

    public void pooledObjectReleased(PooledObjectEvent event)

  Notify about new available connection. This method is called by `PooledConnection` when its wrapped connection being closed.

  Specified by:
    `pooledObjectReleased` in interface `PooledObjectListener`
  Parameters:
    `event` - instance of `PooledObjectEvent` containing information about closed connection.

### physicalConnectionDeallocated

    protected void physicalConnectionDeallocated(PooledObjectEvent event)

  Notify about the deallocation of the physical connection (for example, when connection is removed by the idle remover thread).

  Parameters:
    `event` - instance of `PooledObjectEvent`.

### getConfiguration

    public abstract ConnectionPoolConfiguration getConfiguration()

  Get configuration of this data source.

  Returns:
    instance of `ConnectionPoolConfiguration` describing this data source.

### getConnectionManager

    protected abstract PooledConnectionManager getConnectionManager()
                                                             throws SQLException

  Get instance of `PooledConnectionManager` responsible for instantiating pooled connections.

  Returns:
    instance of `PooledConnectionManager`
  Throws:
    `SQLException` - if connection manager cannot be obtained.

### getPoolName

    protected abstract String getPoolName()

  Get name of the pool. This name will be displayed in log when pool is started.

  Returns:
    name of the connection queue.

### getFreeSize

    public abstract int getFreeSize()
                             throws SQLException

  Get number of free connections in this pool. This method returns the number of free open connections to the specified database. It might return 0, but this does not mean that next request will block. This will happen only if `getMaxSize() != 0 && getMaxSize() == getWorkingSize()`, meaning that we have allocated maximum number of connections and all of them are in use.

  Returns:
    number of free connections left.
  Throws:
    `SQLException`

### getTotalSize

    public abstract int getTotalSize()
                              throws SQLException

  Get total size of physical connections opened to the database.

  Returns:
    total number of opened connections to the database.
  Throws:
    `SQLException`

### getWorkingSize

    public abstract int getWorkingSize()
                                throws SQLException

  Get number of connections that are in use.

  Returns:
    number of working connections.
  Throws:
    `SQLException`

Copyright © 2001-2010. All Rights Reserved.