Class BaseGenericObjectPool<T>
java.lang.Object
org.apache.tomcat.dbcp.pool2.BaseObject
org.apache.tomcat.dbcp.pool2.impl.BaseGenericObjectPool<T>
- Type Parameters:
- T- Type of element pooled in this pool.
- All Implemented Interfaces:
- AutoCloseable
- Direct Known Subclasses:
- GenericKeyedObjectPool,- GenericObjectPool
Base class that provides common functionality for 
GenericObjectPool
 and GenericKeyedObjectPool. The primary reason this class exists is
 reduce code duplication between the two pool implementations.
 Concrete implementations of this class are expected to be thread-safe.
- Since:
- 2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected AbandonedConfigAdditional configuration properties for abandoned object tracking.static final intThe size of the caches used to store historical data for some attributes so that rolling means may be calculated.
- 
Constructor SummaryConstructorsConstructorDescriptionBaseGenericObjectPool(BaseObjectPoolConfig<T> config, String jmxNameBase, String jmxNamePrefix) Handles JMX registration (if required) and the initialization required for monitoring.
- 
Method SummaryModifier and TypeMethodDescriptionabstract voidclose()Closes the pool, destroys the remaining idle objects and, if registered in JMX, deregisters it.abstract voidevict()PerformnumTestsidle object eviction tests, evicting examined objects that meet the criteria for eviction.final booleanGets whether to block when theborrowObject()method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).final longGets the total number of objects successfully borrowed from this pool over the lifetime of the pool.final longGets the total number of objects created for this pool over the lifetime of the pool.final StringGets the stack trace for the call that created this pool.final longGets the total number of objects destroyed by this pool as a result of failing validation duringborrowObject()over the lifetime of the pool.final longGets the total number of objects destroyed by the evictor associated with this pool over the lifetime of the pool.final longGets the total number of objects destroyed by this pool over the lifetime of the pool.final DurationGets the duration to sleep between runs of the idle object evictor thread.Gets theEvictionPolicydefined for this pool.final StringGets the name of theEvictionPolicyimplementation that is used by this pool.final DurationDeprecated.final DurationGets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the the value for the Evictor.final longDeprecated.final booleanGets whether or not the pool serves threads waiting to borrow objects fairly.final ObjectNameGets the name under which the pool has been registered with the platform MBean server ornullif the pool has not been registered.final booleangetLifo()Gets whether the pool has LIFO (last in, first out) behavior with respect to idle objects - always returning the most recently used object from the pool, or as a FIFO (first in, first out) queue, where the pool always returns the oldest object in the idle object pool.booleanGets whether this pool identifies and logs any abandoned objects.final DurationGets the maximum time a thread has waited to borrow objects from the pool.final longDeprecated.final intGets the maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time.final DurationGets the maximum duration theborrowObject()method should block before throwing an exception when the pool is exhausted andgetBlockWhenExhausted()is true.final longDeprecated.UsegetMaxWaitDuration().final DurationGets the mean time objects are active for based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects returned to the pool.final longDeprecated.final DurationGets the mean time threads wait to borrow an object based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects borrowed from the pool.final longDeprecated.final DurationGets the mean time objects are idle for based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects borrowed from the pool.final longDeprecated.booleanGets whether to include statistics in exception messages.final DurationGets 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 - seesetDurationBetweenEvictionRuns(Duration)).final DurationDeprecated.final longDeprecated.abstract intGets the number of instances currently idle in this pool.final intGets the maximum number of objects to examine during each run (if any) of the idle object evictor thread.booleanGets whether a check is made for abandoned objects when an object is borrowed from this pool.booleanGets whether a check is made for abandoned objects when the evictor runs.intDeprecated.Gets the timeout before which an object will be considered to be abandoned by this pool.final longGets the total number of objects returned to this pool over the lifetime of the pool.final DurationGets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool.final DurationDeprecated.final longDeprecated.Gets the listener used (if any) to receive notifications of exceptions unavoidably swallowed by the pool.final booleanGets whether objects borrowed from the pool will be validated before being returned from theborrowObject()method.final booleanGets whether objects created for the pool will be validated before being returned from theborrowObject()method.final booleanGets whether objects borrowed from the pool will be validated when they are returned to the pool via thereturnObject()method.final booleanGets whether objects sitting idle in the pool will be validated by the idle object evictor (if any - seesetDurationBetweenEvictionRuns(Duration)).final DurationDeprecated.final longDeprecated.booleanTests whether or not abandoned object removal is configured for this pool.final booleanisClosed()Tests whether this pool instance been closed.protected voidmarkReturningState(PooledObject<T> pooledObject) Marks the object as returning to the pool.voidsetAbandonedConfig(AbandonedConfig abandonedConfig) Sets the abandoned object removal configuration.final voidsetBlockWhenExhausted(boolean blockWhenExhausted) Sets whether to block when theborrowObject()method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).protected voidsetConfig(BaseObjectPoolConfig<T> config) Sets the receiver with the given configuration.final voidsetDurationBetweenEvictionRuns(Duration timeBetweenEvictionRuns) Sets the number of milliseconds to sleep between runs of the idle object evictor thread.voidsetEvictionPolicy(EvictionPolicy<T> evictionPolicy) Sets the eviction policy for this pool.final voidsetEvictionPolicyClassName(String evictionPolicyClassName) Sets the name of theEvictionPolicyimplementation that is used by this pool.final voidsetEvictionPolicyClassName(String evictionPolicyClassName, ClassLoader classLoader) Sets the name of theEvictionPolicyimplementation that is used by this pool.final voidsetEvictorShutdownTimeout(Duration evictorShutdownTimeout) Sets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the value for the Evictor.final voidsetEvictorShutdownTimeoutMillis(long evictorShutdownTimeoutMillis) Deprecated.final voidsetLifo(boolean lifo) Sets whether the pool has LIFO (last in, first out) behavior with respect to idle objects - always returning the most recently used object from the pool, or as a FIFO (first in, first out) queue, where the pool always returns the oldest object in the idle object pool.final voidsetMaxTotal(int maxTotal) Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time.final voidsetMaxWait(Duration maxWaitDuration) Sets the maximum duration theborrowObject()method should block before throwing an exception when the pool is exhausted andgetBlockWhenExhausted()is true.final voidsetMaxWaitMillis(long maxWaitMillis) Deprecated.voidsetMessagesStatistics(boolean messagesDetails) Sets whether to include statistics in exception messages.final voidsetMinEvictableIdle(Duration minEvictableIdleTime) Deprecated.final voidsetMinEvictableIdleDuration(Duration minEvictableIdleTime) Sets 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 - seesetDurationBetweenEvictionRuns(Duration)).final voidsetMinEvictableIdleTime(Duration minEvictableIdleTime) Deprecated.final voidsetMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) Deprecated.final voidsetNumTestsPerEvictionRun(int numTestsPerEvictionRun) Sets the maximum number of objects to examine during each run (if any) of the idle object evictor thread.final voidsetSoftMinEvictableIdle(Duration softMinEvictableIdleTime) Deprecated.final voidsetSoftMinEvictableIdleDuration(Duration softMinEvictableIdleTime) Sets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool.final voidsetSoftMinEvictableIdleTime(Duration softMinEvictableIdleTime) Deprecated.final voidsetSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) Deprecated.final voidsetSwallowedExceptionListener(SwallowedExceptionListener swallowedExceptionListener) Sets the listener used (if any) to receive notifications of exceptions unavoidably swallowed by the pool.final voidsetTestOnBorrow(boolean testOnBorrow) Sets whether objects borrowed from the pool will be validated before being returned from theborrowObject()method.final voidsetTestOnCreate(boolean testOnCreate) Sets whether objects created for the pool will be validated before being returned from theborrowObject()method.final voidsetTestOnReturn(boolean testOnReturn) Sets whether objects borrowed from the pool will be validated when they are returned to the pool via thereturnObject()method.final voidsetTestWhileIdle(boolean testWhileIdle) Sets whether objects sitting idle in the pool will be validated by the idle object evictor (if any - seesetDurationBetweenEvictionRuns(Duration)).final voidsetTimeBetweenEvictionRuns(Duration timeBetweenEvictionRuns) Deprecated.final voidsetTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) Deprecated.protected voidtoStringAppendFields(StringBuilder builder) Used by sub-classes to include the fields defined by the sub-class in theBaseObject.toString()output.Methods inherited from class org.apache.tomcat.dbcp.pool2.BaseObjecttoString
- 
Field Details- 
MEAN_TIMING_STATS_CACHE_SIZEpublic static final int MEAN_TIMING_STATS_CACHE_SIZEThe size of the caches used to store historical data for some attributes so that rolling means may be calculated.- See Also:
 
