Search code examples
javaapache-commonspool

Java apache.commons.pool : How to set a maximum idle time for the objects from the pool?


I am programming a pool with apache.commons.pool, and one of the requisites is that there is a maximum idle time. If the object is idle for more than that time, it must be destroyed calling a method. I have been looking the Api for quite a long time, and I don't find any class /interface that says anything in that way. Do I have to program it myself? Or is it anything there that I am missing?

Thanks for your time!


Solution

  • Ok, auto answer ;-p

    There are fields in the implementations that control exactly that. For example, in the implementation GenericObjectPool, there is the field DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS that says how much time can be an idle object in the pool before being eligible for eviction.

    Have to drink more coffe before starting reading Apis ;-p