Tobias Bocanegra wrote:
-1 using thread local is very dangerous and can cause memory leaks
Yes, thread locals can cause memory leaks if you haven't developed your
code carefully :) But they are not a memory leak per se.
i strongly recommend to reconsider this approach. whenever i
encountered the problem that i need a resource resolver but did't had
the request handy - it was a flaw in my architecture of my classes.
:) Now, this assumes one of three things, I guess:
a) your code never needs a resource resolver
b) your code needs a resource resolver and you pass it all the way down
through all invoked methods
c) your code needs a resource resolver and you pass the request all the
way down
We had a similar problem in Cocoon. In most use cases people needed a
resource resolver and in the beginning they could only do b) or c) which
lead to very very ugly interfaces and method calls. The resulting code
was barely usable outside of a request.
Then we introduced the thread locals with a service on top hiding the
fact that a thread local was used underneath - and this lead to cleaner
code and better design in the end.
And we had memory problems with these thread locals once in six years,
but this was detected very quickly and could be fixed easily. :)
Carsten
--
Carsten Ziegeler
[EMAIL PROTECTED]