- 
abandonedConfigAdditional configuration properties for abandoned object tracking.
 
- 
- 
Constructor Details- 
BaseGenericObjectPoolpublic BaseGenericObjectPool(BaseObjectPoolConfig<T> config, String jmxNameBase, String jmxNamePrefix) Handles JMX registration (if required) and the initialization required for monitoring.- Parameters:
- config- Pool configuration
- jmxNameBase- The default base JMX name for the new pool unless overridden by the config
- jmxNamePrefix- Prefix to be used for JMX name for the new pool
 
 
- 
- 
Method Details- 
closepublic abstract void close()Closes the pool, destroys the remaining idle objects and, if registered in JMX, deregisters it.- Specified by:
- closein interface- AutoCloseable
 
- 
evictPerformnumTestsidle object eviction tests, evicting examined objects that meet the criteria for eviction. IftestWhileIdleis true, examined objects are validated when visited (and removed if invalid); otherwise only objects that have been idle for more thanminEvicableIdleTimeMillisare removed.- Throws:
- Exception- when there is a problem evicting idle objects.
 
- 
getBlockWhenExhaustedpublic final boolean getBlockWhenExhausted()Gets whether to block when theborrowObject()method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).- Returns:
- trueif- borrowObject()should block when the pool is exhausted
- See Also:
 
