cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giacomo Pati <Giacomo.P...@pwr.ch>
Subject Re: Shutdown of an producer
Date Fri, 18 Aug 2000 05:44:59 GMT
Ricardo Rocha wrote:
> 
> Stefano Mazzocchi wrote:
> > I would like to be able to have both init() and destroy() method
> > implemented, at least, in generators so that we can have resources
> > started and stopped along with the servlet life cycles to ensure greater
> > possible usability compared to pure servlets.
> >
> > In practice, this means that every generator that is created by the
> > sitemap should be destroyed when the servlet is destroyed.
> >
> > These init/destroy cycles might be needed for also the other pipeline
> > components... what do you say?
> 
> +1 for pipeline components at large

Well, I think this wouldn't be possible because almost none of the
sitemap components are thread save today (and most of them would never
be) and thus are created per request (and destroyed right after request
processing). 

Look at the interfaces:

   Serializer
      impossible to make it thread save because of the setOutputStream 
      method (it has to save it to a instance variable)

   Transformer/Generator
      the setup Method of the inherited SitemapModelComponent Interface 
      will be critical too (as with the Serializers saving setup
parameters 
      to instance variables)

   Matcher/Selector:
     they must be thread save because the sitemap handles them as such
but
     these are not relevant for the purpose we are discussing here

   Generator
      Also here the XMLProducer and the SitemapModelComponent Interface 
      wouldn't allow them to be thread save

And I didn't mentioned other Interfaces like XMLConsumer
(ContentHandler) which are hardly thread save because it is likely that
one might need access to instance variables in the ContentHandler
methods.

I mean there are ways to make an object thread save but most of these
methods aren't efficent enough in a SAX pipeline.

One could say we can use a pool for those objects but I think this
wouldn't help at all for this purpose (which FooBarGenerator is
responsible for beeing called at destroy()).

So, this is why I've proposed the following in a mail yesterday:

Giacomo Pati wrote:
> 
> I have no idea for C1 (I'm not familiar with C1 code). For me the
> CocoonServlet.java is meant as an example how to use C2 in a servlet
> environment and thus would suggest to hack the destroy method there or
> subclass it an overwrite the destroy method to do what you like.

Comments are very welcome (could be that I am blinded by something :)

Giacomo

-- 
PWR GmbH, Organisation & Entwicklung      Tel:   +41 (0)1 856 2202
Giacomo Pati, CTO/CEO                     Fax:   +41 (0)1 856 2201
Hintereichenstrasse 7                     Mailto:Giacomo.Pati@pwr.ch
CH-8166 Niederweningen                    Web:   http://www.pwr.ch

Mime
View raw message