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


Constructor Summary
ConnectionPool(int min, int max, LDAPConnection ldc)
           
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
 
Method Summary
 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.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionPool

public ConnectionPool(int min,
                      int max,
                      java.lang.String host,
                      int port,
                      java.lang.String authdn,
                      java.lang.String authpw)
               throws LDAPException
Constructor for specifying all parameters
Parameters:
min - initial number of connections
max - maximum number of connections
host - hostname of LDAP server
port - port number of LDAP server
authdn - DN to authenticate as
authpw - password for authentication
Throws:
LDAPException - on failure to create connections

ConnectionPool

public ConnectionPool(int min,
                      int max,
                      java.lang.String host,
                      int port)
               throws LDAPException
Constructor for specifying all parameters, anonymous identity
Parameters:
min - initial number of connections
max - maximum number of connections
host - hostname of LDAP server
port - port number of LDAP server
Throws:
LDAPException - on failure to create connections

ConnectionPool

public ConnectionPool(java.lang.String host,
                      int port)
               throws LDAPException
Constructor for using default parameters, anonymous identity
Parameters:
host - hostname of LDAP server
port - port number of LDAP server
Throws:
LDAPException - on failure to create connections

ConnectionPool

public ConnectionPool(int min,
                      int max,
                      LDAPConnection ldc)
               throws LDAPException
Method Detail

destroy

public void destroy()
Destroy the whole pool - called during a shutdown

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.
Returns:
an active connection.

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.
Returns:
an active connection or null.

close

public void close(LDAPConnection ld)
This is our soft close - all we do is mark the connection as available for others to use.
Parameters:
ld - a connection to return to the pool

printPool

public void printPool()
Debug method to print the contents of the pool

setDebug

public void setDebug(boolean mode)
Sets the debug printout mode.
Parameters:
mode - debug mode to use

getDebug

public boolean getDebug()
Reports the debug printout mode.
Returns:
debug mode in use.