- 
getBorrowedCountpublic final long getBorrowedCount()Gets the total number of objects successfully borrowed from this pool over the lifetime of the pool.- Returns:
- the borrowed object count
 
- 
getCreatedCountpublic final long getCreatedCount()Gets the total number of objects created for this pool over the lifetime of the pool.- Returns:
- the created object count
 
- 
getCreationStackTraceGets the stack trace for the call that created this pool. JMX registration may trigger a memory leak so it is important that pools are deregistered when no longer used by calling theclose()method. This method is provided to assist with identifying code that creates but does not close it thereby creating a memory leak.- Returns:
- pool creation stack trace
 
- 
getDestroyedByBorrowValidationCountpublic final long getDestroyedByBorrowValidationCount()Gets the total number of objects destroyed by this pool as a result of failing validation duringborrowObject()over the lifetime of the pool.- Returns:
- validation destroyed object count
 
- 
getDestroyedByEvictorCountpublic final long getDestroyedByEvictorCount()Gets the total number of objects destroyed by the evictor associated with this pool over the lifetime of the pool.- Returns:
- the evictor destroyed object count
 
- 
getDestroyedCountpublic final long getDestroyedCount()Gets the total number of objects destroyed by this pool over the lifetime of the pool.- Returns:
- the destroyed object count
 
- 
getDurationBetweenEvictionRunsGets the duration to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.- Returns:
- number of milliseconds to sleep between evictor runs
- Since:
- 2.11.0
- See Also:
 
- 
getEvictionPolicyGets theEvictionPolicydefined for this pool.- Returns:
- the eviction policy
- Since:
- 2.4, 2.6.0 Changed access from protected to public.
 
- 
getEvictionPolicyClassNameGets the name of theEvictionPolicyimplementation that is used by this pool.- Returns:
- The fully qualified class name of the EvictionPolicy
- See Also:
 
- 
getEvictorShutdownTimeoutDeprecated.Gets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the the value for the Evictor.- Returns:
- The timeout that will be used while waiting for the Evictor to shut down.
- Since:
- 2.10.0
 
- 
getEvictorShutdownTimeoutDurationGets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the the value for the Evictor.- Returns:
- The timeout that will be used while waiting for the Evictor to shut down.
- Since:
- 2.11.0
 
- 
getEvictorShutdownTimeoutMillisDeprecated.Gets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the the value for the Evictor.- Returns:
- The timeout in milliseconds that will be used while waiting for the Evictor to shut down.
 
