|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.jtopenlite.HostServerConnectionPool<T>
public class HostServerConnectionPool<T extends HostServerConnection>
Used to pool HostServerConnections of a specific type to a specific system. For example:
// Get the SystemInfo object used to seed our pool.
SignonConnection signon = SignonConnection.getConnection("system", "user", "password");
SystemInfo info = signon.getInfo();
signon.close();
// Construct the pool (initially empty).
HostServerConnectionPool<CommandConnection> commandPool = new HostServerConnectionPool<CommandConnection>(info);
// To populate the pool, create connections and check them in.
// To use the pool, check out connections from the pool.
CommandConnection conn = CommandConnection.getConnection(info, "FRED", "password");
commandPool.checkin(conn);
conn = commandPool.checkout("FRED");
commandPool.checkin(conn);
// You can check the current size of the pool.
int used = commandPool.getUsedConnectionCount();
int free = commandPool.getFreeConnectionCount();
// You can check the number of connections per user.
int fredUsed = commandPool.getUsedConnectionCount("FRED");
int fredFree = commandPool.getFreeConnectionCount("FRED");
// Closing the pool will close all connections in the pool, both free and in use.
commandPool.close();
| Constructor Summary | |
|---|---|
HostServerConnectionPool(SystemInfo info)
Constructs a new connection pool for the specified system. |
|
| Method Summary | |
|---|---|
void |
checkin(T conn)
Adds or returns a connection to this pool. |
T |
checkout(String user)
Obtains a free connection from this pool for the specified user. |
void |
close()
Closes and removes all connections in this pool, both free and in use. |
void |
close(String user)
Closes and removes all connections for the specified user in this pool, both free and in use. |
void |
closeFree()
Closes and removes all free connections in this pool. |
void |
closeFree(String user)
Closes and removes all free connections for the specified user in this pool. |
void |
closeUsed()
Closes and removes all in-use connections in this pool. |
void |
closeUsed(String user)
Closes and removes all in-use connections for the specified user in this pool. |
protected void |
finalize()
|
int |
getConnectionCount()
Returns the total number of connections in this pool, both free and in use. |
int |
getConnectionCount(String user)
Returns the total number of connections for the specified user in this pool, both free and in use. |
int |
getFreeConnectionCount()
Returns the number of free connections in this pool. |
int |
getFreeConnectionCount(String user)
Returns the number of free connections for the specified user in this pool. |
SystemInfo |
getInfo()
Returns the system information for this pool. |
int |
getUsedConnectionCount()
Returns the number of in-use connections in this pool. |
int |
getUsedConnectionCount(String user)
Returns the number of used connections for the specified user in this pool. |
String[] |
getUsers()
Returns an array of users of connections in this pool, both free and in use. |
void |
remove(T conn)
Removes the specified connection from this pool, regardless if it is free or in use. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HostServerConnectionPool(SystemInfo info)
| Method Detail |
|---|
public SystemInfo getInfo()
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
public void checkin(T conn)
throws IOException
IOException
public T checkout(String user)
throws IOException
IOExceptionpublic void remove(T conn)
public void close()
throws IOException
IOException
public void closeFree()
throws IOException
IOException
public void closeUsed()
throws IOException
IOException
public void close(String user)
throws IOException
IOException
public void closeFree(String user)
throws IOException
IOException
public void closeUsed(String user)
throws IOException
IOExceptionpublic int getConnectionCount()
public int getFreeConnectionCount()
public int getUsedConnectionCount()
public int getConnectionCount(String user)
public int getFreeConnectionCount(String user)
public int getUsedConnectionCount(String user)
public String[] getUsers()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||