title: Conditional Spring configuration
body: <p>Is it possible to use conditional expressions in a Spring config?</p>
  
  <p>E.g. I'd like to define two different connectors like this:</p>
  
  <p>Connector 1:</p>
  
  <pre><code>&lt;spring:bean id="MyConnector" class="org.test.provider.DBConnector"&gt;
      &lt;spring:property name="host" value="${my.config.host}"/&gt;
      &lt;spring:property name="user" value="${my.config.user}"/&gt;
      &lt;spring:property name="password" value="${my.config.password}"/&gt;
  &lt;/spring:bean&gt;
  </code></pre>
  
  <p>Connector 2:</p>
  
  <pre><code>&lt;spring:bean id="MyConnector" class="org.test.provider.FileSystemConnector"&gt;
      &lt;spring:property name="path" value="${my.config.path}"/&gt;
  &lt;/spring:bean&gt;
  </code></pre>
  
  <p>Then, later, use one of those like this:</p>
  
  <pre><code>&lt;spring:bean id="LookupCommand" class="org.test.lookup.LookupCommand"
      scope="prototype"&gt;
      &lt;spring:property name="connector" ref="MyConnector"/&gt;
  &lt;/spring:bean&gt;
  </code></pre>
  
  <p>Depending on, lets say, <code>${my.config.connectorType}</code> from my .cfg file, I'd like to chose/activate one of those two:</p>
  
  <pre><code>if ${my.config.connectorType} == DB then
  
      &lt;spring:bean id="MyConnector" class="org.test.provider.DBConnector"&gt;
          &lt;spring:property name="host" value="${my.config.host}"/&gt;
          &lt;spring:property name="user" value="${my.config.user}"/&gt;
          &lt;spring:property name="password" value="${my.config.password}"/&gt;
      &lt;/spring:bean&gt;
  
  else
  
      &lt;spring:bean id="MyConnector" class="org.test.provider.FileSystemConnector"&gt;
          &lt;spring:property name="path" value="${my.config.path}"/&gt;
      &lt;/spring:bean&gt;
  end
  ...
  &lt;spring:bean id="LookupCommand" class="org.test.lookup.LookupCommand"
      scope="prototype"&gt;
      &lt;spring:property name="connector" ref="MyConnector"/&gt;
  &lt;/spring:bean&gt;
  </code></pre>