On 03.07.2009, at 10:41, Carsten Ziegeler wrote:
Alexander Daniel wrote:
Does somebody know why ThreadLocal is used in PoolableProxyHandler
[1]
for the componentHolder in Cocoon 2.2?
Sure :)
Whenever components are taken out of the pool they need to be put back
somehow, so they are available for other clients again.
We use a thread local which is cleared when the request finishes,
so all used components get back into the pool.
Thanks for the answer Carsten. What you describe is done by the
destruction callback mechanism of Spring. But why can't we simply use
a direct reference [2] to the component? Why is a ThreadLocal used as
key to the component?
Alex
[2] private Object component = null;
[1]
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/PoolableFactoryBean.java