FileDocCategorySizeDatePackage
ReadConnectionPool.javaAPI DocGlassfish v2 API4768Tue May 22 16:54:54 BST 2007oracle.toplink.essentials.threetier

ReadConnectionPool

public class ReadConnectionPool extends ConnectionPool

Purpose:The read connection pool is used for read access through the server session. Any of the connection pools can be used for the read pool however this is the default. This pool allows for concurrent reads against the same JDBC connection and requires that the JDBC connection support concurrent read access.

Fields Summary
Constructors Summary
public ReadConnectionPool()
PUBLIC: Build a new read connection pool.

        super();
    
public ReadConnectionPool(String name, Login login, int minNumberOfConnections, int maxNumberOfConnections, ServerSession owner)
PUBLIC: Build a new read connection pool.

        super(name, login, minNumberOfConnections, maxNumberOfConnections, owner);
    
Methods Summary
public synchronized oracle.toplink.essentials.internal.databaseaccess.AccessoracquireConnection()
INTERNAL: Wait until a connection is avaiable and allocate the connection for the client.

        Accessor leastBusyConnection = null;

        // Search for an unused connection, also find the least busy incase all are used.
        for (Enumeration connectionsEnum = getConnectionsAvailable().elements();
                 connectionsEnum.hasMoreElements();) {
            Accessor connection = (Accessor)connectionsEnum.nextElement();
            if (connection.getCallCount() == 0) {
                connection.incrementCallCount(getOwner());
                return connection;
            }
            if ((leastBusyConnection == null) || (leastBusyConnection.getCallCount() > connection.getCallCount())) {
                leastBusyConnection = connection;
            }
        }

        // If still not at max, add a new connection.
        if (getTotalNumberOfConnections() < getMaxNumberOfConnections()) {
            Accessor connection = buildConnection();
            getConnectionsAvailable().addElement(connection);
            connection.incrementCallCount(getOwner());
            return connection;
        }

        // Use the least busy connection.
        leastBusyConnection.incrementCallCount(getOwner());
        return leastBusyConnection;
    
public booleanhasConnectionAvailable()
INTERNAL: Concurrent reads are supported.

        return true;
    
public synchronized voidreleaseConnection(oracle.toplink.essentials.internal.databaseaccess.Accessor connection)
INTERNAL: Because connections are not exclusive nothing is required.

        connection.decrementCallCount();