commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz (Jira)" <>
Subject [jira] [Comment Edited] (POOL-321) ObjectPool.addObject limiting us to add an object with parameter
Date Sun, 06 Oct 2019 15:56:00 GMT


Phil Steitz edited comment on POOL-321 at 10/6/19 3:55 PM:

Assuming the parameter is needed only for object creation and objects created with different
actual parameters function the same in the pool (i.e. borrow does not take a parameter), I
can see two ways to do this.
 # Add an addObject<T> method that allows the user to supply an object to be added to
the pool.  The client can then extend or circumvent the factory to create instances with
 # Create a ParameterizedObjectPool that has a second generic type, like GenericKeyedObjectPool,
but the type functions as the parameter used by the object factory.  To be consistent with
the current design, this would be implemented as one of the pools provided by PoolUtils.

Patches welcome!

was (Author: psteitz):
The problem with this is that the parameter needs to be passed to the factory and the pool
would have to know about the signature or use some type-weak method of passing parameters
via JSON or somesuch.  How about adding an addObject(T) that takes an instance of the class
of objects under management?  Client code can then extend the factory to create instances
with whatever parameters are desired and then use this method to get them added to the pool.

> ObjectPool.addObject limiting us to add an object with parameter
> ----------------------------------------------------------------
>                 Key: POOL-321
>                 URL:
>             Project: Commons Pool
>          Issue Type: Improvement
>    Affects Versions: 2.4
>            Reporter: Ugur Bayram
>            Priority: Major
>             Fix For: 2.7.1
> In current implementation we are not able to add an object with parameter to the pool.
addObject does not take any parameter
> Consider of a user pool where the content of each user might differ. In such cases, current
implementation have limitation. 

This message was sent by Atlassian Jira

View raw message