Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Java, how to reload dynamically resources bundles in a web application?

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. :)

like image 372
paulgreg Avatar asked Oct 01 '08 07:10

paulgreg


1 Answers

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.

like image 174
WMR Avatar answered Oct 11 '22 15:10

WMR