Hello,

I am using the commons pool for a project and would like only one object 
instance to be stored per key using the GenericKeyedObjectPool - is this 
actually possible?

The javadoc for KeyedObjectPool states that:
"KeyedObjectPool implementations may choose to store at most  one instance per 
key value, or may choose to maintain a pool of instances  for each key 
(essentially creating a Map of  pools)."

However, having looked in the codebase, the GenericKeyedObjectPool implements a 
linkedlist of objects, with no option for setting one object per key only...

Also, I am unable to subclass GenericKeyedObjectPool to alter the behaviour 
since the members are all private, so that is not an option.

Another option would be to add a custom implementation to my project, however 
certain member variables e.g. GenericObjectPool.EVICTION_TIMER are not visible, 
which procludes this approach. The only option would be to add a new class to 
the commons jar, which I am loathe to do since then it will not be compatible 
with future releases e.g. v2.

Many thanks for any feedback.

Cheerio,
Nic Hemley

       
---------------------------------
 Yahoo! Answers - Get better answers from someone who knows. Tryit now.

Reply via email to