How to implement Dynamic properties files?

Hello,

I use Properties files to display some messages in my jsp but It could be very usefull if someone can tell mea way to reload my properties files when my application server is running.

Or if Someone can tell me where to find the singleton who manage the map of message it can help me a lot ^_^.

NB: I use Struts framework to manage properties, but if someone have a solution with JSTL I'm interest too.

best regards,

Jrme

[474 byte] By [vergereaua] at [2007-11-27 11:14:12]
# 1

Hi Jerome, this is something all Java developers have run into at some point I believe. The ResourceBundle in Java reads your .properties file once and cannot be told to re-load. Unless you can do some sort of classloader trick, not sure.... You have a few options otherwise:

1) Write your own ResourceBundle which either checks a database or re-reads a .properties file on some timely basis.

2) Use Spring's ReloadableResourceBundleMessageSource (http://www.springframework.org/docs/api/org/springframework/context/support/ReloadableResourceBundleMessageSource.html) The only drawback here being you no longer use the ResourceBundle like you would a normal Java resource bundle (i.e. using ResourceBundle.getBundle()) you now use Spring's MessageSource interface to get at your properties.

Hope that helps

CraigTataryna at 2007-7-29 14:05:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks a lot for you help I will try to use Spring ReloadableResourceBundleMessageSource.

It's just sad to think Struts apache doesn't implement it :/.

regards,

Jrme

vergereaua at 2007-7-29 14:05:34 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...