cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: ThreadSafe Transformers
Date Wed, 22 Sep 2004 20:12:35 GMT
Vadim Gritsenko wrote:

> Y'all,
>
> Some time ago I remember discussions about making transformers 
> threadsafe, major changes, about Cocoon 3, etc. Yesterday it occured 
> to me that Transformers can easily be made ThreadSafe with only 
> additions to current Cocoon architecture without any major rewrites. 
> It can be done in this way:
>
> Add new interface marking threadsafe transformer:
>     public interface TransformerFactory {
>         Transformer getTransformer();
>     }
>
> Override select method in ComponentSelector:
>     public Component select(Object hint) throws ComponentException {
>         Component component = super.select(hint);
>         if (this.roleId == TRANSFORMER) {
>             if (component instanceof TransformerFactory) {
>                 return ((TransformerFactory)component).getTransformer();
>             }
>         }
>
>         return component;
>     }
> (it is in org.apache.cocoon.components.treeprocessor.sitemap package)


Hey, nice hack!

We could even go further by having the ExtendedComponentSelector handle 
components implementing an ObjectFactory interface. That way, we 
potentially can use it for any kind of component.

<snip/>

> Now question; is it a good idea to check in this code into 2.2? Any 
> drawbacks of this approach?


I like it. The selector hack is the piece that was missing to the puzzle 
to implement it in a simple way.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Mime
View raw message