diff --git a/source/java/org/alfresco/web/app/Application.java b/source/java/org/alfresco/web/app/Application.java index a249b87ca6..558a05ba89 100644 --- a/source/java/org/alfresco/web/app/Application.java +++ b/source/java/org/alfresco/web/app/Application.java @@ -482,7 +482,7 @@ public class Application { locale = Locale.getDefault(); } - bundle = ResourceBundleWrapper.findSharedResourceBundle(MESSAGE_BUNDLE, locale); + bundle = ResourceBundleWrapper.getResourceBundle(MESSAGE_BUNDLE, locale); session.setAttribute(MESSAGE_BUNDLE, bundle); } @@ -512,7 +512,7 @@ public class Application { locale = Locale.getDefault(); } - bundle = ResourceBundleWrapper.findSharedResourceBundle(MESSAGE_BUNDLE, locale); + bundle = ResourceBundleWrapper.getResourceBundle(MESSAGE_BUNDLE, locale); session.put(MESSAGE_BUNDLE, bundle); } diff --git a/source/java/org/alfresco/web/app/ResourceBundleWrapper.java b/source/java/org/alfresco/web/app/ResourceBundleWrapper.java index f4b2c1f0bf..5b5f69c23e 100644 --- a/source/java/org/alfresco/web/app/ResourceBundleWrapper.java +++ b/source/java/org/alfresco/web/app/ResourceBundleWrapper.java @@ -17,9 +17,7 @@ package org.alfresco.web.app; import java.util.Enumeration; -import java.util.HashMap; import java.util.Locale; -import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -30,9 +28,6 @@ import org.apache.log4j.Priority; /** * Wrapper around Alfresco Resource Bundle objects. Used to catch and handle missing * resource exception to help identify missing I18N strings in client apps. - *

- * Also provides a factory method to get/create a shared instance to a named resource - * bundle for a particular locale. * * @author Kevin Roast */ @@ -42,8 +37,6 @@ public final class ResourceBundleWrapper extends ResourceBundle private ResourceBundle delegate; - private static Map cache = new HashMap(); - /** * Constructor * @@ -81,40 +74,22 @@ public final class ResourceBundleWrapper extends ResourceBundle } /** - * Factory method to get/create a shared instance to a named resource bundle for a - * particular locale. A static cache of language bundles is used to save memory, as each - * bundle consumes >300K per user and they are read only objects. + * Factory method to get a named wrapped resource bundle for a particular locale. * * @param name Bundle name * @param locale Locale to retrieve bundle for * - * @return Shared ResourceBundle instance for specified locale + * @return Wrapped ResourceBundle instance for specified locale */ - public static ResourceBundle findSharedResourceBundle(String name, Locale locale) + public static ResourceBundle getResourceBundle(String name, Locale locale) { - String key = name + '_' + locale; - - ResourceBundle bundle = cache.get(key); + ResourceBundle bundle = ResourceBundle.getBundle(name, locale); if (bundle == null) { - // we can safely use a weak synchronization point here - i.e. it doesn't actually matter - // if more than one thread loads and caches the same bundle if a race condition occurs - synchronized (cache) - { - bundle = ResourceBundle.getBundle(name, locale); - if (bundle == null) - { - throw new AlfrescoRuntimeException("Unable to load Alfresco messages bundle: " + name); - } - - // apply our wrapper to catch MissingResourceException - bundle = new ResourceBundleWrapper(bundle); - - // cache the bundle for later use - cache.put(key, bundle); - } + throw new AlfrescoRuntimeException("Unable to load Alfresco messages bundle: " + name); } - return bundle; + // apply our wrapper to catch MissingResourceException + return new ResourceBundleWrapper(bundle); } }