Good morning...

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.

Thanks

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 15, 2003 11:14
To: Struts Users Mailing List
Subject: RE: Reloading of application resources


At 11:42 AM +0200 12/15/03, Nicklas Karlsson wrote:
>On Mon, 15 Dec 2003, Yves Sy wrote:
>
>>  Create a thread in your cache manager that polls for changes in the
>>  timestamp of the properties file, say, every 5000 ms and reloads it when
>>  a new one is detected.
>
>       Yes, but the problem is not at the cache end, the issues are how
>to trigger the components (the ActionServlet in this case) into refreshing
>their data from the cache. Do I have to extends the ActionServlet and
>manually pop in refreshed data (based on some trigger) in the message key
>in the ServletContext? And how does locale affect the configured key

Note that although the message data is read in from Properties files, 
the objects in the ServletContext which resolve references to 
properties keys are instances of a specific Struts class, 
MessageResources.  If you dynamically reloadable messages (which 
would be useful to many people), you'll want to look at the 
MessageResources and MessageResourcesFactory abstract classes and 
extend them (or their Property oriented subclasses) in order to add 
in your functionality...


http://jakarta.apache.org/struts/api/org/apache/struts/util/MessageResources
.html
http://jakarta.apache.org/struts/api/org/apache/struts/util/MessageResources
Factory.html

There's an ongoing process to factor these classes out of Struts and 
into a commons library, and to have Struts use that library (on the 
roadmap, that's slated for Struts 1.3.x).

http://jakarta.apache.org/commons/sandbox/resources/
http://jakarta.apache.org/struts/status.html

Hope that helps.  I know I'd find a dynamically reloadable messages 
bundle useful!

Joe

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

Reply via email to