Interface IObjectPoolFactory<DATATYPE>

Type Parameters:
DATATYPE - the type of results supplied by this factory

public interface IObjectPoolFactory<DATATYPE>
An extended factory for objects in the ObjectPool.
Since:
11.1.0
Author:
Philip Helger
  • Method Details

    • create

      @Nonnull DATATYPE create()
      Create a new object for usage in the pool. This method is called if no object is in the pool, or if activation of a pooled object failed.
      Returns:
      A new object of data type. Never null.
    • activate

      Called when an existing object is borrowed from the pool. If activation failed, a new object will be created.
      Parameters:
      aItem - The item to be borrowed. Never null.
      Returns:
      ESuccess.SUCCESS if the object can be reused, ESuccess.FAILURE if not.
    • passivate

      void passivate(@Nonnull DATATYPE aItem)
      Called when an object is returned to the pool. This method has no return value - only activate(Object) can change the path.
      Parameters:
      aItem - The item to be returned. Never null.
    • wrap

      @Nonnull static <T> IObjectPoolFactory<T> wrap(@Nonnull Supplier<? extends T> aSupplier)
      Wrapper around Supplier to create an IObjectPoolFactory.
      Type Parameters:
      T - Type the object pool is supplying.
      Parameters:
      aSupplier - The supplier to wrap. May not be null.
      Returns:
      A new instance of IObjectPoolFactory.