Good afternoon... This sounds pretty good. The "synchronized" modifier, I've seen it around but we've never really gotten to know each other. I'll look into it.
Eric Schultz Technical Leader Conseiller Technique Elix Telephony & Web convergence at its best: http://www.talktosantaclaus.com La convergence téléphonie-web à son meilleur: http://www.parleauperenoel.com Specialist in interactive business solutions Specialiste en solutions d'affaires interactives 14 Commerce Place, 5th floor Nun's Island, QC H4E 1T5 t: 514 768-1000 f: 514 768-7680 -----Original Message----- From: Joe Germuska [mailto:[EMAIL PROTECTED] Sent: December 16, 2003 14:53 To: Struts Users Mailing List Subject: RE: Reloading of application resources I'd suggest that if you can achieve the same goals by writing a PlugIn implementation that you might achieve by extending the ActionServlet, you're probably better off writing the PlugIn. You could avoid creating a thread by implementing a freshness check at an access point. That is, rather than having your action get its config out of the servletcontext, have it get a plug-in instance out of the servlet context, and have it ask the plug-in for the config. At that time, the plug-in can decide whether it needs to reload the config or not before returning it to the action, perhaps by comparing the last modified timestamp on the config file to a value stored the last time the file was read. Then you could just add a "synchronized" modifier to the plug-in method that the action classes call and achieve pretty simple thread safety. It's not the fanciest, but if you're not comfortable writing concurrent code, better safe than fancy! Joe > > I need to do something similar with additional configuration properties for >> a particular action. >> >> I figure I need to write a plug-in that creates a thread that checks the >> properties file every x seconds and if changed reloads it into a context >> attribute. >> >> My problem is I've never done thread-safe programming before and I figure I >> need to handle the possibility that the plug-in's thread could be writing a >> new version while several actions are reading from the existing one. >> >> Does anyone have any pointers to some information on how to do this >> properly? Much appreciated. > >Just a thought: > >How about extending the ActionServlet and maintain an "expire"-variable >that is set at init-time. Then every time after a request is processed the >expire variable is checked. If expired, calls the same method for loading >the resources as init() does (think it's initModuleMessageResources)? -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "We want beef in dessert if we can get it there." -- Betty Hogan, Director of New Product Development, National Cattlemen's Beef Association --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]