Cache resolved resource bundles based on our path to avoid stepping on other

message managers.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1900 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2006-09-10 16:47:30 +00:00
parent b04e96dc27
commit 1b16a084bb
@@ -209,7 +209,7 @@ public class MessageManager
// in the request object // in the request object
ResourceBundle[] bundles = null; ResourceBundle[] bundles = null;
if (req != null) { if (req != null) {
bundles = (ResourceBundle[])req.getAttribute(BUNDLE_CACHE_NAME); bundles = (ResourceBundle[])req.getAttribute(getBundleCacheName());
} }
if (bundles != null) { if (bundles != null) {
return bundles; return bundles;
@@ -251,7 +251,7 @@ public class MessageManager
// if we found either or both bundles, cache 'em // if we found either or both bundles, cache 'em
if (bundles[0] != null || bundles[1] != null && req != null) { if (bundles[0] != null || bundles[1] != null && req != null) {
req.setAttribute(BUNDLE_CACHE_NAME, bundles); req.setAttribute(getBundleCacheName(), bundles);
} }
return bundles; return bundles;
@@ -326,6 +326,12 @@ public class MessageManager
return (req == null) ? "<none>" : req.getRequestURL().toString(); return (req == null) ? "<none>" : req.getRequestURL().toString();
} }
/** Used to cache resolved bundles in a request. */
protected String getBundleCacheName ()
{
return BUNDLE_CACHE_PREFIX + _bundlePath;
}
/** The path, relative to the classpath, to our resource bundles. */ /** The path, relative to the classpath, to our resource bundles. */
protected String _bundlePath; protected String _bundlePath;
@@ -346,6 +352,6 @@ public class MessageManager
/** The attribute name that we use for caching resource bundles in /** The attribute name that we use for caching resource bundles in
* request objects. */ * request objects. */
protected static final String BUNDLE_CACHE_NAME = protected static final String BUNDLE_CACHE_PREFIX =
"com.samskivert.servlet.MessageManager:CachedResourceBundle"; "com.samskivert.servlet.MessageManager:CachedResourceBundle:";
} }