What are common strategies for defining a bunch of beans, which are used differently in development and production environments?
Let's say I have 2 beans, each implementing the same interface. One bean serves as abstraction for local filesystem, the other connects to a distributed filesystem. To keep the development as steady, as possible, the development environment should use local filesystem implementation, the production release uses distributed filesystem bean.
Currently what I'm doing is having two xml definitions.
native.xml
<bean id="resourceSystem" class="com.cust.NativeResourceSystem" />
distributed.xml
<bean id="resourceSystem" class="com.cust.HadoopResourceSystem">
<constructor-arg name="fs" ref="hdfs" />
</bean>
When creating application context I omit either native.xml
or distributed.xml
depending on environment and grab the resourceSystem
bean.
Are there any proper tools or best practices in Spring to configure bean definitions for different environments?
Thanks.