Methods Summary |
---|
public synchronized oracle.toplink.essentials.internal.databaseaccess.Accessor | acquireConnection()INTERNAL:
Wait until a connection is avaiable and allocate the connection for the client.
while (!hasConnectionAvailable()) {
if (getTotalNumberOfConnections() < getMaxNumberOfConnections()) {
Accessor connection = buildConnection();
getConnectionsUsed().addElement(connection);
return connection;
}
try {
wait();// Notify is called when connections are released.
} catch (InterruptedException exception) {
throw ConcurrencyException.waitFailureOnClientSession(exception);
}
}
Accessor connection = (Accessor)getConnectionsAvailable().firstElement();
getConnectionsAvailable().removeElement(connection);
getConnectionsUsed().addElement(connection);
getOwner().updateProfile(getName(), new Integer(getConnectionsUsed().size()));
return connection;
|
protected oracle.toplink.essentials.internal.databaseaccess.Accessor | buildConnection()INTERNAL:
Create a new connection, accessors are used as connections.
Login localLogin = (Login)getLogin().clone();
Accessor connection = localLogin.buildAccessor();
connection.connect(localLogin, getOwner());
return connection;
|
public java.util.Vector | getConnectionsAvailable()INTERNAL:
returns the connections currently available for use in the pool
return connectionsAvailable;
|
protected java.util.Vector | getConnectionsUsed()Return a list of the connections that are being used.
return connectionsUsed;
|
public oracle.toplink.essentials.sessions.Login | getLogin()PUBLIC:
Return the login used to create connections.
return login;
|
public int | getMaxNumberOfConnections()PUBLIC:
Return the maximum number of connections allowed.
When the max is reached clients must wait for a connection to become available.
return maxNumberOfConnections;
|
public int | getMinNumberOfConnections()PUBLIC:
Return the minimum number of connections.
These connection will be create on startup.
return minNumberOfConnections;
|
public java.lang.String | getName()PUBLIC:
Return the name of this pool.
Pools are identified by name to allow multiple connection pools.
return name;
|
protected oracle.toplink.essentials.threetier.ServerSession | getOwner()Return the ServerSession that is the owner of this connection pool.
return owner;
|
public int | getTotalNumberOfConnections()INTERNAL:
Return the total number of connections currently in use.
return getConnectionsUsed().size() + getConnectionsAvailable().size();
|
public boolean | hasConnectionAvailable()INTERNAL:
Wait until a connection is avaiable and allocate the connection for the client.
return !getConnectionsAvailable().isEmpty();
|
public boolean | isConnected()INTERNAL:
Return if this pool has been connected to the database.
return isConnected;
|
public boolean | isThereConflictBetweenLoginAndType()INTERNAL:
Checks for a conflict between pool's type and pool's login
return getLogin().shouldUseExternalConnectionPooling();
|
public synchronized void | releaseConnection(oracle.toplink.essentials.internal.databaseaccess.Accessor connection)INTERNAL:
Add the connection as single that a new connection is available.
getConnectionsUsed().removeElement(connection);
if (getTotalNumberOfConnections() < getMinNumberOfConnections()) {
getConnectionsAvailable().addElement(connection);
} else {
connection.disconnect(getOwner());
}
notify();
|
public void | resetConnections()INTERNAL:
Reset the connections on shutDown and when the pool is started.
this.connectionsUsed = new Vector();
this.connectionsAvailable = new Vector();
|
protected void | setConnectionsAvailable(java.util.Vector connectionsAvailable)INTERNAL:
Set this list of connections available
this.connectionsAvailable = connectionsAvailable;
|
protected void | setConnectionsUsed(java.util.Vector connectionsUsed)INTERNAL:
Set the list of connections being used.
this.connectionsUsed = connectionsUsed;
|
public void | setIsConnected(boolean isConnected)INTERNAL:
Set if this pool has been connected to the database.
this.isConnected = isConnected;
|
public void | setLogin(oracle.toplink.essentials.sessions.Login login)PUBLIC:
Set the login used to create connections.
this.login = login;
|
public void | setMaxNumberOfConnections(int maxNumberOfConnections)PUBLIC:
Set the maximum number of connections allowed.
When the max is reached clients must wait for a connection to become available.
this.maxNumberOfConnections = maxNumberOfConnections;
|
public void | setMinNumberOfConnections(int minNumberOfConnections)PUBLIC:
Set the minimum number of connections.
These connection will be create on startup.
this.minNumberOfConnections = minNumberOfConnections;
|
public void | setName(java.lang.String name)PUBLIC:
Set the name of this pool.
Pools are identified by name to allow multiple connection pools.
this.name = name;
|
protected void | setOwner(oracle.toplink.essentials.threetier.ServerSession owner)Set the ServerSession that owns this connection pool
this.owner = owner;
|
public synchronized void | shutDown()INTERNAL:
Disconnect all connections.
setIsConnected(false);
for (Enumeration avaiableEnum = getConnectionsAvailable().elements();
avaiableEnum.hasMoreElements();) {
try {
((Accessor)avaiableEnum.nextElement()).disconnect(getOwner());
} catch (DatabaseException exception) {
// Ignore.
}
}
for (Enumeration usedEnum = getConnectionsUsed().elements(); usedEnum.hasMoreElements();) {
try {
((Accessor)usedEnum.nextElement()).disconnect(getOwner());
} catch (DatabaseException exception) {
// Ignore.
}
}
resetConnections();
|
public synchronized void | startUp()INTERNAL:
Allocate the minimum connections.
for (int index = getMinNumberOfConnections(); index > 0; index--) {
getConnectionsAvailable().addElement(buildConnection());
}
setIsConnected(true);
|
public java.lang.String | toString()INTERNAL:
return a string representation of this connection pool
Object[] args = { new Integer(getMinNumberOfConnections()), new Integer(getMaxNumberOfConnections()) };
return Helper.getShortClassName(getClass()) + ToStringLocalization.buildMessage("min_max", args);
|