You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nicklas Karlsson <ni...@ra.abo.fi> on 2003/12/15 10:09:37 UTC
Reloading of application resources
Hello,
We have a singleton factory that watches/caches/delivers
up-to-date ResourceBundles of property files based on the timestamp of the
watched file. What would be the natural way of refreshing (and triggering
a refresh) of a watched ApplicationResources.properties file so that e.g.
a change in a language label would immediately be visible?
---
Nicklas "Nik" Karlsson, Murkiogatan 3 B 29 20740 Åbo, 040 9000 724
nickarls@abo.fi ::: http://www.abo.fi/~nickarls ::: Nik@ircnet
"If a man speaks in the forest and there is no woman around to hear him -
Is he still wrong?"
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Reloading of application resources
Posted by Joe Germuska <Jo...@Germuska.com>.
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/MessageResourcesFactory.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
Joe@Germuska.com
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Reloading of application resources
Posted by Nicklas Karlsson <ni...@ra.abo.fi>.
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?
---
Nicklas "Nik" Karlsson, Murkiogatan 3 B 29 20740 Åbo, 040 9000 724
nickarls@abo.fi ::: http://www.abo.fi/~nickarls ::: Nik@ircnet
"If a man speaks in the forest and there is no woman around to hear him -
Is he still wrong?"
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Reloading of application resources
Posted by Yves Sy <yv...@ssip.com>.
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.
Of course a clustered environment will complicate things a little bit
but that's a another story :o)
-Yves-
-----Original Message-----
From: Nicklas Karlsson [mailto:nickarls@ra.abo.fi]
Sent: Monday, December 15, 2003 5:10 PM
To: struts-user@jakarta.apache.org
Subject: Reloading of application resources
Hello,
We have a singleton factory that watches/caches/delivers
up-to-date ResourceBundles of property files based on the timestamp of
the
watched file. What would be the natural way of refreshing (and
triggering
a refresh) of a watched ApplicationResources.properties file so that
e.g.
a change in a language label would immediately be visible?
---
Nicklas "Nik" Karlsson, Murkiogatan 3 B 29 20740 Åbo, 040 9000 724
nickarls@abo.fi ::: http://www.abo.fi/~nickarls ::: Nik@ircnet
"If a man speaks in the forest and there is no woman around to hear him
-
Is he still wrong?"
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org