Package org.apache.camel.spi
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfacePooledObjectFactory.StatisticsUtilization statistics of the this factory.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Tacquire()Acquires an object from the pool (if any)intgetCapacity()The capacity the pool uses for storing objects.intgetSize()The current number of objects in the poolPooledObjectFactory.StatisticsgetStatistics()Gets the usage statisticsbooleanisPooled()Whether the factory is pooled.booleanisStatisticsEnabled()Whether statistics is enabled.voidpurge()Purges the internal cache (if pooled)booleanrelease(T t)Releases the object back to the poolvoidresetStatistics()Reset the statisticsvoidsetCapacity(int capacity)The capacity the pool uses for storing objects.voidsetStatisticsEnabled(boolean statisticsEnabled)Whether statistics is enabled.-
Methods inherited from interface org.apache.camel.CamelContextAware
getCamelContext, setCamelContext
-
-
-
-
Method Detail
-
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
PooledObjectFactory.Statistics 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
-
-