AbandonedObjectPool (Apache Tomcat 7.0.104 API Documentation)

org.apache.tomcat.dbcp.dbcp

## Class AbandonedObjectPool<T extends AbandonedTrace>

- java.lang.Object
- - org.apache.tomcat.dbcp.pool.BaseObjectPool<T>
  - - org.apache.tomcat.dbcp.pool.impl.GenericObjectPool<T>
    - - org.apache.tomcat.dbcp.dbcp.AbandonedObjectPool<T>

- All Implemented Interfaces:
    ObjectPool<T>

      public class AbandonedObjectPool<T extends AbandonedTrace>
      extends GenericObjectPool<T>

  An implementation of a Jakarta-Commons ObjectPool which tracks JDBC connections and can recover abandoned db connections. If logAbandoned=true, a stack trace will be printed for any abandoned db connections recovered.

  Author:
    Glenn L. Nielsen

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.tomcat.dbcp.pool.impl.GenericObjectPool

      `GenericObjectPool.Config`

  - ### Field Summary

    - ### Fields inherited from class org.apache.tomcat.dbcp.pool.impl.GenericObjectPool

      `DEFAULT_LIFO, DEFAULT_MAX_ACTIVE, DEFAULT_MAX_IDLE, DEFAULT_MAX_WAIT, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_MIN_IDLE, DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TEST_WHILE_IDLE, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, DEFAULT_WHEN_EXHAUSTED_ACTION, WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, WHEN_EXHAUSTED_GROW`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbandonedObjectPool(PoolableObjectFactory<T> factory, AbandonedConfig config)` Create an ObjectPool which tracks db connections.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `borrowObject()` Get a db connection from the pool.
    `void` | `invalidateObject(T obj)` Invalidates an object from the pool.
    `void` | `returnObject(T obj)` Return a db connection to the pool.

    - ### Methods inherited from class org.apache.tomcat.dbcp.pool.impl.GenericObjectPool

      `addObject, clear, close, evict, getLifo, getMaxActive, getMaxIdle, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getWhenExhaustedAction, setConfig, setFactory, setLifo, setMaxActive, setMaxIdle, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setWhenExhaustedAction, startEvictor`

    - ### Methods inherited from class org.apache.tomcat.dbcp.pool.BaseObjectPool

      `assertOpen, isClosed`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbandonedObjectPool

          public AbandonedObjectPool(PoolableObjectFactory<T> factory,
                             AbandonedConfig config)

      Create an ObjectPool which tracks db connections.
      Parameters:
        `factory` - PoolableObjectFactory used to create this
        `config` - configuration for abandoned db connections

  - ### Method Detail

    - #### borrowObject

          public T borrowObject()
                                                throws Exception

      Get a db connection from the pool. If removeAbandoned=true, recovers db connections which have been idle > removeAbandonedTimeout and getNumActive() > getMaxActive() - 3 and getNumIdle() < 2
      Specified by:
        `borrowObject` in interface `ObjectPool<T extends AbandonedTrace>`
      Overrides:
        `borrowObject` in class `GenericObjectPool<T extends AbandonedTrace>`
      Returns:
        Object JDBC Connection
      Throws:
        `Exception` - if an exception occurs retrieving a connection from the pool

    - #### returnObject

          public void returnObject(T obj)
                            throws Exception

      Return a db connection to the pool.
      Specified by:
        `returnObject` in interface `ObjectPool<T extends AbandonedTrace>`
      Overrides:
        `returnObject` in class `GenericObjectPool<T extends AbandonedTrace>`
      Parameters:
        `obj` - db Connection to return
      Throws:
        `Exception` - if an exception occurs returning the connection to the pool

    - #### invalidateObject

          public void invalidateObject(T obj)
                                throws Exception

      Invalidates an object from the pool.
      Specified by:
        `invalidateObject` in interface `ObjectPool<T extends AbandonedTrace>`
      Overrides:
        `invalidateObject` in class `GenericObjectPool<T extends AbandonedTrace>`
      Parameters:
        `obj` - object to be returned
      Throws:
        `Exception` - if an exception occurs invalidating the object

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.