1 Reply Latest reply on Feb 19, 2010 6:51 PM by Mark Torres

    Performance on Page.getResourceBundle and Messages

    Mark Torres Newbie

      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.

        • 1. Re: Performance on Page.getResourceBundle and Messages
          Mark Torres Newbie

          While the fix to Page.getResourceBundle improved the performance, we stumbled again on one more bottleneck which is SeamResourceBundle.handleGetObject. This method is iterating through configured message bundles, and performing the lookup of the messages. We did have a couple of files where we're putting the messages, to try to organize our messages a little bit. Merging them in one big file definitely improved the performance.