title: JSF Internationalization f:loadbundle or through faces-config: Performance point
body: <p>There are two ways to load the properties file into JSF 2.0.</p>
  
  <ol>
  <li>Global Resource Bundle
  To load the properties file globally, so that all the jsf pages can access the messages. You can create a “faces-config.xml” file and declare the properties file explicitly.</li>
  </ol>
  
  <p>faces-config.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;faces-config
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
      version="2.0"&gt;
       &lt;application&gt;
        &lt;resource-bundle&gt;
          &lt;base-name&gt;com.mkyong.messages&lt;/base-name&gt;
          &lt;var&gt;msg&lt;/var&gt;
         &lt;/resource-bundle&gt;
       &lt;/application&gt;
  &lt;/faces-config&gt;
  </code></pre>
  
  <p><strong>Option 2:</strong> Local Resource Bundle
  To load the properties file locally, or for specified page only. Declare the <code>&lt;f:loadBundle /&gt;</code> tag in the page that need to access the message in the messages.properties. </p>
  
  <p>Out of these two which one gives me better performance?</p>
  
  <p>Lets say I going with 1st option, does it means all the bundles gets loaded during the application startup or is it lazy loading? (on demand)</p>
  
  <p>If choose a 2nd option, does it potentially cause bundle to get loaded multiple time for each ViewRoot?</p>
  
  <p>Is the Java ResourceBundle is factory class which provides singleton object within servlet container?</p>
  
  <p>I mean getBundle method is factory method which creates singleton object for always?  </p>
  
  <pre><code>ResourceBundle myResources =
        ResourceBundle.getBundle("MyResources", currentLocale);
  </code></pre>
  
  <p>Lets say I have a page abc.xhtml and I am using f:loadBundle, and there 1000 users accessing this page, does this mean there would 1000 resouceBundle object created? or is it only object which is being shared by all the page instances?  </p>