netscape.ldap.util
Class ConnectionPool
java.lang.Object
netscape.ldap.util.ConnectionPool
public class ConnectionPool
extends java.lang.Object
Connection pool, typically used by a server to avoid creating
a new connection for each client
ConnectionPool(String host, int port) - Constructor for using default parameters, anonymous identity
|
ConnectionPool(int min, int max, String host, int port) - Constructor for specifying all parameters, anonymous
identity
|
ConnectionPool(int min, int max, String host, int port, String authdn, String authpw) - Constructor for specifying all parameters
|
ConnectionPool(int min, int max, LDAPConnection ldc) - Constructor for using an existing connection to clone
from.
|
void | close(LDAPConnection ld) - This is our soft close - all we do is mark
the connection as available for others to use.
|
void | destroy() - Destroy the whole pool - called during a shutdown
|
protected LDAPConnection | getConnFromPool() - Gets a connection from the pool
If no connections are available, the pool will be
extended if the number of connections is less than
the maximum; if the pool cannot be extended, the method
returns null.
|
LDAPConnection | getConnection() - Gets a connection from the pool
If no connections are available, the pool will be
extended if the number of connections is less than
the maximum; if the pool cannot be extended, the method
blocks until a free connection becomes available.
|
LDAPConnection | getConnection(int timeout) - Gets a connection from the pool within a time limit.
|
boolean | getDebug() - Reports the debug printout mode.
|
void | printPool() - Debug method to print the contents of the pool
|
void | setDebug(boolean mode) - Sets the debug printout mode.
|
ConnectionPool
public ConnectionPool(String host,
int port)
throws LDAPException
Constructor for using default parameters, anonymous identity
host
- hostname of LDAP serverport
- port number of LDAP server
ConnectionPool
public ConnectionPool(int min,
int max,
String host,
int port)
throws LDAPException
Constructor for specifying all parameters, anonymous
identity
min
- initial number of connectionsmax
- maximum number of connectionshost
- hostname of LDAP serverport
- port number of LDAP server
ConnectionPool
public ConnectionPool(int min,
int max,
String host,
int port,
String authdn,
String authpw)
throws LDAPException
Constructor for specifying all parameters
min
- initial number of connectionsmax
- maximum number of connectionshost
- hostname of LDAP serverport
- port number of LDAP serverauthdn
- DN to authenticate asauthpw
- password for authentication
ConnectionPool
public ConnectionPool(int min,
int max,
LDAPConnection ldc)
throws LDAPException
Constructor for using an existing connection to clone
from.
The connection to clone must be already established and
the user authenticated.
min
- initial number of connectionsmax
- maximum number of connectionsldc
- connection to clone
close
public void close(LDAPConnection ld)
This is our soft close - all we do is mark
the connection as available for others to use.
We also reset the auth credentials in case
they were changed by the caller.
ld
- a connection to return to the pool
destroy
public void destroy()
Destroy the whole pool - called during a shutdown
getConnFromPool
protected LDAPConnection getConnFromPool()
Gets a connection from the pool
If no connections are available, the pool will be
extended if the number of connections is less than
the maximum; if the pool cannot be extended, the method
returns null.
- an active connection or null.
getConnection
public LDAPConnection getConnection()
Gets a connection from the pool
If no connections are available, the pool will be
extended if the number of connections is less than
the maximum; if the pool cannot be extended, the method
blocks until a free connection becomes available.
getConnection
public LDAPConnection getConnection(int timeout)
Gets a connection from the pool within a time limit.
If no connections are available, the pool will be
extended if the number of connections is less than
the maximum; if the pool cannot be extended, the method
blocks until a free connection becomes available or the
time limit is exceeded.
timeout
- timeout in milliseconds
- an active connection or
null
if timed out.
getDebug
public boolean getDebug()
Reports the debug printout mode.
printPool
public void printPool()
Debug method to print the contents of the pool
setDebug
public void setDebug(boolean mode)
Sets the debug printout mode.