• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

java.util.Properties subclass which can reload values when the underlying properties file is modified.

Hi there,
I'm looking for either a howto,tutorial or source code for a subclass of java.util.Properties that will detect when the properties file has been modified and load the new values automatically without having to restart the application.

Any ideas ?

Thanks

Bryan
0
revoltingdigits
Asked:
revoltingdigits
1 Solution
 
CEHJCommented:
You could use a file monitor class such as this and reload on a file chnaged event:


http://geosoft.no/software/filemonitor/FileMonitor.java.html
0
 
Mayank SAssociate Director - Product EngineeringCommented:
0
 
aozarovCommented:
This what Log4j does in its PropertyConfigurator#configureAndWatch method.
See: http://www.docjar.com/html/api/org/apache/log4j/PropertyConfigurator.java.html and its use of
http://www.docjar.com/docs/api/org/apache/log4j/PropertyWatchdog.html
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
aozarovCommented:
:-)
Not trying to be pushy but mayankeagle so many links lead me to beleive that there must be one provided by Jakarta and I think I found it.
Using the jakarta commons configuration package -> http://jakarta.apache.org/commons/configuration
You can use the PropertiesConfiguration http://jakarta.apache.org/commons/configuration/apidocs/org/apache/commons/configuration/PropertiesConfiguration.html
with a FileChangedReloadingStrategy http://jakarta.apache.org/commons/configuration/apidocs/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.html
Though this might not be good for you because PropertiesConfiguration does not extend java.util.Proeprties but rather provides a similar (but much more powerfull [e.g loading from different files])
functionality.
0
 
revoltingdigitsAuthor Commented:
Great answer aozarov , that's exactly what I'm looking for.

Thanks

Byan
0
 
Mayank SAssociate Director - Product EngineeringCommented:
See aozarov, I inspired you to write that great answer ;-) he he....
0
 
aozarovCommented:
Indeed you did. Thanks :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now