Pool Properties

The following properties are available on the PoolingContextSource for configuration of the DirContext pool. The contextSource property must be set and the dirContextValidator property must be set if validation is enabled, all other properties are optional.

Table 9.1. Pooling Configuration Properties

ParameterDefaultDescription
contextSource null The ContextSource implementation to get DirContext s from to populate the pool.
dirContextValidator null The DirContextValidator implementation to use when validating connections. This is required if testOnBorrow , testOnReturn , or testWhileIdle options are set to true .
maxActive 8 The maximum number of active connections of each type (read-only|read-write) that can be allocated from this pool at the same time, or non-positive for no limit.
maxTotal -1 The overall maximum number of active connections (for all types) that can be allocated from this pool at the same time, or non-positive for no limit.
maxIdle 8 The maximum number of active connections of each type (read-only|read-write) that can remain idle in the pool, without extra ones being released, or non-positive for no limit.
minIdle 0 The minimum number of active connections of each type (read-only|read-write) that can remain idle in the pool, without extra ones being created, or zero to create none.
maxWait -1 The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or non-positive to wait indefinitely.
whenExhaustedAction 1 (BLOCK) Specifies the behaviour when the pool is exhausted.
  • The FAIL (0) option will throw a NoSuchElementException when the pool is exhausted.

  • The BLOCK (1) option will wait until a new object is available. If maxWait is positive a NoSuchElementException is thrown if no new object is available after the maxWait time expires.

  • The GROW (2) option will create and return a new object (essentially making maxActive meaningless).

testOnBorrow false The indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and an attempt to borrow another will be made.
testOnReturn false The indication of whether objects will be validated before being returned to the pool.
testWhileIdle false The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.
timeBetweenEvictionRunsMillis -1 The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.
numTestsPerEvictionRun 3 The number of objects to examine during each run of the idle object evictor thread (if any).
minEvictableIdleTimeMillis 1000 * 60 * 30 The minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any).