I was doing some profiling on our application and we've identified Page.getResourceBundle as one hotspot. It eventually ends up going to java.util.ResourceBundle.getBundle, which throws a MissingResourceException since we're not using page specific resource bundles. However, this absence of page specific resource bundle is not cached and ResourceLoader.loadBundle gets called over and over. As an attempt to fix the issue, we started caching the result of ResourceLoader.loadBundle in the Page object.
private static final ResourceBundle NONEXISTENT_BUNDLE = new ResourceBundle() {
public Enumeration<String> getKeys() { return null; }
protected Object handleGetObject(String key) { return null; }
public String toString() { return "NONEXISTENT_BUNDLE"; }
};
public java.util.ResourceBundle getResourceBundle() {
String resourceBundleName = getResourceBundleName();
if (resourceBundleName == null) {
return null;
} else {
if (bundle == null) {
bundle = ResourceLoader.instance().loadBundle(
resourceBundleName);
if (bundle == null)
bundle = NONEXISTENT_BUNDLE;
}
return bundle == NONEXISTENT_BUNDLE ? null : bundle;
}
}
and we did notice some performance gains. Is there any foreseeable problem in caching the result of the call to ResourceLoader.instance().loadBundle?
Thanks.