Interface KeyedPooledObjectFactory<K,​V>

    • Method Detail

      • activateObject

        void activateObject​(K key,
                            PooledObject<V> p)
                     throws java.lang.Exception
        Reinitializes an instance to be returned by the pool.
        Parameters:
        key - the key used when selecting the object
        p - a PooledObject wrapping the instance to be activated
        Throws:
        java.lang.Exception - if there is a problem activating obj, this exception may be swallowed by the pool.
        See Also:
        destroyObject(K, org.apache.tomcat.dbcp.pool2.PooledObject<V>)
      • destroyObject

        void destroyObject​(K key,
                           PooledObject<V> p)
                    throws java.lang.Exception
        Destroys an instance no longer needed by the pool.

        It is important for implementations of this method to be aware that there is no guarantee about what state obj will be in and the implementation should be prepared to handle unexpected errors.

        Also, an implementation must take in to consideration that instances lost to the garbage collector may never be destroyed.

        Parameters:
        key - the key used when selecting the instance
        p - a PooledObject wrapping the instance to be destroyed
        Throws:
        java.lang.Exception - should be avoided as it may be swallowed by the pool implementation.
        See Also:
        validateObject(K, org.apache.tomcat.dbcp.pool2.PooledObject<V>), KeyedObjectPool.invalidateObject(K, V)
      • makeObject

        PooledObject<V> makeObject​(K key)
                            throws java.lang.Exception
        Creates an instance that can be served by the pool and wrap it in a PooledObject to be managed by the pool.
        Parameters:
        key - the key used when constructing the object
        Returns:
        a PooledObject wrapping an instance that can be served by the pool.
        Throws:
        java.lang.Exception - if there is a problem creating a new instance, this will be propagated to the code requesting an object.
      • passivateObject

        void passivateObject​(K key,
                             PooledObject<V> p)
                      throws java.lang.Exception
        Uninitializes an instance to be returned to the idle object pool.
        Parameters:
        key - the key used when selecting the object
        p - a PooledObject wrapping the instance to be passivated
        Throws:
        java.lang.Exception - if there is a problem passivating obj, this exception may be swallowed by the pool.
        See Also:
        destroyObject(K, org.apache.tomcat.dbcp.pool2.PooledObject<V>)
      • validateObject

        boolean validateObject​(K key,
                               PooledObject<V> p)
        Ensures that the instance is safe to be returned by the pool.
        Parameters:
        key - the key used when selecting the object
        p - a PooledObject wrapping the instance to be validated
        Returns:
        false if obj is not valid and should be dropped from the pool, true otherwise.