- 
getFairnesspublic final boolean getFairness()Gets whether or not the pool serves threads waiting to borrow objects fairly. True means that waiting threads are served as if waiting in a FIFO queue.- Returns:
- trueif waiting threads are to be served by the pool in arrival order
 
- 
getJmxNameGets the name under which the pool has been registered with the platform MBean server ornullif the pool has not been registered.- Returns:
- the JMX name
 
- 
getLifopublic final boolean getLifo()Gets whether the pool has LIFO (last in, first out) behavior with respect to idle objects - always returning the most recently used object from the pool, or as a FIFO (first in, first out) queue, where the pool always returns the oldest object in the idle object pool.- Returns:
- trueif the pool is configured with LIFO behavior or- falseif the pool is configured with FIFO behavior
- See Also:
 
- 
getLogAbandonedpublic boolean getLogAbandoned()Gets whether this pool identifies and logs any abandoned objects.- Returns:
- trueif abandoned object removal is configured for this pool and removal events are to be logged otherwise- false
- Since:
- 2.11.0
- See Also:
 
- 
getMaxBorrowWaitDurationGets the maximum time a thread has waited to borrow objects from the pool.- Returns:
- maximum wait time in milliseconds since the pool was created
- Since:
- 2.12.0
 
- 
getMaxBorrowWaitTimeMillisDeprecated.Gets the maximum time a thread has waited to borrow objects from the pool.- Returns:
- maximum wait time in milliseconds since the pool was created
 
- 
getMaxTotalpublic final int getMaxTotal()Gets the maximum number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. When negative, there is no limit to the number of objects that can be managed by the pool at one time.- Returns:
- the cap on the total number of object instances managed by the pool.
- See Also:
 
- 
getMaxWaitDurationGets the maximum duration theborrowObject()method should block before throwing an exception when the pool is exhausted andgetBlockWhenExhausted()is true. When less than 0, theborrowObject()method may block indefinitely.- Returns:
- the maximum number of milliseconds borrowObject()will block.
- Since:
- 2.11.0
- See Also:
 
- 
getMaxWaitMillisDeprecated.UsegetMaxWaitDuration().Gets the maximum amount of time (in milliseconds) theborrowObject()method should block before throwing an exception when the pool is exhausted andgetBlockWhenExhausted()is true. When less than 0, theborrowObject()method may block indefinitely.- Returns:
- the maximum number of milliseconds borrowObject()will block.
- See Also:
 
- 
getMeanActiveDurationGets the mean time objects are active for based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects returned to the pool.- Returns:
- mean time an object has been checked out from the pool among recently returned objects.
- Since:
- 2.12.0
 
- 
getMeanActiveTimeMillisDeprecated.Gets the mean time objects are active for based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects returned to the pool.- Returns:
- mean time an object has been checked out from the pool among recently returned objects.
 
- 
getMeanBorrowWaitDurationGets the mean time threads wait to borrow an object based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects borrowed from the pool.- Returns:
- mean time in milliseconds that a recently served thread has had to wait to borrow an object from the pool.
- Since:
- 2.12.0
 
- 
getMeanBorrowWaitTimeMillisDeprecated.Gets the mean time threads wait to borrow an object based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects borrowed from the pool.- Returns:
- mean time in milliseconds that a recently served thread has had to wait to borrow an object from the pool.
 
- 
getMeanIdleDurationGets the mean time objects are idle for based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects borrowed from the pool.- Returns:
- mean time an object has been idle in the pool among recently borrowed objects.
- Since:
- 2.12.0
 
- 
getMeanIdleTimeMillisDeprecated.Gets the mean time objects are idle for based on the lastMEAN_TIMING_STATS_CACHE_SIZEobjects borrowed from the pool.- Returns:
- mean time an object has been idle in the pool among recently borrowed objects.
 
- 
getMessageStatisticspublic boolean getMessageStatistics()Gets whether to include statistics in exception messages.Statistics may not accurately reflect snapshot state at the time of the exception because we do not want to lock the pool when gathering this information. - Returns:
- whether to include statistics in exception messages.
- Since:
- 2.11.0
 
- 
getMinEvictableIdleDurationGets 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 - seesetDurationBetweenEvictionRuns(Duration)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Returns:
- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- Since:
- 2.11.0
- See Also:
 
