开发者

How to reload ResourceBundles that are used by JSF?

开发者 https://www.devze.com 2022-12-15 22:57 出处:网络
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 app

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消