Class CommonsPool2TargetSource

    • Method Detail

      • setMaxIdle

        public void setMaxIdle​(int maxIdle)
        Set the maximum number of idle objects in the pool. Default is 8.
        See Also:
        GenericObjectPool.setMaxIdle(int)
      • getMaxIdle

        public int getMaxIdle()
        Return the maximum number of idle objects in the pool.
      • setMinIdle

        public void setMinIdle​(int minIdle)
        Set the minimum number of idle objects in the pool. Default is 0.
        See Also:
        GenericObjectPool.setMinIdle(int)
      • getMinIdle

        public int getMinIdle()
        Return the minimum number of idle objects in the pool.
      • setMaxWait

        public void setMaxWait​(long maxWait)
        Set the maximum waiting time for fetching an object from the pool. Default is -1, waiting forever.
        See Also:
        BaseGenericObjectPool.setMaxWaitMillis(long)
      • getMaxWait

        public long getMaxWait()
        Return the maximum waiting time for fetching an object from the pool.
      • setTimeBetweenEvictionRunsMillis

        public void setTimeBetweenEvictionRunsMillis​(long timeBetweenEvictionRunsMillis)
        Set the time between eviction runs that check idle objects whether they have been idle for too long or have become invalid. Default is -1, not performing any eviction.
        See Also:
        BaseGenericObjectPool.setTimeBetweenEvictionRunsMillis(long)
      • setMinEvictableIdleTimeMillis

        public void setMinEvictableIdleTimeMillis​(long minEvictableIdleTimeMillis)
        Set the minimum time that an idle object can sit in the pool before it becomes subject to eviction. Default is 1800000 (30 minutes).

        Note that eviction runs need to be performed to take this setting into effect.

        See Also:
        setTimeBetweenEvictionRunsMillis(long), BaseGenericObjectPool.setMinEvictableIdleTimeMillis(long)
      • setBlockWhenExhausted

        public void setBlockWhenExhausted​(boolean blockWhenExhausted)
        Set whether the call should bock when the pool is exhausted.
      • isBlockWhenExhausted

        public boolean isBlockWhenExhausted()
        Specify if the call should block when the pool is exhausted.
      • createObjectPool

        protected org.apache.commons.pool2.ObjectPool createObjectPool()
        Subclasses can override this if they want to return a specific Commons pool. They should apply any configuration properties to the pool here.

        Default is a GenericObjectPool instance with the given pool size.

        Returns:
        an empty Commons ObjectPool.
        See Also:
        GenericObjectPool, AbstractPoolingTargetSource.setMaxSize(int)
      • destroy

        public void destroy()
                     throws Exception
        Closes the underlying ObjectPool when destroying this object.
        Specified by:
        destroy in interface DisposableBean
        Throws:
        Exception - in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.
      • makeObject

        public org.apache.commons.pool2.PooledObject<ObjectmakeObject()
                                                                 throws Exception
        Specified by:
        makeObject in interface org.apache.commons.pool2.PooledObjectFactory<Object>
        Throws:
        Exception
      • destroyObject

        public void destroyObject​(org.apache.commons.pool2.PooledObject<Object> p)
                           throws Exception
        Specified by:
        destroyObject in interface org.apache.commons.pool2.PooledObjectFactory<Object>
        Throws:
        Exception
      • validateObject

        public boolean validateObject​(org.apache.commons.pool2.PooledObject<Object> p)
        Specified by:
        validateObject in interface org.apache.commons.pool2.PooledObjectFactory<Object>
      • activateObject

        public void activateObject​(org.apache.commons.pool2.PooledObject<Object> p)
                            throws Exception
        Specified by:
        activateObject in interface org.apache.commons.pool2.PooledObjectFactory<Object>
        Throws:
        Exception
      • passivateObject

        public void passivateObject​(org.apache.commons.pool2.PooledObject<Object> p)
                             throws Exception
        Specified by:
        passivateObject in interface org.apache.commons.pool2.PooledObjectFactory<Object>
        Throws:
        Exception