- 
getMinEvictableIdleTimeDeprecated.Gets 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 - seesetDurationBetweenEvictionRuns(Duration)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Returns:
- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- Since:
- 2.10.0
- See Also:
 
- 
getMinEvictableIdleTimeMillisDeprecated.Gets 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 - seesetTimeBetweenEvictionRunsMillis(long)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Returns:
- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- See Also:
 
- 
getNumIdlepublic abstract int getNumIdle()Gets the number of instances currently idle in this pool.- Returns:
- count of instances available for checkout from the pool
 
- 
getNumTestsPerEvictionRunpublic final int getNumTestsPerEvictionRun()Gets the maximum number of objects to examine during each run (if any) of the idle object evictor thread. When positive, the number of tests performed for a run will be the minimum of the configured value and the number of idle instances in the pool. When negative, the number of tests performed will beceil(which means that when the value isgetNumIdle()/ abs(getNumTestsPerEvictionRun()))-nroughly one nth of the idle objects will be tested per run.- Returns:
- max number of objects to examine during each evictor run
- See Also:
 
- 
getRemoveAbandonedOnBorrowpublic boolean getRemoveAbandonedOnBorrow()Gets whether a check is made for abandoned objects when an object is borrowed from this pool.- Returns:
- trueif abandoned object removal is configured to be activated by borrowObject otherwise- false
- Since:
- 2.11.0
- See Also:
 
- 
getRemoveAbandonedOnMaintenancepublic boolean getRemoveAbandonedOnMaintenance()Gets whether a check is made for abandoned objects when the evictor runs.- Returns:
- trueif abandoned object removal is configured to be activated when the evictor runs otherwise- false
- Since:
- 2.11.0
- See Also:
 
- 
getRemoveAbandonedTimeoutDeprecated.Gets the timeout before which an object will be considered to be abandoned by this pool.- Returns:
- The abandoned object timeout in seconds if abandoned object removal is configured for this pool; Integer.MAX_VALUE otherwise.
- Since:
- 2.11.0
- See Also:
 
- 
getRemoveAbandonedTimeoutDurationGets the timeout before which an object will be considered to be abandoned by this pool.- Returns:
- The abandoned object timeout in seconds if abandoned object removal is configured for this pool; Integer.MAX_VALUE otherwise.
- Since:
- 2.11.0
- See Also:
 
- 
getReturnedCountpublic final long getReturnedCount()Gets the total number of objects returned to this pool over the lifetime of the pool. This excludes attempts to return the same object multiple times.- Returns:
- the returned object count
 
- 
getSoftMinEvictableIdleDurationGets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTime()(that is, ifgetMinEvictableIdleTime()is positive, thengetSoftMinEvictableIdleTime()is ignored).- Returns:
- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- Since:
- 2.11.0
- See Also:
 
- 
getSoftMinEvictableIdleTimeDeprecated.Gets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTime()(that is, ifgetMinEvictableIdleTime()is positive, thengetSoftMinEvictableIdleTime()is ignored).- Returns:
- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- Since:
- 2.10.0
- See Also:
 
- 
getSoftMinEvictableIdleTimeMillisDeprecated.Gets 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 - seesetTimeBetweenEvictionRunsMillis(long)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTimeMillis()(that is, ifgetMinEvictableIdleTimeMillis()is positive, thengetSoftMinEvictableIdleTimeMillis()is ignored).- Returns:
- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- See Also:
 
- 
getSwallowedExceptionListenerGets the listener used (if any) to receive notifications of exceptions unavoidably swallowed by the pool.- Returns:
- The listener or nullfor no listener
 
- 
getTestOnBorrowpublic final boolean getTestOnBorrow()Gets whether objects borrowed from the pool will be validated before being returned from theborrowObject()method. Validation is performed by thevalidateObject()method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed, and a new attempt will be made to borrow an object from the pool.- Returns:
- trueif objects are validated before being returned from the- borrowObject()method
- See Also:
 
- 
getTestOnCreatepublic final boolean getTestOnCreate()Gets whether objects created for the pool will be validated before being returned from theborrowObject()method. Validation is performed by thevalidateObject()method of the factory associated with the pool. If the object fails to validate, thenborrowObject()will fail.- Returns:
- trueif newly created objects are validated before being returned from the- borrowObject()method
- Since:
- 2.2
- See Also:
 
