Class PoolUtils.PoolableObjectFactoryAdaptor<K,​V>

  • All Implemented Interfaces:
    PoolableObjectFactory<V>
    Enclosing class:
    PoolUtils

    private static class PoolUtils.PoolableObjectFactoryAdaptor<K,​V>
    extends java.lang.Object
    implements PoolableObjectFactory<V>
    Adaptor class that wraps and converts a KeyedPoolableObjectFactory with a fixed key to a PoolableObjectFactory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateObject​(V obj)
      Activate the object, passing the fixed key to the factory.
      void destroyObject​(V obj)
      Destroy the object, passing the fixed key to the factory.
      V makeObject()
      Create an object instance using the configured factory and key.
      void passivateObject​(V obj)
      Passivate the object, passing the fixed key to the factory.
      java.lang.String toString()
      boolean validateObject​(V obj)
      Validate the object, passing the fixed key to the factory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • PoolableObjectFactoryAdaptor

        PoolableObjectFactoryAdaptor​(KeyedPoolableObjectFactory<K,​V> keyedFactory,
                                     K key)
                              throws java.lang.IllegalArgumentException
        Create a PoolableObjectFactoryAdaptor wrapping the provided KeyedPoolableObjectFactory with the given fixed key.
        Parameters:
        keyedFactory - KeyedPoolableObjectFactory that will manage objects
        key - fixed key
        Throws:
        java.lang.IllegalArgumentException - if either of the parameters is null
    • Method Detail

      • makeObject

        public V makeObject()
                     throws java.lang.Exception
        Create an object instance using the configured factory and key.
        Specified by:
        makeObject in interface PoolableObjectFactory<K>
        Returns:
        new object instance
        Throws:
        java.lang.Exception - if there is a problem creating a new instance, this will be propagated to the code requesting an object.
      • validateObject

        public boolean validateObject​(V obj)
        Validate the object, passing the fixed key to the factory.
        Specified by:
        validateObject in interface PoolableObjectFactory<K>
        Parameters:
        obj - object to validate
        Returns:
        true if validation is successful
      • activateObject

        public void activateObject​(V obj)
                            throws java.lang.Exception
        Activate the object, passing the fixed key to the factory.
        Specified by:
        activateObject in interface PoolableObjectFactory<K>
        Parameters:
        obj - object to activate
        Throws:
        java.lang.Exception - if there is a problem activating obj, this exception may be swallowed by the pool.
        See Also:
        PoolableObjectFactory.destroyObject(T)
      • passivateObject

        public void passivateObject​(V obj)
                             throws java.lang.Exception
        Passivate the object, passing the fixed key to the factory.
        Specified by:
        passivateObject in interface PoolableObjectFactory<K>
        Parameters:
        obj - object to passivate
        Throws:
        java.lang.Exception - if there is a problem passivating obj, this exception may be swallowed by the pool.
        See Also:
        PoolableObjectFactory.destroyObject(T)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object