title: Spring loading properties from a bean
body: <p>I am currently usinmg <code>PropertyPlaceholderConfigurer</code> to load properties into my spring context, however I want to have a custom hierarchy/overriding of property files that I am handling in a Java class. Can I have my class, which itself is a bean in the context, inject the properties into the context?</p>
  
  <p>e.g.</p>
  
  <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="locations" value="classpath:/config/conf.properties" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="config" class="com.main.Config" /&gt;
  </code></pre>
  
  <p>My Config class has a <code>Properties getProperties()</code>  method -- can I wire that into spring somehow? Obviously the properties would not be loaded until the config bean is created or inited.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Update</strong>: As suggested by the answer I change my Config to <code>Config extends PropertySource&lt;Properties&gt;</code> and had to write a small wrapper around <code>MutablePropertySources</code> that takes a single <code>PropertySource</code> and then my xml looks like this:</p>
  
  <pre><code>&lt;bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer"&gt;
      &lt;property name="propertySources"&gt;
          &lt;bean class="com.main.ConfigMutablePropertySources"&gt;
               &lt;constructor-arg name="propertySource" ref="config" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>public class ConfigMutablePropertySources extends MutablePropertySources {
      public ConfigMutablePropertySources(PropertySource&lt;?&gt; propertySource) {
          super(new MutablePropertySources());
          addLast(propertySource);
      }
  }
  </code></pre>