- 
getTestOnReturnpublic final boolean getTestOnReturn()Gets whether objects borrowed from the pool will be validated when they are returned to the pool via thereturnObject()method. Validation is performed by thevalidateObject()method of the factory associated with the pool. Returning objects that fail validation are destroyed rather then being returned the pool.- Returns:
- trueif objects are validated on return to the pool via the- returnObject()method
- See Also:
 
- 
getTestWhileIdlepublic final boolean getTestWhileIdle()Gets whether objects sitting idle in the pool will be validated by the idle object evictor (if any - seesetDurationBetweenEvictionRuns(Duration)). Validation is performed by thevalidateObject()method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed.- Returns:
- trueif objects will be validated by the evictor
- See Also:
 
- 
getTimeBetweenEvictionRunsDeprecated.Gets the duration to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.- Returns:
- number of milliseconds to sleep between evictor runs
- Since:
- 2.10.0
- See Also:
 
- 
getTimeBetweenEvictionRunsMillisDeprecated.Gets 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.- Returns:
- number of milliseconds to sleep between evictor runs
- See Also:
 
- 
isAbandonedConfigpublic boolean isAbandonedConfig()Tests whether or not abandoned object removal is configured for this pool.- Returns:
- true if this pool is configured to detect and remove abandoned objects
- Since:
- 2.11.0
 
- 
isClosedpublic final boolean isClosed()Tests whether this pool instance been closed.- Returns:
- truewhen this pool has been closed.
 
- 
markReturningStateMarks the object as returning to the pool.- Parameters:
- pooledObject- instance to return to the keyed pool
 
- 
setAbandonedConfigSets the abandoned object removal configuration.- Parameters:
- abandonedConfig- the new configuration to use. This is used by value.
- Since:
- 2.11.0
- See Also:
 
- 
setBlockWhenExhaustedpublic final void setBlockWhenExhausted(boolean blockWhenExhausted) Sets whether to block when theborrowObject()method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).- Parameters:
- blockWhenExhausted-- trueif- borrowObject()should block when the pool is exhausted
- See Also:
 
- 
setConfigSets the receiver with the given configuration.- Parameters:
- config- Initialization source.
 
- 
setDurationBetweenEvictionRunsSets the number of milliseconds to sleep between runs of the idle object evictor thread.- When positive, the idle object evictor thread starts.
- When null or non-positive, no idle object evictor thread runs.
 - Parameters:
- timeBetweenEvictionRuns- duration to sleep between evictor runs
- Since:
- 2.12.0
- See Also:
 
- 
setEvictionPolicySets the eviction policy for this pool.- Parameters:
- evictionPolicy- the eviction policy for this pool.
- Since:
- 2.6.0
 
- 
setEvictionPolicyClassNameSets the name of theEvictionPolicyimplementation that is used by this pool. The Pool will attempt to load the class using the thread context class loader. If that fails, the use the class loader for theEvictionPolicyinterface.- Parameters:
- evictionPolicyClassName- the fully qualified class name of the new eviction policy
- Since:
- 2.6.0 If loading the class using the thread context class loader fails, use the class loader for the
        EvictionPolicyinterface.
- See Also:
 
- 
setEvictionPolicyClassNamepublic final void setEvictionPolicyClassName(String evictionPolicyClassName, ClassLoader classLoader) Sets the name of theEvictionPolicyimplementation that is used by this pool. The Pool will attempt to load the class using the given class loader. If that fails, use the class loader for theEvictionPolicyinterface.- Parameters:
- evictionPolicyClassName- the fully qualified class name of the new eviction policy
- classLoader- the class loader to load the given- evictionPolicyClassName.
- Since:
- 2.6.0 If loading the class using the given class loader fails, use the class loader for the
        EvictionPolicyinterface.
- See Also:
 
- 
setEvictorShutdownTimeoutSets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the value for the Evictor.- Parameters:
- evictorShutdownTimeout- the timeout in milliseconds that will be used while waiting for the Evictor to shut down.
- Since:
- 2.10.0
 
- 
setEvictorShutdownTimeoutMillisDeprecated.Sets the timeout that will be used when waiting for the Evictor to shutdown if this pool is closed and it is the only pool still using the value for the Evictor.- Parameters:
- evictorShutdownTimeoutMillis- the timeout in milliseconds that will be used while waiting for the Evictor to shut down.
 
