Package org.apache.camel.spi
Interface PooledObjectFactory<T>
- All Superinterfaces:
AutoCloseable,CamelContextAware,HasCamelContext,Service
- All Known Subinterfaces:
ExchangeFactory,ProcessorExchangeFactory
Factory for pooled objects or tasks.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceUtilization statistics of the this factory. -
Method Summary
Modifier and TypeMethodDescriptionacquire()Acquires an object from the pool (if any)intThe capacity the pool uses for storing objects.intgetSize()The current number of objects in the poolGets the usage statisticsbooleanisPooled()Whether the factory is pooled.booleanWhether statistics is enabled.voidpurge()Purges the internal cache (if pooled)booleanReleases the object back to the poolvoidReset 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
setCamelContextMethods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContext
-
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
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
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
-