Interface PooledObjectFactory<T>

    • Method Detail

      • activateObject

        void activateObject​(PooledObject<T> p)
                     throws java.lang.Exception
        Reinitializes an instance to be returned by the pool.
        Parameters:
        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(org.apache.tomcat.dbcp.pool2.PooledObject<T>)
      • destroyObject

        void destroyObject​(PooledObject<T> p)
                    throws java.lang.Exception
        Destroys an instance no longer needed by the pool, using the default (NORMAL) DestroyMode.

        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:
        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(org.apache.tomcat.dbcp.pool2.PooledObject<T>), ObjectPool.invalidateObject(T)
      • makeObject

        PooledObject<T> makeObject()
                            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.
        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​(PooledObject<T> p)
                      throws java.lang.Exception
        Uninitializes an instance to be returned to the idle object pool.
        Parameters:
        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(org.apache.tomcat.dbcp.pool2.PooledObject<T>)
      • validateObject

        boolean validateObject​(PooledObject<T> p)
        Ensures that the instance is safe to be returned by the pool.
        Parameters:
        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.