You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Carsten Ziegeler <cz...@s-und-n.de> on 2002/09/26 15:29:01 UTC

Does Component Handling always work ?

Hi,

sorry for this question - but I'm currently totally confused
if the avalon concepts (4.x) always work as expected. (I hope they do...)

Example: I have two components, one being ThreadSafe and one Poolable
component which is of course not ThreadSafe.

Now, the ThreadSafe component looks up the Poolable one, lets say
in the compose() method and stores this instance for the whole
lifetime.

Does this work properly? I would assume that now the Poolable
component is used as a ThreadSafe one. Is this right?
Or do I oversee something?

Regards
Carsten

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Does Component Handling always work ?

Posted by Berin Loritsch <bl...@apache.org>.
Carsten Ziegeler wrote:
> Hi,
> 
> sorry for this question - but I'm currently totally confused
> if the avalon concepts (4.x) always work as expected. (I hope they do...)
> 
> Example: I have two components, one being ThreadSafe and one Poolable
> component which is of course not ThreadSafe.
> 
> Now, the ThreadSafe component looks up the Poolable one, lets say
> in the compose() method and stores this instance for the whole
> lifetime.
> 
> Does this work properly? I would assume that now the Poolable
> component is used as a ThreadSafe one. Is this right?
> Or do I oversee something?

That component is now being referenced by the ThreadSafe one for the
duration.  It is not really a good thing.  If there is the slightest
chance that a component might be transient (poolable or singlethreaded)
then you have to grab a new instance each time you need to use it.

-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Does Component Handling always work ?

Posted by Leo Sutic <le...@inspireinfrastructure.com>.

> From: Carsten Ziegeler [mailto:cziegeler@s-und-n.de] 
> 
> Hi,
> 
> sorry for this question - but I'm currently totally confused
> if the avalon concepts (4.x) always work as expected. (I hope 
> they do...)
> 
> Example: I have two components, one being ThreadSafe and one 
> Poolable component which is of course not ThreadSafe.
> 
> Now, the ThreadSafe component looks up the Poolable one, lets 
> say in the compose() method and stores this instance for the 
> whole lifetime.
> 
> Does this work properly? I would assume that now the Poolable 
> component is used as a ThreadSafe one. Is this right? Or do I 
> oversee something?

That should work as expected (?), meaning that the threadsafe component
*has* to provide the synchronization for the poolable component.
That is, if two threads concurrently access the ThreadSafe component,
they must not be allowed to access the poolable component 
simultaneously.

/LS


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Does Component Handling always work ?

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Peter Royal wrote:
> 
> On Thursday, September 26, 2002, at 09:29  AM, Carsten Ziegeler wrote:
> > Example: I have two components, one being ThreadSafe and one Poolable
> > component which is of course not ThreadSafe.
> >
> > Now, the ThreadSafe component looks up the Poolable one, lets say
> > in the compose() method and stores this instance for the whole
> > lifetime.
> >
> > Does this work properly? I would assume that now the Poolable
> > component is used as a ThreadSafe one. Is this right?
> > Or do I oversee something?
> 
> Yes, you are correct. The single Poolable component you got will be 
> used for all calls to the ThreadSafe component.
> 
> For Poolable components, each call to ComponentManager.lookup() will 
> return you a component instance from the pool.
> 
> For the above example, since each call to a ThreadSafe component's 
> methods are generally stateless, you would probably want to lookup() 
> and release() a new Poolable in each method call.

Thanks, I'm glad that I'm not insane or too paranoid, but...the great
thing about Avalon and the lifecycle interfaces is of course that as
a user of the components I don't have to care about wheter a component
is thread safe or not...

So if I write myself a ThreadSafe component I have to take care that
I do a lookup/release each time I use another component because I
never know if that one is ThreadSafe or not. (I there comes the
same answer from Berin. Thanks Berin).

Ok, so this important statemtent should be documented somewhere.

Thanks all, now I can go and check all my ThreadSafe components...

Regards
Carsten

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Does Component Handling always work ?

Posted by Peter Royal <pr...@apache.org>.
On Thursday, September 26, 2002, at 09:29  AM, Carsten Ziegeler wrote:
> Example: I have two components, one being ThreadSafe and one Poolable
> component which is of course not ThreadSafe.
>
> Now, the ThreadSafe component looks up the Poolable one, lets say
> in the compose() method and stores this instance for the whole
> lifetime.
>
> Does this work properly? I would assume that now the Poolable
> component is used as a ThreadSafe one. Is this right?
> Or do I oversee something?

Yes, you are correct. The single Poolable component you got will be 
used for all calls to the ThreadSafe component.

For Poolable components, each call to ComponentManager.lookup() will 
return you a component instance from the pool.

For the above example, since each call to a ThreadSafe component's 
methods are generally stateless, you would probably want to lookup() 
and release() a new Poolable in each method call.
-pete

-- 
peter royal -> proyal@apache.org


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>