Class GenericPool

  • All Implemented Interfaces:
    IPool

    public class GenericPool
    extends java.lang.Object
    implements IPool
    A very simple implementation of a generic IPool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void activateObject​(java.lang.Object object)  
      protected void assertOpen()  
      void checkin​(java.lang.Object object)
      Add an object to the pool.
      java.lang.Object checkout​(long timeout)
      Get an object from the pool.
      void close()
      Close the pool.
      protected java.lang.Object createObject()  
      protected void deactivateObject​(java.lang.Object object)  
      void destroy​(java.lang.Object object)
      Destroy an object previously allocated from the pool.
      protected void destroyObject​(java.lang.Object object)  
      protected boolean isClosed()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkin

        public void checkin​(java.lang.Object object)
                     throws java.lang.Exception
        Description copied from interface: IPool
        Add an object to the pool.
        Specified by:
        checkin in interface IPool
        Parameters:
        object - The object to be added to the pool.
        Throws:
        java.lang.Exception
      • deactivateObject

        protected void deactivateObject​(java.lang.Object object)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • destroyObject

        protected void destroyObject​(java.lang.Object object)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • isClosed

        protected boolean isClosed()
      • assertOpen

        protected void assertOpen()
      • checkout

        public java.lang.Object checkout​(long timeout)
                                  throws java.lang.Exception
        Description copied from interface: IPool
        Get an object from the pool.

        This may be a reused object or a new one, up to the pool strategy and size.

        Specified by:
        checkout in interface IPool
        Parameters:
        timeout - The maximum time to wait for an instance to be available in milliseconds. -1 will wait indefinitely, 0 will not wait.
        Returns:
        A new object from the pool.
        Throws:
        java.lang.Exception
      • activateObject

        protected void activateObject​(java.lang.Object object)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createObject

        protected java.lang.Object createObject()
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • close

        public void close()
                   throws java.lang.Exception
        Description copied from interface: IPool
        Close the pool.
        Specified by:
        close in interface IPool
        Throws:
        java.lang.Exception
      • destroy

        public void destroy​(java.lang.Object object)
                     throws java.lang.Exception
        Description copied from interface: IPool
        Destroy an object previously allocated from the pool.
        Specified by:
        destroy in interface IPool
        Parameters:
        object - The object to be destroyed.
        Throws:
        java.lang.Exception