aspose file tools*
The moose likes Struts and the fly likes Problem with ResourseBundle.Control using struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with ResourseBundle.Control using struts" Watch "Problem with ResourseBundle.Control using struts" New topic
Author

Problem with ResourseBundle.Control using struts

PradeepKumar Dev Venkata
Greenhorn

Joined: Feb 19, 2009
Posts: 6
Hello all,

I have a requirement to make our web application to reload the ResourceBundle (a properties file) for regular interval. Basically this is to avoid restarting the application server for .properties file changes (FYI..we use Struts Framework and Jboss application server).

For this, I used a util class which will extends ResourceBundle.Control in Java SE 6 and override its getFormats() and newBundle() methods, made getTimeToLive method to return different timeToLive values TTL_DONT_CACHE,0 etc.. and passed this instance to in ResourceBundle.getBundle method.

Something like below...

In Action class:

ResourceBundle msgBundle = ResourceBundle.getBundle("resources.ApplicationResources",ResourceBundleController.instance());

PROBLEM IS: With these changes I couldnt achive the expected outcome. Application is not reloading the cache for any of the timeToLive I mentioned above.. I also have a doubt how can I do same changes on jsp which uses <bean:message .. > tag.

Please correct me if I am wrong anywhere... or suggest any other alternative. Any help is really appreciated.


Below is the util class (ResourceBundleController) used FYI ::

import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.ResourceBundle.Control;

public class ResourceBundleController extends Control
{

public static ResourceBundleController instance() {
return new ResourceBundleController();
}

private long timeToLive = ResourceBundle.Control.TTL_DONT_CACHE;

public long getTimeToLive(String baseName, java.util.Locale locale) {
return timeToLive;
}

public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime) {
return super.needsReload(baseName, locale, format, loader, bundle, loadTime);
}

public void setTimeToLive(long timeToLive) {
this.timeToLive = timeToLive;
}

public List<String> getFormats(String arg0) {
return super.getFormats(arg0);
}

public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader,
boolean reload) throws IllegalAccessException, InstantiationException, IOException {
return super.newBundle(baseName,locale, format, loader, reload);
}

}


Thanks in advance
 
jQuery in Action, 2nd edition
 
subject: Problem with ResourseBundle.Control using struts