tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Smith" <ssm...@mainstreamdata.com>
Subject Dynamic ResourceBundle clearCache()
Date Fri, 13 Jun 2008 07:10:58 GMT
We are trying to build functionality into our website so a website
administrator can update the properties file which contains the webpage
display strings without stopping the website.  He would do this through
an administrative webpage. 

 

The code (excerpted below) works fine when we step through the code when
running Tomcat (5.5, Java 6) under Eclipse.  However, if we put it in a
war file and run it in Tomcat, the clearCache() appears to have no
effect.  We think it should have caused jstl to re-read the properties
file.  We can see that the properties file is getting re-written.
However the string value displayed on the page doesn't change.  If we
restart Tomcat, then the new string value takes effect, but that
obviously doesn't work in the long run.

 

There is a comment that it clears the properties files for any
properties files that have been read in with the current ClassLoader.
But we aren't sure what ClassLoader to specify if it's not the current
one.

 

Does anyone have any idea why this might not work or an alternative
suggestion on how to do what we want to do? 

 

 

        File propertiesFile = new File("myproperty.properties");

  Properties p = new Properties();

        FileReader fr = new FileReader(propertiesFile);

        p.load(fr);

        fr.close();

        p.setProperty("my.key", "the string");

        FileWriter fw = new FileWriter(propertiesFile);

        p.store(fw, "");

        fw.flush();

        fw.close();

        ResourceBundle.clearCache();

        PropertyResourceBundle rb = (PropertyResourceBundle)
ResourceBundle.getBundle("myproperty");

        PropertyResourceBundle.clearCache();

        Config.set(ses.getServletContext(),
Config.FMT_LOCALIZATION_CONTEXT, new LocalizationContext(rb)); 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message