« Return to Thread: [2.2] ThreadLocal use in PoolableProxyHandler

Re: [2.2] ThreadLocal use in PoolableProxyHandler

by cziegeler :: Rate this Message:

Reply to Author | View in Thread

Alexander Daniel wrote
>
> PoolableFactoryBean [2] creates a new PoolableProxyHandler instance [1]
> for each pooled component used in a pipeline, i.e. it will not be shared
> across different requests. Therefore I do not understand the use of
> ThreadLocal.
Yes, you're right for sitemap components - but this isn't true for any
other component. Imagine a singleton component using a poolable. The
singleton is used by multiple threads and therefore each thread
requires an own instance

Now, this is not optimal and actually it's legacy code - it is only used
for old Avalon components.

Carsten

>
> Alex
>
> [1]
>     public Object getObject() throws Exception {
>         return Proxy.newProxyInstance(this.getClass().getClassLoader(),
>                                       this.interfaces,
>                                       new PoolableProxyHandler(this));
>     }
>
> [2]
> 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
>
>


--
Carsten Ziegeler
cziegeler@...

 « Return to Thread: [2.2] ThreadLocal use in PoolableProxyHandler