Question

We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app.

Is there any simple way to use the new value without restarting the web server ?

(We do not want to always look up the value from database but we would like to invalidate the cache, for example by calling a special 'admin' URL)

EDIT : We are using JDK 1.4, so I would prefer a solution on that version. :)

Was it helpful?

Solution

As others have pointed out in the comments, you might want to look into Spring - particularly the ReloadableResourceBundleMessageSource.

OTHER TIPS

If you're using JDK 1.6 you can use the callback methods getTimeToLive() and needsReload() in ResourceBundle.Control to control if the bundle cache needs to be loaded with new values from the database.

First you can create a class which extends from ReloadableResourceBundleMessageSource to expose its inner class protected method called getProperties. This method return a concurrent map from PropertiesHolder object. Second you should configure a bean of that extended class in you web configuration class. Now you able to use messageSource in your service or business layer. Here is the reference link Configure reloadable message source bundle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top