edu.vt.middleware.ldap.pool
Class SharedLdapPool

java.lang.Object
  extended by edu.vt.middleware.ldap.pool.AbstractLdapPool<Ldap>
      extended by edu.vt.middleware.ldap.pool.SharedLdapPool
All Implemented Interfaces:
LdapPool<Ldap>

public class SharedLdapPool
extends AbstractLdapPool<Ldap>

SharedLdapPool 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 be serviced by objects that are already in use. Since Ldap is a thread safe object this implementation leverages that by sharing ldap objects among requests. See LdapContext.newInstance(Control[]). This implementation should be used when you want some control over the maximum number of ldap connections, but can tolerate some new connections under high load. 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
SharedLdapPool()
          Creates a new ldap pool using DefaultLdapFactory.
SharedLdapPool(LdapFactory<Ldap> lf)
          Creates a new ldap pool with the supplied ldap factory.
SharedLdapPool(LdapPoolConfig lpc, LdapFactory<Ldap> lf)
          Creates a new ldap pool with the supplied ldap config and factory.
 
Method Summary
 void checkIn(Ldap l)
          Returns an ldap object to the pool.
 Ldap checkOut()
          Returns an ldap object from the pool.
protected  Ldap retrieveAvailable()
          This attempts to retrieve an ldap object from the available queue.
 
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

SharedLdapPool

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


SharedLdapPool

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

Parameters:
lf - ldap factory

SharedLdapPool

public SharedLdapPool(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

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. This pooling implementation guarantees there is always an object available.

Returns:
ldap object from the pool
Throws:
IllegalStateException - if an object cannot be removed from the available queue

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.