- 
setLifopublic final void setLifo(boolean lifo) Sets whether the pool has LIFO (last in, first out) behavior with respect to idle objects - always returning the most recently used object from the pool, or as a FIFO (first in, first out) queue, where the pool always returns the oldest object in the idle object pool.- Parameters:
- lifo-- trueif the pool is to be configured with LIFO behavior or- falseif the pool is to be configured with FIFO behavior
- See Also:
 
- 
setMaxTotalpublic final void setMaxTotal(int maxTotal) Sets the cap on the number of objects that can be allocated by the pool (checked out to clients, or idle awaiting checkout) at a given time. Use a negative value for no limit.- Parameters:
- maxTotal- The cap on the total number of object instances managed by the pool. Negative values mean that there is no limit to the number of objects allocated by the pool.
- See Also:
 
- 
setMaxWaitSets the maximum duration theborrowObject()method should block before throwing an exception when the pool is exhausted andgetBlockWhenExhausted()is true. When less than 0, theborrowObject()method may block indefinitely.- Parameters:
- maxWaitDuration- the maximum duration- borrowObject()will block or negative for indefinitely.
- Since:
- 2.11.0
- See Also:
 
- 
setMaxWaitMillisDeprecated.Sets the maximum amount of time (in milliseconds) theborrowObject()method should block before throwing an exception when the pool is exhausted andgetBlockWhenExhausted()is true. When less than 0, theborrowObject()method may block indefinitely.- Parameters:
- maxWaitMillis- the maximum number of milliseconds- borrowObject()will block or negative for indefinitely.
- See Also:
 
- 
setMessagesStatisticspublic void setMessagesStatistics(boolean messagesDetails) Sets whether to include statistics in exception messages.Statistics may not accurately reflect snapshot state at the time of the exception because we do not want to lock the pool when gathering this information. - Parameters:
- messagesDetails- whether to include statistics in exception messages.
- Since:
- 2.11.0
 
- 
setMinEvictableIdleDeprecated.Sets 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 - seesetDurationBetweenEvictionRuns(Duration)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Parameters:
- minEvictableIdleTime- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- Since:
- 2.11.0
- See Also:
 
- 
setMinEvictableIdleDurationSets 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 - seesetDurationBetweenEvictionRuns(Duration)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Parameters:
- minEvictableIdleTime- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- Since:
- 2.12.0
- See Also:
 
- 
setMinEvictableIdleTimeDeprecated.Sets 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 - seesetDurationBetweenEvictionRuns(Duration)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Parameters:
- minEvictableIdleTime- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- Since:
- 2.10.0
- See Also:
 
- 
setMinEvictableIdleTimeMillisDeprecated.Sets 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 - seesetTimeBetweenEvictionRunsMillis(long)). When non-positive, no objects will be evicted from the pool due to idle time alone.- Parameters:
- minEvictableIdleTimeMillis- minimum amount of time an object may sit idle in the pool before it is eligible for eviction
- See Also:
 
- 
setNumTestsPerEvictionRunpublic final void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) Sets the maximum number of objects to examine during each run (if any) of the idle object evictor thread. When positive, the number of tests performed for a run will be the minimum of the configured value and the number of idle instances in the pool. When negative, the number of tests performed will beceil(which means that when the value isgetNumIdle()/ abs(getNumTestsPerEvictionRun()))-nroughly one nth of the idle objects will be tested per run.- Parameters:
- numTestsPerEvictionRun- max number of objects to examine during each evictor run
- See Also:
 
- 
setSoftMinEvictableIdleDeprecated.Sets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTime()(that is, ifgetMinEvictableIdleTime()is positive, thengetSoftMinEvictableIdleTime()is ignored).- Parameters:
- softMinEvictableIdleTime- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- Since:
- 2.11.0
- See Also:
 
- 
setSoftMinEvictableIdleDurationSets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTime()(that is, ifgetMinEvictableIdleTime()is positive, thengetSoftMinEvictableIdleTime()is ignored).- Parameters:
- softMinEvictableIdleTime- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- Since:
- 2.12.0
- See Also:
 
