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. <[EMAIL PROTECTED]> Friedrich Nietzsche -------------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]