Yes, I have also written a database implementation or three ;)

http://sourceforge.net/project/showfiles.php?group_id=49385&package_id=76369

In addition to this one, I have also written several impls for commons-resources (which Struts will be moving to very soon). There were license issues so I had to host them elsewhere (same link above) but I haven't released these as of yet. That's on my todo list ;)


The workaround for Struts 1.1 and 1.2.x is to clear the hashmap of formatted messages. Look at org.apache.struts.util.MessageResources#getMessage(Locale locale, String key, Object args[]).


In that method you'll see where if the formatted message (param replacement already done) is found, then that is returned. That certainly is a nice way to speed up things, but the impl fails to make that configurable, so you are just stuck with it :(

My impl simply does formats.clear() on each call to getMessage(), so, in effect, unless the very next call to your getMessage() is asking for the last one you just gave it, the cache is (basically) disabled.

You also might consider implementing your own cache or taking advantage of caching available via O/R Mapping tools like Hibernate.



--
James Mitchell
Software Engineer / Open Source Evangelist
EdgeTech, Inc.
678.910.8017
AIM: jmitchtx

----- Original Message ----- From: "Günther Wieser" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Monday, February 28, 2005 5:57 PM
Subject: caching of message resources when using bean:message tag




hi,

we are using struts version 1.2.4 and we implemented our own
MessageResources and MessageResourceFactory. we needed to have a database
based system for managing message resources for different locales so that we
can change valued on the fly without the need to restart the app.
these implementation work quite well, but we found one issue when using
<bean:message key="whatever"/>:
it seems that the message with the key "whatever" gets cached somewhere. the
first call to this bean with key="whatever" results in a getMessage() call
to our implementation of MessageResources. the message gets delivered and
inserted into the JSP.
but all further calls to the message tag do NOT query
MessageResources.getMessage(), so we assume that the message value is cached
somewhere.

what we see from the source code of the message tag is that
TagUtils.message() is called. so far we haven't found anything that caches
in TagUtils. and there's no caching in the message tag..

anyone an idea where the caching takes place?
am i missing something fundamentally when i assume that it's possible (with
my own implementation of MessageResources) to change message resources in
struts dynamically during runtime?

kr,
guenther



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



Reply via email to