edu.vt.middleware.ldap.pool
Class BlockingLdapPool

java.lang.Object
  extended by edu.vt.middleware.ldap.pool.AbstractLdapPool<Ldap>
      extended by edu.vt.middleware.ldap.pool.BlockingLdapPool
All Implemented Interfaces:
LdapPool<Ldap>
Direct Known Subclasses:
SoftLimitLdapPool

public class BlockingLdapPool
extends AbstractLdapPool<Ldap>

BlockingLdapPool implements a pool of ldap objects that has a set minimum and maximum size. The pool will not grow beyond the maximum size and when the pool is exhausted, requests for new objects will block. The length of time the pool will block is determined by getBlockWaitTime(). By default the pool will block indefinitely and there is no guarantee that waiting threads will be serviced in the order in which they made their request. This implementation should be used when you need to control the exact number of ldap connections that can be created. See AbstractLdapPool.

Version:
$Revision: 1330 $ $Date: 2010-05-23 18:10:53 -0400 (Sun, 23 May 2010) $
Author:
Middleware Services

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.vt.middleware.ldap.pool.AbstractLdapPool
AbstractLdapPool.PooledLdap<T extends BaseLdap>
 
Field Summary
 
Fields inherited from class edu.vt.middleware.ldap.pool.AbstractLdapPool
active, available, checkInLock, checkOutLock, ldapFactory, logger, poolConfig, poolLock, poolNotEmpty
 
Constructor Summary
BlockingLdapPool()
          Creates a new ldap pool using DefaultLdapFactory.
BlockingLdapPool(LdapFactory<Ldap> lf)
          Creates a new ldap pool with the supplied ldap factory.
BlockingLdapPool(LdapPoolConfig lpc, LdapFactory<Ldap> lf)
          Creates a new ldap pool with the supplied ldap config and factory.
 
Method Summary
protected  Ldap blockAvailable()
          This blocks until an ldap object can be aquired.
 void checkIn(Ldap l)
          Returns an ldap object to the pool.
 Ldap checkOut()
          Returns an ldap object from the pool.
 long getBlockWaitTime()
          Returns the block wait time.
protected  Ldap retrieveAvailable()
          This attempts to retrieve an ldap object from the available queue.
 void setBlockWaitTime(long time)
          Sets the block wait time.
 
Methods inherited from class edu.vt.middleware.ldap.pool.AbstractLdapPool
activateAndValidate, activeCount, availableCount, close, createActive, createAvailable, createAvailableAndActive, finalize, getLdapPoolConfig, initialize, prune, removeActive, removeAvailable, removeAvailableAndActive, setPoolTimer, validate, validateAndPassivate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingLdapPool

public BlockingLdapPool()
Creates a new ldap pool using DefaultLdapFactory.


BlockingLdapPool

public BlockingLdapPool(LdapFactory<Ldap> lf)
Creates a new ldap pool with the supplied ldap factory.

Parameters:
lf - ldap factory

BlockingLdapPool

public BlockingLdapPool(LdapPoolConfig lpc,
                        LdapFactory<Ldap> lf)
Creates a new ldap pool with the supplied ldap config and factory.

Parameters:
lpc - ldap pool configuration
lf - ldap factory
Method Detail

getBlockWaitTime

public long getBlockWaitTime()
Returns the block wait time. Default time is 0, which will wait indefinitely.

Returns:
time in milliseconds to wait for available ldap objects

setBlockWaitTime

public void setBlockWaitTime(long time)
Sets the block wait time. Default time is 0, which will wait indefinitely.

Parameters:
time - in milliseconds to wait for available ldap objects

checkOut

public Ldap checkOut()
              throws LdapPoolException
Returns an ldap object from the pool.

Returns:
ldap object
Throws:
LdapPoolException - if this operation fails
BlockingTimeoutException - if this pool is configured with a block time and it occurs
PoolInterruptedException - if this pool is configured with a block time and the current thread is interrupted

retrieveAvailable

protected Ldap retrieveAvailable()
This attempts to retrieve an ldap object from the available queue.

Returns:
ldap object from the pool
Throws:
NoSuchElementException - if the available queue is empty

blockAvailable

protected Ldap blockAvailable()
                       throws LdapPoolException
This blocks until an ldap object can be aquired.

Returns:
ldap object from the pool
Throws:
LdapPoolException - if this method fails
BlockingTimeoutException - if this pool is configured with a block time and it occurs
PoolInterruptedException - if the current thread is interrupted

checkIn

public void checkIn(Ldap l)
Returns an ldap object to the pool.

Parameters:
l - ldap object


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.