<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Reloading Java ResourceBundle at Runtime</title>
	<atom:link href="http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/feed" rel="self" type="application/rss+xml" />
	<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime</link>
	<description>Thoughts...Opinions...Ideas... and More!</description>
	<lastBuildDate>Wed, 04 Aug 2010 00:57:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Siddu4u</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-1296</link>
		<dc:creator>Siddu4u</dc:creator>
		<pubDate>Thu, 10 Jun 2010 21:20:52 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-1296</guid>
		<description>can you give me share a sample code how it works with ResourceBundle.control beacause i implemented it but it is not working with this resourcebundle.control</description>
		<content:encoded><![CDATA[<p>can you give me share a sample code how it works with ResourceBundle.control beacause i implemented it but it is not working with this resourcebundle.control</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: papenoir</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-50</link>
		<dc:creator>papenoir</dc:creator>
		<pubDate>Thu, 29 Oct 2009 16:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-50</guid>
		<description>ResourceBundle.clearCache() doesn&#039;t work on my tomcat/jre 1.6

My walkaround solution is as follow:

Create ResourceBundle.Control subclass, override getTimeToLive and needsReload functions to force reload when necessary.
Then use ResourceBundle.getBundle(&quot;myproperty&quot;,locale,myResouceBundleControl)

Here&#039;s the source (subclass). have fun:

boolean needReload = false;
class myResourceBundleControl extends ResourceBundle.Control{
        @Override
        public long getTimeToLive(String baseName, Locale locale) {
            //System.out.println(&quot;asking TTL&quot;);
            if(needReload)
                return 0; //ResourceBundle.Control.TTL_DONT_CACHE doesn&#039;t work;
            else
                return ResourceBundle.Control.TTL_NO_EXPIRATION_CONTROL;
        }

        @Override
        public boolean 	needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)
        {

            return needReload;


        }
    }</description>
		<content:encoded><![CDATA[<p>ResourceBundle.clearCache() doesn&#8217;t work on my tomcat/jre 1.6</p>
<p>My walkaround solution is as follow:</p>
<p>Create ResourceBundle.Control subclass, override getTimeToLive and needsReload functions to force reload when necessary.<br />
Then use ResourceBundle.getBundle(&#8220;myproperty&#8221;,locale,myResouceBundleControl)</p>
<p>Here&#8217;s the source (subclass). have fun:</p>
<p>boolean needReload = false;<br />
class myResourceBundleControl extends ResourceBundle.Control{<br />
        @Override<br />
        public long getTimeToLive(String baseName, Locale locale) {<br />
            //System.out.println(&#8220;asking TTL&#8221;);<br />
            if(needReload)<br />
                return 0; //ResourceBundle.Control.TTL_DONT_CACHE doesn&#8217;t work;<br />
            else<br />
                return ResourceBundle.Control.TTL_NO_EXPIRATION_CONTROL;<br />
        }</p>
<p>        @Override<br />
        public boolean 	needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)<br />
        {</p>
<p>            return needReload;</p>
<p>        }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amar.gautam</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-#comment-48</link>
		<dc:creator>amar.gautam</dc:creator>
		<pubDate>Fri, 11 Sep 2009 11:18:07 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-48</guid>
		<description>This defect has been fixed in Java 1.6

Check specifications of Java 6.</description>
		<content:encoded><![CDATA[<p>This defect has been fixed in Java 1.6</p>
<p>Check specifications of Java 6.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: laslorma</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-49</link>
		<dc:creator>laslorma</dc:creator>
		<pubDate>Thu, 10 Sep 2009 19:36:12 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-49</guid>
		<description>how about clearcache in java 1.6? .

i try this, but doesn&#039;t work!

   ResourceBundle.clearCache();
        resourceBundle = ResourceBundle.getBundle(Constants.RESOURCES);

i apreciate any help!</description>
		<content:encoded><![CDATA[<p>how about clearcache in java 1.6? .</p>
<p>i try this, but doesn&#8217;t work!</p>
<p>   ResourceBundle.clearCache();<br />
        resourceBundle = ResourceBundle.getBundle(Constants.RESOURCES);</p>
<p>i apreciate any help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Waqas</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-44</link>
		<dc:creator>Waqas</dc:creator>
		<pubDate>Mon, 10 Aug 2009 05:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-44</guid>
		<description>I had this implemented in my web already, like this..
&lt;code&gt;
    private static void clearMap(Class cl, Object obj, String name)
    throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException,
    InvocationTargetException
    {
        Field field = cl.getDeclaredField(name);
        field.setAccessible(true);

        Object cache = field.get(obj);
        Class ccl = cache.getClass();
        Method clearMethod = ccl.getMethod(&quot;clear&quot;, null);
        clearMethod.invoke(cache, null);
    }
&lt;/code&gt;

But there is one problem in it,
I am using tomcat, and tomcat context reloads and invalidates the session. are there any work arounds for this?</description>
		<content:encoded><![CDATA[<p>I had this implemented in my web already, like this..<br />
<code><br />
    private static void clearMap(Class cl, Object obj, String name)<br />
    throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException,<br />
    InvocationTargetException<br />
    {<br />
        Field field = cl.getDeclaredField(name);<br />
        field.setAccessible(true);</p>
<p>        Object cache = field.get(obj);<br />
        Class ccl = cache.getClass();<br />
        Method clearMethod = ccl.getMethod("clear", null);<br />
        clearMethod.invoke(cache, null);<br />
    }<br />
</code></p>
<p>But there is one problem in it,<br />
I am using tomcat, and tomcat context reloads and invalidates the session. are there any work arounds for this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vivalkakira</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-47</link>
		<dc:creator>Vivalkakira</dc:creator>
		<pubDate>Fri, 07 Aug 2009 09:48:41 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-47</guid>
		<description>The best information i have found exactly here. Keep going Thank you</description>
		<content:encoded><![CDATA[<p>The best information i have found exactly here. Keep going Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SergeyNikolaev</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-46</link>
		<dc:creator>SergeyNikolaev</dc:creator>
		<pubDate>Thu, 30 Jul 2009 09:48:59 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-46</guid>
		<description>Thanks for post. Nice to see such good ideas.</description>
		<content:encoded><![CDATA[<p>Thanks for post. Nice to see such good ideas.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: electromozzo</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-45</link>
		<dc:creator>electromozzo</dc:creator>
		<pubDate>Tue, 28 Jul 2009 09:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-45</guid>
		<description>I’m glad that after surfing the web for such a long time I have found out this information. I’m really lucky.</description>
		<content:encoded><![CDATA[<p>I’m glad that after surfing the web for such a long time I have found out this information. I’m really lucky.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CrisBetewsky</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-43</link>
		<dc:creator>CrisBetewsky</dc:creator>
		<pubDate>Mon, 06 Jul 2009 17:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-43</guid>
		<description>It&#039;s a pity that people don&#039;t realize the importance of this information. Thanks for posing it.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a pity that people don&#8217;t realize the importance of this information. Thanks for posing it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amar.gautam</title>
		<link>http://amargautam.com/tech-talks/reloading-java-resourcebundle-at-runtime/comment-page-1#comment-42</link>
		<dc:creator>amar.gautam</dc:creator>
		<pubDate>Tue, 02 Jun 2009 09:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://amargautam.com/?p=172#comment-42</guid>
		<description>You can copy it to your site but kindly give me a back link and an acknowledgement.</description>
		<content:encoded><![CDATA[<p>You can copy it to your site but kindly give me a back link and an acknowledgement.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
