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 ;) Thanks regards Jeremy -- ___________________________________________________________________ Jeremy Quinn Karma Divers webSpace Design HyperMedia Research Centre <mailto:[EMAIL PROTECTED]> <http://www.media.demon.co.uk> <phone:+44.[0].20.7737.6831> <pager:[EMAIL PROTECTED]> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]