Interface PooledObjectFactory<T>

All Superinterfaces:
AutoCloseable, CamelContextAware, Service
All Known Subinterfaces:
ExchangeFactory, ProcessorExchangeFactory

public interface PooledObjectFactory<T> extends Service, CamelContextAware
Factory for pooled objects or tasks.
  • Method Details

    • getSize

      int getSize()
      The current number of objects in the pool
    • getCapacity

      int getCapacity()
      The capacity the pool uses for storing objects. The default capacity is 100.
    • setCapacity

      void setCapacity(int capacity)
      The capacity the pool uses for storing objects. The default capacity is 100.
    • isStatisticsEnabled

      boolean isStatisticsEnabled()
      Whether statistics is enabled.
    • setStatisticsEnabled

      void setStatisticsEnabled(boolean statisticsEnabled)
      Whether statistics is enabled.
    • resetStatistics

      void resetStatistics()
      Reset the statistics
    • purge

      void purge()
      Purges the internal cache (if pooled)
    • getStatistics

      Gets the usage statistics
      Returns:
      the statistics, or null if statistics is not enabled
    • isPooled

      boolean isPooled()
      Whether the factory is pooled.
    • acquire

      T acquire()
      Acquires an object from the pool (if any)
      Returns:
      the object or null if the pool is empty
    • release

      boolean release(T t)
      Releases the object back to the pool
      Parameters:
      t - the object
      Returns:
      true if released into the pool, or false if something went wrong and the object was discarded