Class ObjectPool<T>

    • Field Detail

      • WHEN_EXHAUSTED_FAIL

        public static final int WHEN_EXHAUSTED_FAIL
        Exhaustion policies
        See Also:
        Constant Field Values
      • WHEN_EXHAUSTED_RETURN_NULL

        public static final int WHEN_EXHAUSTED_RETURN_NULL
        See Also:
        Constant Field Values
      • WHEN_EXHAUSTED_WAIT_RETURN_NULL

        public static final int WHEN_EXHAUSTED_WAIT_RETURN_NULL
        See Also:
        Constant Field Values
    • Constructor Detail

      • ObjectPool

        public ObjectPool​(int minSize,
                          int maxIdle,
                          int maxSize,
                          int exhaustionPolicy,
                          long waitTimeout)
                   throws javax.jms.JMSException
        Constructor
        Throws:
        javax.jms.JMSException
    • Method Detail

      • init

        protected void init()
                     throws javax.jms.JMSException
        Throws:
        javax.jms.JMSException
      • borrow

        public T borrow()
                 throws javax.jms.JMSException
        Borrow an object from the pool
        Returns:
        a pooled object
        Throws:
        javax.jms.JMSException
      • release

        public void release​(T poolObject)
        Return an object to the pool
        Parameters:
        poolObject - a pooled object to be returned
      • close

        public void close()
        Close the pool, destroying all objects
      • createPoolObject

        protected abstract T createPoolObject()
                                       throws Exception
        Create a new pool object
        Returns:
        an new pool object
        Throws:
        Exception - on creation error
      • destroyPoolObject

        protected abstract void destroyPoolObject​(T poolObject)
                                           throws Exception
        Destroy a pool object
        Parameters:
        poolObject - the object to destroy
        Throws:
        Exception - on release error
      • exhaustionPolicyAsString

        public static String exhaustionPolicyAsString​(int exhaustionPolicy)