org.eclipse.persistence.sessions.server
Class ConnectionPool

java.lang.Object
  extended by org.eclipse.persistence.sessions.server.ConnectionPool
Direct Known Subclasses:
ExternalConnectionPool, ReadConnectionPool

public class ConnectionPool
extends Object

Purpose: Used to specify how connection should be pooled in a server session.

See Also:
ServerSession

Field Summary
static int INITIAL_CONNECTIONS
           
static int MAX_CONNECTIONS
           
static int MIN_CONNECTIONS
           
static int WAIT_TIMEOUT
           
 
Constructor Summary
ConnectionPool()
          PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.
ConnectionPool(String name, Login login, int initialNumberOfConnections, int minNumberOfConnections, int maxNumberOfConnections, ServerSession owner)
          PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.
ConnectionPool(String name, Login login, int minNumberOfConnections, int maxNumberOfConnections, ServerSession owner)
          PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.
ConnectionPool(String name, Login login, ServerSession owner)
          PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.
 
Method Summary
 org.eclipse.persistence.internal.databaseaccess.Accessor acquireConnection()
          INTERNAL: Wait until a connection is available and allocate the connection for the client.
 List<org.eclipse.persistence.internal.databaseaccess.Accessor> getConnectionsAvailable()
          INTERNAL: returns the connections currently available for use in the pool
 int getInitialNumberOfConnections()
          PUBLIC: Return the initial number of connections allowed.
 Login getLogin()
          PUBLIC: Return the login used to create connections.
 int getMaxNumberOfConnections()
          PUBLIC: Return the maximum number of connections allowed.
 int getMinNumberOfConnections()
          PUBLIC: Return the minimum number of connections.
 String getName()
          PUBLIC: Return the name of this pool.
 int getTotalNumberOfConnections()
          INTERNAL: Return the total number of connections currently in use.
 int getWaitTimeout()
          PUBLIC: Return the time in milliseconds to wait for a available connection.
 boolean hasConnectionAvailable()
          INTERNAL: Wait until a connection is avaiable and allocate the connection for the client.
 boolean isConnected()
          INTERNAL: Return if this pool has been connected to the database.
 boolean isThereConflictBetweenLoginAndType()
          INTERNAL: Checks for a conflict between pool's type and pool's login
 void releaseConnection(org.eclipse.persistence.internal.databaseaccess.Accessor connection)
          INTERNAL: Add the connection as single that a new connection is available.
 void resetConnections()
          INTERNAL: Reset the connections on shutDown and when the pool is started.
 void setCheckConnections()
          INTERNAL: This method is called to indicate that all available connections should be checked.
 void setInitialNumberOfConnections(int initialNumberOfConnections)
          PUBLIC: Set the initial number of connections allowed.
 void setIsConnected(boolean isConnected)
          INTERNAL: Set if this pool has been connected to the database.
 void setLogin(Login login)
          PUBLIC: Set the login used to create connections.
 void setMaxNumberOfConnections(int maxNumberOfConnections)
          PUBLIC: Set the maximum number of connections allowed.
 void setMinNumberOfConnections(int minNumberOfConnections)
          PUBLIC: Set the minimum number of connections.
 void setName(String name)
          PUBLIC: Set the name of this pool.
 void setWaitTimeout(int waitTimeout)
          PUBLIC: Set the time in milliseconds to wait for an available connection.
 void shutDown()
          INTERNAL: Disconnect all connections.
 void startUp()
          INTERNAL: Allocate the minimum connections.
 String toString()
          INTERNAL: return a string representation of this connection pool
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_CONNECTIONS

public static final int MAX_CONNECTIONS
See Also:
Constant Field Values

MIN_CONNECTIONS

public static final int MIN_CONNECTIONS
See Also:
Constant Field Values

INITIAL_CONNECTIONS

public static final int INITIAL_CONNECTIONS
See Also:
Constant Field Values

WAIT_TIMEOUT

public static final int WAIT_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

ConnectionPool

public ConnectionPool()
PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.


ConnectionPool

public ConnectionPool(String name,
                      Login login,
                      ServerSession owner)
PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.


ConnectionPool

public ConnectionPool(String name,
                      Login login,
                      int minNumberOfConnections,
                      int maxNumberOfConnections,
                      ServerSession owner)
PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.


ConnectionPool

public ConnectionPool(String name,
                      Login login,
                      int initialNumberOfConnections,
                      int minNumberOfConnections,
                      int maxNumberOfConnections,
                      ServerSession owner)
PUBLIC: A connection pool is used to specify how connection should be pooled in a server session.

Method Detail

acquireConnection

