public class ConnectionPool
extends java.lang.Object
Constructor and Description |
---|
ConnectionPool(int min,
int max,
LDAPConnection ldc)
Constructor for using an existing connection to clone
from.
|
ConnectionPool(int min,
int max,
java.lang.String host,
int port)
Constructor for specifying all parameters, anonymous
identity
|
ConnectionPool(int min,
int max,
java.lang.String host,
int port,
java.lang.String authdn,
java.lang.String authpw)
Constructor for specifying all parameters
|
ConnectionPool(java.lang.String host,
int port)
Constructor for using default parameters, anonymous identity
|
Modifier and Type | Method and Description |
---|---|
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
|
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.
|
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.
|
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.
|
public ConnectionPool(int min, int max, java.lang.String host, int port, java.lang.String authdn, java.lang.String authpw) throws LDAPException
min
- initial number of connectionsmax
- maximum number of connectionshost
- hostname of LDAP serverport
- port number of LDAP serverauthdn
- DN to authenticate asauthpw
- password for authenticationLDAPException
- on failure to create connectionspublic ConnectionPool(int min, int max, java.lang.String host, int port) throws LDAPException
min
- initial number of connectionsmax
- maximum number of connectionshost
- hostname of LDAP serverport
- port number of LDAP serverLDAPException
- on failure to create connectionspublic ConnectionPool(java.lang.String host, int port) throws LDAPException
host
- hostname of LDAP serverport
- port number of LDAP serverLDAPException
- on failure to create connectionspublic ConnectionPool(int min, int max, LDAPConnection ldc) throws LDAPException
The connection to clone must be already established and the user authenticated.
min
- initial number of connectionsmax
- maximum number of connectionsldc
- connection to cloneLDAPException
- on failure to create connectionspublic void destroy()
public LDAPConnection getConnection()
public LDAPConnection getConnection(int timeout)
timeout
- timeout in millisecondsnull
if timed out.protected LDAPConnection getConnFromPool()
public void close(LDAPConnection ld)
ld
- a connection to return to the poolpublic void printPool()
public void setDebug(boolean mode)
mode
- debug mode to usepublic boolean getDebug()