Thanks Stephen, 

I've already started implementing something like this using
commons-pool, and your recommendation helps crystallize my thoughts
considerably.

Regards,

Peter

On Wed, 2004-01-07 at 17:36, Stephen McConnell wrote:
> Peter Courcoux wrote:
> > Hi all,
> > 
> > I have a requirement for pooling components and am using a version of
> > merlin which is a couple of months old. I seem to recall that the pooled
> > lifestyle handling was switched off. Is this still the case and if so,
> > is there a recommended pattern for providing pooled components?
> 
> Correct.
> 
> Based on discussion on this subject over the last six months - my 
> conclusion is that the related semantics area for all intensive purposes 
> a rather gray area.  This is primarily related to strong relationship 
> between pool and the components it manages (in particular things like 
> recycling strategies), and subtle relationships between a component that 
> is using a pooled component and the pool itself.
> 
> My recommendation concerning pooled components is:
> 
>     1. declare a factory service with formal instance acquisition
>        and release methods .. e.g.
> 
>          public interface WidgetPool
>          {
>              Widget aquireWidget();
>              void releaseWidget( Widget widget );
>          }
> 
>     2. implement a component the exposes the pooled interface as a
>        service using whatever pool technology you like (excalibur,
>        commons pool, etc.)
> 
>         /**
>          * @avalon.service type="WidgetPool"
>          */
>          public class DefaultWidgetPool implements WidgetPool
>          {
>              ...
>          }
> 
>     3. for consumer components, declare a dependency on the pool
>        directly
> 
>         /**
>          * @avalon.dependency key="pool" type="WidgetPool"
>          */
>          public void service( ServiceManager manager )
>            throws ServiceException
>          {
>               m_pool = (WidgetPool) manager.lookup( "pool" );
>          }
> 
> Using this approach you component implementation is crystal clear about 
> the assumptions concerning the WidgetPool and your implementation can be 
> much more strict about acquisition and release policies.
> 
> Hope that helps.
> 
> Cheers, Stephen.
> 
> 
> > 
> > I will be grateful for any thoughts.
> > 
> > Many thanks.
> > 
> > Peter
-- 
Peter Courcoux <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to