cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject Re: FileWritingTransformer, locking
Date Mon, 18 Feb 2002 10:37:11 GMT
At 8:15 am +0100 18/2/02, Bertrand Delacretaz wrote:

Thanks for your reply, Bertrand,

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

That's good to hear ...

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

Thanks for your suggestions.

While I am working out how to do this the right way, I'll fix the
Transformer so that it writes to a temporary file as above, and if another
person attempts to simultaneously overwrite, I can just throw an Excpetion
and have them try again later. I would like to work out how to do this
properly though ;)


regards Jeremy

   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <>     		 <>
   <phone:+44.[0].20.7737.6831>             <>

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

View raw message