• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Reloading a Resource Bundle

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is possible to reload a ResourceBundle without bringing down the server ? . I find that getBundle caches the Resource as a PropertiesResourceBundle that cannot be dynamicaly reloaded with a another call to getBundle(resource).
Is it possible to force reload of a Resource / Property file ?

Thanks
Lakshmi
[ May 28, 2002: Message edited by: Laksh Anan ]
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might be possible if the server is set up to reload java classes upon modification. If this is true, then you can have a java class load the resource bundle in a static initializer and then 'touch' the class file so the file so that the modification date changes. The app server should see the new timestamp on the file and reload it. Since the static initializer is run when the class is loaded, the resource bundle should be reloaded as well.
Sean
 
Lakshmi Anantharaman
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sean,
I have been trying exactly this but it does not seem to work . Should my ResourceBundle be a class rather than a properties file. [ I make a change to the property file call refresh throu UI , then make another call to get Corresponding property bundle which I changed ]
My apps server does currently reload files , strangely sometimes it does not . I wonder if it is a classpath issue as I have my class files out side the server.

Lakshmi
[ May 28, 2002: Message edited by: Laksh Anan ]
[ May 28, 2002: Message edited by: Laksh Anan ]
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try to use your ClassLoader, instead of System one - but at this case you need to write your utility for getting resource bundle (you could check timestamp, to deside, does it need to be reloaded).
It kind of funny, but when you say that package/class name should be uniq, you should add - within same classloader.
You could have a simple code, wich will allow you to have two different version of same class in the system
 
Lakshmi Anantharaman
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I shall try this out , thanks .
 
Lakshmi Anantharaman
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found some good work around here :
Reloading Resource Bundle
This implementation help me achieve what I want , until we have a later solution from javasoft .
Class type = ResourceBundle.class;
Field cacheList = type.getDeclaredField("cacheList");
cacheList.setAccessible(true);
((Map)cacheList.get(ResourceBundle.class)).clear();
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic