Interface PooledObjectFactory<T>

    • Method Detail

      • destroyObject

        void destroyObject​(PooledObject<T> p)
                    throws 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:
        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 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:
        Exception - if there is a problem creating a new instance, this will be propagated to the code requesting an object.
      • 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.