烦恼岁月

付出总是有回报的 take action follow your heart , or follow your head
posts - 40, comments - 5, trackbacks - 0, articles - 4

ResourecBundled cache的讨论

Posted on 2009-10-17 17:23 不需要解释 阅读(323) 评论(0)  编辑  收藏 所属分类: java

有个大师说过一句话,有人的地方就有江湖,有江湖的地方就有斗争。今天在java eys就看到了一场Resourcebundle引起的口角,集体见:

http://www.javaeye.com/topic/6417?page=1.

这个问题在jdk1.6已经不存在

clearCache
public static final void clearCache()
Removes all resource bundles from the cache that have been loaded using the caller's class loader.
Since:
1.6
See Also:
ResourceBundle.Control.getTimeToLive(String,Locale)

clearCache
public static final void clearCache(ClassLoader loader)
Removes all resource bundles from the cache that have been loaded using the given class loader.
Parameters:
loader - the class loader
Throws:
NullPointerException - if loader is null
Since:
1.6
See Also:
ResourceBundle.Control.getTimeToLive(String,Locale)

 

在1.5,1.4怎么办呢:

   Class klass = ResourceBundle.getBundle("your.Bundle").getClass().getSuperclass();
   Field field = klass.getDeclaredField("cacheList");
   field.setAccessible(true);
   sun.misc.SoftCache cache = (sun.misc.SoftCache)field.get(null);
   cache.clear();
   field.setAccessible(false);

这样就可以清楚cache.


只有注册用户登录后才能发表评论。


网站导航:
 
我实话告诉你们,我可是身经百战了.bbs我见的多了,哪个版我没灌过?你们要知道, 一塌糊 涂的triangle,PIC,SEX版,那比你们不知道厉害到哪里去了,我在那谈笑风声.你 们有一好就是无论在哪个版,什么话题都灌,但是灌来灌去的问题,都too simple, sometimes naive!你 们懂不懂呀?啊?所以说灌水啊,关键是要提高自己的知识水平.你 们啊,不要总想着弄个大坑,然后灌上十大,再把我羞辱一番……你们啊,naive!你们这 样灌是不行地!~那你問我支持 不支持灌水,我說支持,我常來這裡灌,你說支持不支持?