cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@sundn.de>
Subject AW: single instance per context on avalon components
Date Mon, 01 Oct 2001 06:23:39 GMT
This is actually I feature I am looking for since weeks, but had never
time to finish it....

There is of course the ThreadSafe interface from Avalon, but then
you have only one single instance in the whole system. That's not
suitable for many cases.

I would like to add a Cocoon-specific marker interface, similar
to the SitemapModelComponent  interface (but a different name)
>>>
public interface RequestModelComponent extends Component {
    /**
     * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
     * the source and sitemap <code>Parameters</code> used to process the
request.
     */
    void setup(SourceResolver resolver, Map objectModel) throws
ProcessingException;
}
<<<<

The behaviour for this would be:
- The first time during a request processing a component marked with
  this interface is looked up, a new instance is created (or got from
  the pool) and the setup method is called. This object is stored
  somewhere so that the ComponentManager has access to it for later
  requests.
- The second, third.. time during the same request this component is
  looked up, it is get from the store and the setup() method is
  not looked up
- Every time a release is called on this object, nothing really happens
- When the request processing is finished, the ComponentManager
  must really release all stored objects.

So actually objects marked in this way are more or less ThreadSafe
but per request exists a different instance.

I didn't look much more in the Avalon code, but I thought, implementing
an own ComponentManager which does exactly this behaviour in the
lookup and release methods would be simply enough.

Your thoughts?


Carsten

Open Source Group                        sunShine - b:Integrated
================================================================
Carsten Ziegeler, S&N AG, Klingenderstrasse 5, D-33100 Paderborn
www.sundn.de                          mailto: cziegeler@sundn.de
================================================================


> Stefano Mazzocchi
>
> Working for finishing up the gallery code, I've come into the need to
> share the instance of an avalon component between two cocoon pipeline
> components, respectively a transformer and a generator.
>
> This is the same need of the FragmentExtractor generator/transformer
> pair: one collects information at transformation stage and stores this
> information for later retrieval at generation stage. It's not a common
> need, but I assume this will turn out very useful for complex operations
> like pagination and path expansion (which is why I need this).
>
> So, my code compiles and does what it should: the problem is that the
> two sitemap components (the generator and the transformer) get two
> different instances of the component so one stores correctly and the
> other retrieves correctly, the problem is that it never retrieves
> anything since it's the other instance that gets filled with data :(
>
> how do I share a component without using static methods?
>
> (oh, BTW, the FragmentExtractor is buggy in that respect since it uses a
> static hashtable instead of using a shared component, this could well
> create problems on situations where more than one cocoon is run in the
> same JVM! please, kill all static instances!)
>
> Thanks much in advance.
>
> --
> Stefano Mazzocchi      One must still have chaos in oneself to be
>                           able to give birth to a dancing star.
> <stefano@apache.org>                             Friedrich Nietzsche
> --------------------------------------------------------------------
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message