From: markt Date: Mon, 13 Jul 2009 21:49:14 +0000 (+0000) Subject: Prep required for the o.a.tomcat.util.res.StringManager to replace the o.a.c.util... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=83e6094bf0d4749236b6116eb303242969534a16;p=tomcat7.0 Prep required for the o.a.tomcat.util.res.StringManager to replace the o.a.c.util.StringManager Adds handling for when classloaders common != server != shared git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@793722 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/res/StringManager.java b/java/org/apache/tomcat/util/res/StringManager.java index 1b6381f07..a7b8765fb 100644 --- a/java/org/apache/tomcat/util/res/StringManager.java +++ b/java/org/apache/tomcat/util/res/StringManager.java @@ -68,9 +68,25 @@ public class StringManager { */ private StringManager(String packageName) { String bundleName = packageName + ".LocalStrings"; - bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault()); + try { + bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault()); + } catch( MissingResourceException ex ) { + // Try from the current loader (that's the case for trusted apps) + // Should only be required if using a TC5 style classloader structure + // where common != shared != server + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if( cl != null ) { + try { + bundle = ResourceBundle.getBundle( + bundleName, Locale.getDefault(), cl); + } catch(MissingResourceException ex2) { + } + } + } // Get the actual locale, which may be different from the requested one - locale = bundle.getLocale(); + if (bundle != null) { + locale = bundle.getLocale(); + } } /**