- 
setSoftMinEvictableIdleTimeDeprecated.Sets 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 - seesetDurationBetweenEvictionRuns(Duration)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTime()(that is, ifgetMinEvictableIdleTime()is positive, thengetSoftMinEvictableIdleTime()is ignored).- Parameters:
- softMinEvictableIdleTime- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- Since:
- 2.10.0
- See Also:
 
- 
setSoftMinEvictableIdleTimeMillis@Deprecated public final void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) Deprecated.Sets 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 - seesetTimeBetweenEvictionRunsMillis(long)), with the extra condition that at leastminIdleobject instances remain in the pool. This setting is overridden bygetMinEvictableIdleTimeMillis()(that is, ifgetMinEvictableIdleTimeMillis()is positive, thengetSoftMinEvictableIdleTimeMillis()is ignored).- Parameters:
- softMinEvictableIdleTimeMillis- minimum amount of time an object may sit idle in the pool before it is eligible for eviction if minIdle instances are available
- See Also:
 
- 
setSwallowedExceptionListenerpublic final void setSwallowedExceptionListener(SwallowedExceptionListener swallowedExceptionListener) Sets the listener used (if any) to receive notifications of exceptions unavoidably swallowed by the pool.- Parameters:
- swallowedExceptionListener- The listener or- nullfor no listener
 
- 
setTestOnBorrowpublic final void setTestOnBorrow(boolean testOnBorrow) Sets whether objects borrowed from the pool will be validated before being returned from theborrowObject()method. Validation is performed by thevalidateObject()method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed, and a new attempt will be made to borrow an object from the pool.- Parameters:
- testOnBorrow-- trueif objects should be validated before being returned from the- borrowObject()method
- See Also:
 
- 
setTestOnCreatepublic final void setTestOnCreate(boolean testOnCreate) Sets whether objects created for the pool will be validated before being returned from theborrowObject()method. Validation is performed by thevalidateObject()method of the factory associated with the pool. If the object fails to validate, thenborrowObject()will fail.- Parameters:
- testOnCreate-- trueif newly created objects should be validated before being returned from the- borrowObject()method
- Since:
- 2.2
- See Also:
 
- 
setTestOnReturnpublic final void setTestOnReturn(boolean testOnReturn) Sets whether objects borrowed from the pool will be validated when they are returned to the pool via thereturnObject()method. Validation is performed by thevalidateObject()method of the factory associated with the pool. Returning objects that fail validation are destroyed rather then being returned the pool.- Parameters:
- testOnReturn-- trueif objects are validated on return to the pool via the- returnObject()method
- See Also:
 
- 
setTestWhileIdlepublic final void setTestWhileIdle(boolean testWhileIdle) Sets whether objects sitting idle in the pool will be validated by the idle object evictor (if any - seesetDurationBetweenEvictionRuns(Duration)). Validation is performed by thevalidateObject()method of the factory associated with the pool. If the object fails to validate, it will be removed from the pool and destroyed. Note that setting this property has no effect unless the idle object evictor is enabled by settingtimeBetweenEvictionRunsMillisto a positive value.- Parameters:
- testWhileIdle-- trueso objects will be validated by the evictor
- See Also:
 
- 
setTimeBetweenEvictionRunsDeprecated.Sets the number of milliseconds to sleep between runs of the idle object evictor thread.- When positive, the idle object evictor thread starts.
- When non-positive, no idle object evictor thread runs.
 - Parameters:
- timeBetweenEvictionRuns- duration to sleep between evictor runs
- Since:
- 2.10.0
- See Also:
 
- 
setTimeBetweenEvictionRunsMillisDeprecated.Sets the number of milliseconds to sleep between runs of the idle object evictor thread.- When positive, the idle object evictor thread starts.
- When non-positive, no idle object evictor thread runs.
 - Parameters:
- timeBetweenEvictionRunsMillis- number of milliseconds to sleep between evictor runs
- See Also:
 
- 
toStringAppendFieldsDescription copied from class:BaseObjectUsed by sub-classes to include the fields defined by the sub-class in theBaseObject.toString()output.- Overrides:
- toStringAppendFieldsin class- BaseObject
- Parameters:
- builder- Field names and values are appended to this object
 
 
- 
getEvictorShutdownTimeoutDuration().