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
.AbstractLdapPool.PooledLdap<T extends BaseLdap>
active, available, checkInLock, checkOutLock, ldapFactory, logger, poolConfig, poolLock, poolNotEmpty
Constructor and Description |
---|
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.
|
Modifier and Type | Method and 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.
|
activateAndValidate, activeCount, availableCount, close, createActive, createAvailable, createAvailableAndActive, finalize, getLdapPoolConfig, initialize, prune, removeActive, removeAvailable, removeAvailableAndActive, setPoolTimer, validate, validateAndPassivate
public BlockingLdapPool()
DefaultLdapFactory
.public BlockingLdapPool(LdapFactory<Ldap> lf)
lf
- ldap factorypublic BlockingLdapPool(LdapPoolConfig lpc, LdapFactory<Ldap> lf)
lpc
- ldap pool configurationlf
- ldap factorypublic long getBlockWaitTime()
public void setBlockWaitTime(long time)
time
- in milliseconds to wait for available ldap objectspublic Ldap checkOut() throws LdapPoolException
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 interruptedprotected Ldap retrieveAvailable()
NoSuchElementException
- if the available queue is emptyprotected Ldap blockAvailable() throws LdapPoolException
LdapPoolException
- if this method failsBlockingTimeoutException
- if this pool is configured with a block
time and it occursPoolInterruptedException
- if the current thread is interruptedpublic void checkIn(Ldap l)
l
- ldap objectCopyright © 2014. All rights reserved.