• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with ResourseBundle.Control using struts

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
Pradeep
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"PradeepKumar dv " please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
PradeepKumar Dev Venkata
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

Please someone help me in this..

Thanks in advance.
Pradeep


 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Even i have same requirements can any one help us?

Thanks in Advance,
Ramakrishnan
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic