Package edu.vt.middleware.ldap.pool
Class BlockingLdapPool
- java.lang.Object
-
- edu.vt.middleware.ldap.pool.AbstractLdapPool<Ldap>
-
- edu.vt.middleware.ldap.pool.BlockingLdapPool
-
- 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 bygetBlockWaitTime()
. 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. SeeAbstractLdapPool
.- Version:
- $Revision: 2241 $ $Date: 2012-02-07 21:08:51 +0100 (Tue, 07 Feb 2012) $
- 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
Constructors Constructor Description BlockingLdapPool()
Creates a new ldap pool usingDefaultLdapFactory
.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
-
Constructor Detail
-
BlockingLdapPool
public BlockingLdapPool()
Creates a new ldap pool usingDefaultLdapFactory
.
-
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 configurationlf
- 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 failsBlockingTimeoutException
- if this pool is configured with a block time and it occursPoolInterruptedException
- 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:
java.util.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 failsBlockingTimeoutException
- if this pool is configured with a block time and it occursPoolInterruptedException
- if the current thread is interrupted
-
checkIn
public void checkIn(Ldap l)
Returns an ldap object to the pool.- Parameters:
l
- ldap object
-
-