public org.eclipse.persistence.internal.databaseaccess.Accessor acquireConnection()
                                                                           throws ConcurrencyException
INTERNAL: Wait until a connection is available and allocate the connection for the client.

Throws:
ConcurrencyException

getConnectionsAvailable

public List<org.eclipse.persistence.internal.databaseaccess.Accessor> getConnectionsAvailable()
INTERNAL: returns the connections currently available for use in the pool


getLogin

public Login getLogin()
PUBLIC: Return the login used to create connections.


getMaxNumberOfConnections

public int getMaxNumberOfConnections()
PUBLIC: Return the maximum number of connections allowed. If all connections are in use, a new connection will be created until the maximum size is reach. Only the minimum number of connections will be pooled, if the pool is between the min and max size the connection will be disconnected when returned to the pool. Typically it is desirable to have the min and max connections the same to avoid connects and disconnects. When the max is reached clients must wait for a connection to become available.


getMinNumberOfConnections

public int getMinNumberOfConnections()
PUBLIC: Return the minimum number of connections. If all connections are in use, a new connection will be created until the maximum size is reach. Only the minimum number of connections will be pooled, if the pool is between the min and max size the connection will be disconnected when returned to the pool. Typically it is desirable to have the min and max connections the same to avoid connects and disconnects.


getName

public String getName()
PUBLIC: Return the name of this pool. Pools are identified by name to allow multiple connection pools.


getTotalNumberOfConnections

public int getTotalNumberOfConnections()
INTERNAL: Return the total number of connections currently in use.


hasConnectionAvailable

public boolean hasConnectionAvailable()
INTERNAL: Wait until a connection is avaiable and allocate the connection for the client.


isConnected

public boolean isConnected()
INTERNAL: Return if this pool has been connected to the database.


isThereConflictBetweenLoginAndType

public boolean isThereConflictBetweenLoginAndType()
INTERNAL: Checks for a conflict between pool's type and pool's login


releaseConnection

public void releaseConnection(org.eclipse.persistence.internal.databaseaccess.Accessor connection)
                       throws DatabaseException
INTERNAL: Add the connection as single that a new connection is available.

Throws:
DatabaseException

resetConnections

public void resetConnections()
INTERNAL: Reset the connections on shutDown and when the pool is started.


setCheckConnections

public void setCheckConnections()
INTERNAL: This method is called to indicate that all available connections should be checked.


setIsConnected

public void setIsConnected(boolean isConnected)
INTERNAL: Set if this pool has been connected to the database.


setLogin

public void setLogin(Login login)
PUBLIC: Set the login used to create connections.


getInitialNumberOfConnections

public int getInitialNumberOfConnections()
PUBLIC: Return the initial number of connections allowed. This is the number of connections connected on startup.


setInitialNumberOfConnections

public void setInitialNumberOfConnections(int initialNumberOfConnections)
PUBLIC: Set the initial number of connections allowed. This is the number of connections connected on startup. The default is 1.


setMaxNumberOfConnections

public void setMaxNumberOfConnections(int maxNumberOfConnections)
PUBLIC: Set the maximum number of connections allowed. If all connections are in use, a new connection will be created until the maximum size is reach. Only the minimum number of connections will be pooled, if the pool is between the min and max size the connection will be disconnected when returned to the pool. Typically it is desirable to have the min and max connections the same to avoid connects and disconnects. When the max is reached clients must wait for a connection to become available. The default is 32.


setMinNumberOfConnections

public void setMinNumberOfConnections(int minNumberOfConnections)
PUBLIC: Set the minimum number of connections. If all connections are in use, a new connection will be created until the maximum size is reach. Only the minimum number of connections will be pooled, if the pool is between the min and max size the connection will be disconnected when returned to the pool. Typically it is desirable to have the min and max connections the same to avoid connects and disconnects. The default is 32.


setName

public void setName(String name)
PUBLIC: Set the name of this pool. Pools are identified by name to allow multiple connection pools.


shutDown

public void shutDown()
INTERNAL: Disconnect all connections.


startUp

public void startUp()
INTERNAL: Allocate the minimum connections.


toString

public String toString()
INTERNAL: return a string representation of this connection pool

Overrides:
toString in class Object

getWaitTimeout

public int getWaitTimeout()
PUBLIC: Return the time in milliseconds to wait for a available connection. If the wait time is exceeded and exception will occur. The default is 180000 or 3 minutes. A value of 0 means wait forever.


setWaitTimeout

public void setWaitTimeout(int waitTimeout)
PUBLIC: Set the time in milliseconds to wait for an available connection. If the wait time is exceeded an exception will occur. The default is 180000 or 3 minutes. A value of 0 means wait forever.