cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Mazzocchi <stef...@apache.org>
Subject Re: FileWritingTransformer, locking
Date Mon, 18 Feb 2002 11:18:16 GMT
Bertrand Delacretaz wrote:
> 
> On Saturday 16 February 2002 14:27, Jeremy Quinn wrote:
> >. . .
> > I suspect I ought to be Serialising into a temporary file and
> > replacing the original only after everything has worked.
> 
> Makes sense, AFAIK renaming a file is an atomic operation on all
> current OSes.

yes, well, at least you don't get problems if two users are renaming the
same file since the OS synchronizes them.

> >. . .
> > How do I block the process of a second simultaneous request?
> > Do I 'syncronize' the temporary file?
> 
> If you want to do this in memory (which makes sense in your case I
> think), you have to have all instances of your component synchronize on
> a shared java object that maps to the absolute filename of the
> file you're writing.
> 
> One problem in this case is making sure the lock on your file is
> released if the file writing operation fails, probably using a lock
> validity timeout .
> 
> In a monolithic program you'd create a Singleton component (a static
> single-instance object) to handle such locks. I suspect such mechanisms
> already exist in Avalon, but I'm not familiar enough with it to tell
> you where to look. Maybe some Avalon guru can help you here?


Hmmm, I would go like Jeremy proposed: write on a temporary file (make
sure you add a timestamp somewhere or people might hit the same problem
with the temporary file.


-- 
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


Mime
View raw message