cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Delacretaz <>
Subject Re: FileWritingTransformer, locking
Date Mon, 18 Feb 2002 07:15:25 GMT
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.

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

 -- Bertrand Delacrétaz,
 -- web technologies consultant - OO, Java, XML, C++

To unsubscribe, e-mail:
For additional commands, email:

View raw message