Oct 30th, 2012, 06:24 AM
Loading different set of beans based on value of a system property
I have 2 sets of beans. I want to load one of these sets based on a system property through spring context file.
Can I do this using spring?
Example: if the system property repositoryLoad = true
i want to load
<bean id="mapppingLoader" class="RepositoryMappingDefinitionLoader"></bean>
<bean id="routingScriptLoader" class="RepositoryScriptDefinitionLoader"></bean>
<bean id="mapppingLoader" class="CacheMappingDefinitionLoader"></bean>
<bean id="routingScriptLoader" class="CacheMappingDefinitionLoader"></bean>
Oct 30th, 2012, 07:29 AM
I suggest you read the reference guide, what you want can be achieved using profiles...
Oct 30th, 2012, 11:41 PM
Originally Posted by Marten Deinum
But I am using Spring 3.0.5 not 3.1.
Oct 31st, 2012, 01:47 AM
Then it might be worth an upgrade (should be a drop-in replacement).
Else create a factorBean for each bean which returns a different instance based on the property.
Oct 31st, 2012, 01:58 AM
Thanks Marten for the reply..
I think I wont be able to go with upgradation. I will do with factoryBean.