At 12:25  2/4/01 -0700, [EMAIL PROTECTED] wrote:
>One problem is with the pool acting as factory for the pooled
>objects. It may looks simple ( Class.forName, newInstance) but it's not
>allways simple ( what if you need another class loader ? special
>constructor ? ).

Agreed - theres huge probalems with that (ie see Cocoon/Avalon/Phoenix).

>The solution we use ( in tc3 ) is to leave the pool deal with pooling, and
>have the caller deal with creating new objects, i.e.
>
>Pool { 
>  Object get();
>  void put( Object );
>} 
>
>User:
>
>  Object o=pool.get();
>  if( o==null ) {
>    // create
>  }
>  ...
>  pool.put(o);

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( )


Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*

Reply via email to