How to reload ResourceBundles that are used by JSF?
I want to reload the ResourceBundles used by JSF programmatically on a button click. The ResourceBundles in the classpath (i.开发者_StackOverflow社区e. WEB-INF/classes) are modified by an external application and the modification event is known to me.
Try
ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());
(you can use the same method without arguments)
From the javadoc
Resource bundle instances created by the getBundle factory methods are cached by default, and the factory methods return the same resource bundle instance multiple times if it has been cached. getBundle clients may clear the cache, manage the lifetime of cached resource bundle instances using time-to-live values, or specify not to cache resource bundle instances. Refer to the descriptions of the getBundle factory method, clearCache, ResourceBundle.Control.getTimeToLive, and ResourceBundle.Control.needsReload for details.
精彩评论