title: Passing properties to a Spring context
body: <p>I'm using Spring to handle RMI calls to some remote server. It is straightforward to construct an application context and obtain the bean for remote invocations from within the client:</p>
  
  <pre><code>ApplicationContext context = new ApplicationContext("classpath:context.xml");
  
  MyService myService = (MyService ) context.getBean( "myService " );
  </code></pre>
  
  <p>However I don't see a simple way to pass properties into the configuration. For example if I want to determine the host name for the remote server at runtime within the client.</p>
  
  <p>I'd ideally have an entry in the Spring context like this:</p>
  
  <pre><code>&lt;bean id="myService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"&gt;
    &lt;property name="serviceUrl" value="rmi://${webServer.host}:80/MyService"/&gt;
    &lt;property name="serviceInterface" value="com.foo.MyService"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>and pass the properties to the context from the client as a parameter.</p>
  
  <p>I can use a PropertyPlaceholderConfigurer in the context to substitute for these properties, but as far as I can tell this only works for properties read from a file. </p>
  
  <p>I have an implementation that addresses this (added as an answer) but I'm looking for a standard Spring implementation to avoid rolling my own. Is there another Spring configurer (or anything else) to help initialise the configuration or am I better off looking at java config to achieve this?</p>