mirror of
https://github.com/apache/struts.git
synced 2026-09-11 08:39:39 +00:00
Updates as stated in PR#20 comments.
This commit is contained in:
@@ -86,7 +86,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
*/
|
||||
public class LocalizedTextUtil {
|
||||
|
||||
private static final ConcurrentMap<Integer, List<String>> classLoaderMap = new ConcurrentHashMap<Integer, List<String>>();
|
||||
private static final ConcurrentMap<Integer, Set<String>> classLoaderMap = new ConcurrentHashMap<Integer, Set<String>>();
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LocalizedTextUtil.class);
|
||||
private static boolean reloadBundles = false;
|
||||
private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<String, ResourceBundle>();
|
||||
@@ -106,9 +106,9 @@ public class LocalizedTextUtil {
|
||||
*/
|
||||
public static void clearDefaultResourceBundles() {
|
||||
ClassLoader ccl = getCurrentThreadContextClassLoader();
|
||||
List<String> bundles = new ArrayList<String>();
|
||||
Set<String> bundles = new HashSet<String>();
|
||||
classLoaderMap.put(ccl.hashCode(), bundles);
|
||||
bundles.add(0, XWORK_MESSAGES_BUNDLE);
|
||||
bundles.add(XWORK_MESSAGES_BUNDLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,14 +132,13 @@ public class LocalizedTextUtil {
|
||||
ClassLoader ccl = null;
|
||||
synchronized (classLoaderMap) {
|
||||
ccl = getCurrentThreadContextClassLoader();
|
||||
List<String> bundles = classLoaderMap.get(ccl.hashCode());
|
||||
Set<String> bundles = classLoaderMap.get(ccl.hashCode());
|
||||
if (bundles == null) {
|
||||
bundles = new ArrayList<String>();
|
||||
bundles = new HashSet<String>();
|
||||
classLoaderMap.put(ccl.hashCode(), bundles);
|
||||
bundles.add(XWORK_MESSAGES_BUNDLE);
|
||||
}
|
||||
bundles.remove(resourceBundleName);
|
||||
bundles.add(0, resourceBundleName);
|
||||
bundles.add(resourceBundleName);
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
@@ -198,7 +197,7 @@ public class LocalizedTextUtil {
|
||||
* @return a localized message based on the specified key, or null if no localized message can be found for it
|
||||
*/
|
||||
public static String findDefaultText(String aTextName, Locale locale) {
|
||||
List<String> localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
|
||||
Set<String> localList = classLoaderMap.get(getCurrentThreadContextClassLoader().hashCode());
|
||||
|
||||
for (String bundleName : localList) {
|
||||
ResourceBundle bundle = findResourceBundle(bundleName, locale);
|
||||
|
||||
Reference in New Issue
Block a user