Interface ObjectFactory<K extends ObjectKey,​V,​I>


  • public interface ObjectFactory<K extends ObjectKey,​V,​I>
    The interface represents a factory to create, validate, activate, passivate, close poolable objects.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void activateObject​(K key, V object, I info)
      When idle object is borrowed by the given key it's activated before returning from the pool.
      void closeObject​(K key, V object, I info)
      Closes physical object and releases any associated resources.
      V createObject​(K key, I info)
      When no idle objects are available in the pool under given object key, the object pool invokes this method to create new object instance.
      boolean passivateObject​(K key, V object, I info)
      Object is passivated before object is returned to the pool.
      boolean validateObject​(K key, V object, I info)
      Before returning object to pool or after validation interval has passed the object can be validated for correctness, such as check for not being stale, out-dated or corrupted.
    • Method Detail

      • createObject

        V createObject​(K key,
                       I info)
                throws Exception
        When no idle objects are available in the pool under given object key, the object pool invokes this method to create new object instance.
        Parameters:
        key - object key to construct new poolable object
        info - additional info
        Returns:
        newly constructed object
        Throws:
        Exception - if object can't be constructed
      • validateObject

        boolean validateObject​(K key,
                               V object,
                               I info)
        Before returning object to pool or after validation interval has passed the object can be validated for correctness, such as check for not being stale, out-dated or corrupted.
        Parameters:
        key - object key to validate provided object
        object - to validate
        info - additional info
        Returns:
        true if object is valid or false if object is state, out-dated or corrupted
      • activateObject

        void activateObject​(K key,
                            V object,
                            I info)
                     throws Exception
        When idle object is borrowed by the given key it's activated before returning from the pool.
        Parameters:
        key - object key to activate provided object
        object - to activate
        info - additional info
        Throws:
        Exception - if object can't be activated
      • passivateObject

        boolean passivateObject​(K key,
                                V object,
                                I info)
        Object is passivated before object is returned to the pool.
        Parameters:
        key - object key to activate provided object
        object - to passivate
        info - additional info
        Returns:
        boolean true if passivate succeded. false if it failed
      • closeObject

        void closeObject​(K key,
                         V object,
                         I info)
        Closes physical object and releases any associated resources.
        Parameters:
        key - object key of the object to close
        object - to close
        info - additional info