On Tue, 3 Apr 2001, Peter Donald wrote:

> Another way to do it which I like a little more as it is easier on user of
> pool is the following.
> 
> final ObjectFactory objectFactory = new SomeObjectFactory();
> final Pool pool = new DefaultPool( ..., objectFactory, ... );
> 
> //If pool empty then objectfactory will be called
> Object o = pool.get( )

Yes, I know - or the ( almost equivalent ) PoolListener.poolEmptyEvent() 
( and the pool user may add more objects to the pool ).

All are valid solutions - each has advantages and some problems. 

Using class.forName/newInstance is the one I like the least. A factory is
fine ( but I don't think of a pool as a factory - or a facade to a
factory, there are different patterns, a cache shouldn't create objects ).
My preference is the Listener/Event, but that may have an extra overhead 
and be more complex ( but it allow other objects to monitor the pool ).

But my argument is that we shouldn't impose ( as a "standard" for pools ) 
one solution or another or try to create a pool that does all. Sometimes
"simpler" is better.


Costin
 



Reply via email to