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