title: Dynamic @Value-equivalent in Spring?
body: <p>I have a Spring-managed bean that loads properties using a <code>property-placeholder</code> in its associated <code>context.xml</code>:</p>
  
  <pre><code>&lt;context:property-placeholder location="file:config/example.prefs" /&gt;
  </code></pre>
  
  <p>I can access properties using Spring's <code>@Value</code> annotations at initialisation, e.g.:</p>
  
  <pre><code>@Value("${some.prefs.key}")
  String someProperty;
  </code></pre>
  
  <p>...but I need to expose those properties to other (non-Spring managed) objects in a generic way. Ideally, I could expose them through a method like:</p>
  
  <pre><code>public String getPropertyValue(String key) {
    @Value("${" + key + "}")
    String value;
  
    return value;
  }
  </code></pre>
  
  <p>...but obviously I can't use the <code>@Value</code> annotation in that context. Is there some way I can access the properties loaded by Spring from <code>example.prefs</code> at runtime using keys, e.g.:</p>
  
  <pre><code>public String getPropertyValue(String key) {
    return SomeSpringContextOrEnvironmentObject.getValue(key);
  }
  </code></pre>