anvil.database
Class ConnectionAccessQueue

java.lang.Object
  |
  +--anvil.database.ConnectionAccessQueue
All Implemented Interfaces:
ConnectionObserver

public class ConnectionAccessQueue
extends java.lang.Object
implements ConnectionObserver

ConnectionAccessQueue is used by ConnectionManager when acquiring connections from the pool. Queue handles the situations when connections are not immediately available by letting threads to wait for certain (limited) amount of time. Queue implements ConnectionObserver through which the notifications of available are made by the pool.

Version:
$Revision: 1.8 $
Author:
Jani Lehtimäki
See Also:
ConnectionManager, ConnectionManager.acquire(String), ConnectionPool, ConnectionPool.acquire(int), ConnectionObserver, PooledConnection

Constructor Summary
ConnectionAccessQueue(ConnectionPool pool)
          Constructs the queue.
 
Method Summary
 PooledConnection acquire(int timeout)
          Acquire the connection from the pool, waiting for only specified amount of time.
 void connectionsAvailable()
          Notification from connection observer interface.
 ConnectionPool getPool()
          Gets the connection pool of this queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionAccessQueue

public ConnectionAccessQueue(ConnectionPool pool)
Constructs the queue.

Parameters:
pool - Connection pool
Method Detail

getPool

public ConnectionPool getPool()
Gets the connection pool of this queue.

Returns:
Connection pool

acquire

public PooledConnection acquire(int timeout)
                         throws CannotReturnPooledConnectionException
Acquire the connection from the pool, waiting for only specified amount of time.

Parameters:
timeout - Timeout override (if > 0)
Returns:
Connection
Throws:
CannotReturnPooledConnectionException - If acquire timed out

connectionsAvailable

public void connectionsAvailable()
Notification from connection observer interface. Interrupt the first thread waiting in queue.

Specified by:
connectionsAvailable in interface ConnectionObserver