Hi Ken:

A JDBCMessageResources class already exists. I believe that James Mitchell wrote it. After a quick search, I couldn't find any additional links to it, however.

Ken Pullin wrote:
I've been looking into extending the MessageResources class and providing my own 
MessageResourcesFactory.  The end goal is to house the ApplicationResource files in a 
database table.  The issue I'm noticing is that the MessageResources class maintains a 
HashMap of key/values called 'formats'.  So any class that extends MessageResources 
only get's called when the particular value is not in the cache(hashmap) in the 
MessageResource class.  This is the method that gets called in the MessageResources 
class:

String formatKey = messageKey(locale, key);
 synchronized (formats) {
     format = (MessageFormat) formats.get(formatKey);
     if (format == null) {
  String formatString = getMessage(locale, key);
  if (formatString == null) {
      if (returnNull)
   return (null);
      else
   return ("???" + formatKey + "???");
  }
  format = new MessageFormat(escape(formatString));
  formats.put(formatKey, format);
     }

 }

Notice how the 1st step is to check to see if the formats hashmap contains the key.  
If it doesn't it then calls the getMessage(locale,key) which is provided by my 
implemenation class.  At that point, it gets back a value and then puts it on the 
HashMap.

The problem I'm having is when I want to update a value.  How do you tell the 
MessageResources class to refresh it's cache.  This becomes even more complicated if 
the application resides in a clustered environment.  You could use OJB or even Entity 
Bean to retrieve the data from the database in the Custom Implemenation, but you still 
have the problem with the MessageResources class maintaining a seperate cache.  The 
EJB or OJB classes would contain the correct values, but the cache at the parent level 
would not.  I basically need a way when a value gets updated to tell the 
MessageResources class to either 1) clear it's cache all together or 2) take the value 
off of the HashMap so the next call to it would go to my custom implementation.

I hope this wasn't 2 confusing....

Thanks


--------------------------------- Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages!


--
Nick Heudecker
System Mobile, Inc.
Email: [EMAIL PROTECTED]
Web: http://www.systemmobile.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to