Pull bundle loading out into a method so subclasses can have their way with it
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5685 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -144,18 +144,7 @@ public class MessageManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if it's not cached, we'll need to resolve it
|
// if it's not cached, we'll need to resolve it
|
||||||
String fqpath = _prefix + path;
|
ResourceBundle rbundle = loadBundle(_prefix + path);
|
||||||
ResourceBundle rbundle = null;
|
|
||||||
try {
|
|
||||||
if (_loader != null) {
|
|
||||||
rbundle = ResourceBundle.getBundle(fqpath, _locale, _loader);
|
|
||||||
} else {
|
|
||||||
rbundle = ResourceBundle.getBundle(fqpath, _locale);
|
|
||||||
}
|
|
||||||
} catch (MissingResourceException mre) {
|
|
||||||
log.warning("Unable to resolve resource bundle " +
|
|
||||||
"[path=" + fqpath + ", locale=" + _locale + "].");
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the resource bundle contains a special resource, we'll
|
// if the resource bundle contains a special resource, we'll
|
||||||
// interpret that as a derivation of MessageBundle to instantiate
|
// interpret that as a derivation of MessageBundle to instantiate
|
||||||
@@ -165,8 +154,7 @@ public class MessageManager
|
|||||||
try {
|
try {
|
||||||
mbclass = rbundle.getString(MBUNDLE_CLASS_KEY).trim();
|
mbclass = rbundle.getString(MBUNDLE_CLASS_KEY).trim();
|
||||||
if (!StringUtil.isBlank(mbclass)) {
|
if (!StringUtil.isBlank(mbclass)) {
|
||||||
bundle = (MessageBundle)
|
bundle = (MessageBundle)Class.forName(mbclass).newInstance();
|
||||||
Class.forName(mbclass).newInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MissingResourceException mre) {
|
} catch (MissingResourceException mre) {
|
||||||
@@ -192,6 +180,23 @@ public class MessageManager
|
|||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a bundle from the given path, or returns null if it can't be found.
|
||||||
|
*/
|
||||||
|
protected ResourceBundle loadBundle (String path)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if (_loader != null) {
|
||||||
|
return ResourceBundle.getBundle(path, _locale, _loader);
|
||||||
|
}
|
||||||
|
return ResourceBundle.getBundle(path, _locale);
|
||||||
|
} catch (MissingResourceException mre) {
|
||||||
|
log.warning("Unable to resolve resource bundle", "path", path, "locale", _locale,
|
||||||
|
mre);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The prefix we prepend to resource paths prior to loading. */
|
/** The prefix we prepend to resource paths prior to loading. */
|
||||||
protected String _prefix;
|
protected String _prefix;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user