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

RE: FragmentExtractor getting and releasing Store every time?

The safest way is to lookup/release a component every time you
need it, so the fragmentextractor uses the "correct" approach.
If you know that the component you want to use is ThreadSafe
and will always be ThreadSafe than you can optimize your code
and lookup the component only once - this optimization has been
done in the xslttransformer.

Carsten

> -----Original Message-----
> From: Torsten Knodt [mailto:torstenknodt@datas-world.de]
> Sent: Friday, May 30, 2003 9:30 PM
> To: cocoon-dev@xml.apache.org
> Subject: FragmentExtractor getting and releasing Store every time?
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
> I've looked for an example to get a TRANSIENT_STORE and decided
> to take the
> FragmentExtractor. There I found something strange for me. Why is
> the store
> taken and released from the ComponentManager every time it needs
> it. Wouldn't
> it be better to get it in compose and release it in dispose? Or have I
> understood something wrong. XSLTProcessorImpl in excalibur does it like I
> think it would be right.
>
> Regards
> 	Torsten
> - --
> Domain in provider transition, hope for smoothness. Planed date
> is 1.7.2003.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.2 (GNU/Linux)
>
> iD4DBQE+17UHvxZktkzSmiwRAorYAJ9oe6t7R5cdjD+uSi6kJ4r5DlRAIACY+qwv
> SDl8/xAzTQ471PFsXrxUpQ==
> =NGPK
> -----END PGP SIGNATURE-----
>


RE: FragmentExtractor getting and releasing Store every time?

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Vadim Gritsenko wrote:
> >Now, the optimization I was refering to can only take place *if* you
> >know which implementation for a component is really used and *if*
> >this specific implementation is ThreadSafe. This is a dangerous
> >assumption! If you assume a component is implemented in a thread safe
> >manner and this changes sometime and you don't reflect these changes
> >than you will quickly result in threading problems.
> >
> 
> Not in this case though. I think you forgot that XSLTProcessor is 
> Recyclable, and not ThreadSafe.
> 
no :) - my comment was meant in general and not targetted at the store,
but yes, you're right, it's only dangerous if the own component is 
ThreadSafe.

Carsten

Re: FragmentExtractor getting and releasing Store every time?

Posted by Vadim Gritsenko <va...@verizon.net>.
Carsten Ziegeler wrote:

>Torsten Knodt wrote:
>  
>
>>On Sunday 01 June 2003 15:51, Carsten Ziegeler wrote:
>>CZ> The safest way is to lookup/release a component every time you
>>CZ> need it, so the fragmentextractor uses the "correct" approach.
>>CZ> If you know that the component you want to use is ThreadSafe
>>CZ> and will always be ThreadSafe than you can optimize your code
>>CZ> and lookup the component only once - this optimization has been
>>CZ> done in the xslttransformer.
>>XSLTProcessorImpl uses Store.TRANSIENT_STORE, like the
>>FragmentExtractor. I
>>haven't mentioned this explicitly.
>>I have looked into the interfaces, and when I understand right, I
>>had to look,
>>if store implements ThreadSafe. Store doesn't implement
>>ThreadSafe, but the
>>MRUMemoryStore, which is used as default in cocoon. So I'd say
>>it's a bug in
>>XSLTProcessorImpl. Agreed? 
>>

No.


>>What I would do, is asking in avalon-users for
>>changing XSLTProcessorImpl and perhaps others or to have Store implement
>>ThreadSafe. But I guess, Store is already released.
>>    
>>
>
>We have to distinguish between the component (it's interface) and the
>implementation. The interface should never expose details about the
>implementation, so an implementation detail like ThreadSafe etc. is
>not part of the interface which in this case is Store.
>
>However, the implementation "decides" if it is thread safe, poolable
>or whatever.
>
>Now, the optimization I was refering to can only take place *if* you
>know which implementation for a component is really used and *if*
>this specific implementation is ThreadSafe. This is a dangerous
>assumption! If you assume a component is implemented in a thread safe
>manner and this changes sometime and you don't reflect these changes
>than you will quickly result in threading problems.
>

Not in this case though. I think you forgot that XSLTProcessor is 
Recyclable, and not ThreadSafe.

Vadim



RE: FragmentExtractor getting and releasing Store every time?

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Torsten Knodt wrote:
> On Sunday 01 June 2003 15:51, Carsten Ziegeler wrote:
> CZ> The safest way is to lookup/release a component every time you
> CZ> need it, so the fragmentextractor uses the "correct" approach.
> CZ> If you know that the component you want to use is ThreadSafe
> CZ> and will always be ThreadSafe than you can optimize your code
> CZ> and lookup the component only once - this optimization has been
> CZ> done in the xslttransformer.
> XSLTProcessorImpl uses Store.TRANSIENT_STORE, like the
> FragmentExtractor. I
> haven't mentioned this explicitly.
> I have looked into the interfaces, and when I understand right, I
> had to look,
> if store implements ThreadSafe. Store doesn't implement
> ThreadSafe, but the
> MRUMemoryStore, which is used as default in cocoon. So I'd say
> it's a bug in
> XSLTProcessorImpl. Agreed? What I would do, is asking in avalon-users for
> changing XSLTProcessorImpl and perhaps others or to have Store implement
> ThreadSafe. But I guess, Store is already released.

We have to distinguish between the component (it's interface) and the
implementation. The interface should never expose details about the
implementation, so an implementation detail like ThreadSafe etc. is
not part of the interface which in this case is Store.

However, the implementation "decides" if it is thread safe, poolable
or whatever.

Now, the optimization I was refering to can only take place *if* you
know which implementation for a component is really used and *if*
this specific implementation is ThreadSafe. This is a dangerous
assumption! If you assume a component is implemented in a thread safe
manner and this changes sometime and you don't reflect these changes
than you will quickly result in threading problems.

Carsten


Re: FragmentExtractor getting and releasing Store every time?

Posted by Torsten Knodt <to...@datas-world.de>.
On Sunday 01 June 2003 15:51, Carsten Ziegeler wrote:
CZ> The safest way is to lookup/release a component every time you
CZ> need it, so the fragmentextractor uses the "correct" approach.
CZ> If you know that the component you want to use is ThreadSafe
CZ> and will always be ThreadSafe than you can optimize your code
CZ> and lookup the component only once - this optimization has been
CZ> done in the xslttransformer.
XSLTProcessorImpl uses Store.TRANSIENT_STORE, like the FragmentExtractor. I 
haven't mentioned this explicitly.
I have looked into the interfaces, and when I understand right, I had to look, 
if store implements ThreadSafe. Store doesn't implement ThreadSafe, but the 
MRUMemoryStore, which is used as default in cocoon. So I'd say it's a bug in 
XSLTProcessorImpl. Agreed? What I would do, is asking in avalon-users for 
changing XSLTProcessorImpl and perhaps others or to have Store implement 
ThreadSafe. But I guess, Store is already released.

Regard
	Torsten
-- 
Domain in provider transition, hope for smoothness. Planed date is 1.7.2003.