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
Modifier and TypeInterfaceDescriptionstatic interface
Utilization statistics of the this factory. -
Method Summary
Modifier and TypeMethodDescriptionacquire()
Acquires an object from the pool (if any)int
The capacity the pool uses for storing objects.int
getSize()
The current number of objects in the poolGets the usage statisticsboolean
isPooled()
Whether the factory is pooled.boolean
Whether statistics is enabled.void
purge()
Purges the internal cache (if pooled)boolean
Releases the object back to the poolvoid
Reset the statisticsvoid
setCapacity
(int capacity) The capacity the pool uses for storing objects.void
setStatisticsEnabled
(boolean statisticsEnabled) Whether statistics is enabled.Methods inherited from interface org.apache.camel.CamelContextAware
setCamelContext
Methods 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
-