title: How Spring loads properties file in memory?
body: <p>Am really new to spring, so please don't get angry and bear with me for a while.</p>
  
  <p>I'm trying to understand how <code>application.properties</code> or any other external config file values gets associated with the places where config file's keys (<code>value="${log4j.configuration}"</code>) are mentioned to consume their values from file itself.</p>
  
  <p>For example below is spring bean xml file:</p>
  
  <pre><code>&lt;bean id = "propertiesToBeTaken"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="locations"&gt;
          &lt;list&gt;
              &lt;value&gt;classpath*:application.properties&lt;/value&gt;
              &lt;value&gt;classpath*:*keys.properties&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="log4jLoader" class="my.loader.Log4jLoader"&gt;
          &lt;property name="log4jCongif" value="${log4j.configuration}" /&gt;
  &lt;/bean&gt; 
  </code></pre>
  
  <p>As you can see, <code>propertiesToBeTaken</code> is an instance of class <code>org.springframework.beans.factory.config.PropertyPlaceholderConfigurer</code>.</p>
  
  <p>And in second case ,<code>log4jLoader</code> is an instance of class <code>my.loader.Log4jLoader</code>, where <code>log4j.configuration</code> key's value is assigned to Log4jLoader class's instance variable <code>log4jCongif</code>. </p>
  
  <p>My questions are below:</p>
  
  <ol>
  <li>There is no <code>locations</code> variable in class <code>PropertyPlaceholderConfigurer</code>, then what is <code>locations</code> here and from where it came ? How can I relate <code>locations</code> to class's instance <code>propertiesToBeTaken</code>?</li>
  <li>If lets say, <code>application.properties</code> key value pairs gets loaded into memory, then who or I mean which method loads that ? And even if it gets loaded then how those key value pairs of <code>application.properties</code> file are accessible to <code>Log4jLoader</code>'s instance variables...?</li>
  <li>Last but I think it could very stupid question, In class <code>log4jLoader</code> class, there is a <code>setLog4jConfig(String log4jpropertiesLocation)</code>, but I really cant see who is calling this method. Just correct me here, Its not true, that In spring what ever the beans of object we have created, calls automatically class's instance methods. RIGHT ? I need to search more in code. CORRECT ?</li>
  </ol>
  
  <p>Please put some light on my doubts here. Read about this alot on spring docs and online as well, but could not understand. Really want to understand how it's happening.</p>
  
  <p>Thanks</p>