I have two xml files defining beans for the springframework (version 2.5.x):
containerBase.xml:
<beans>
<bean id="codebase" class="com.example.CodeBase">
<property name="sourceCodeLocations">
<list>
<value>src/handmade/productive</value>
</list>
</property>
</bean>
</beans>
... and
containerSpecial.xml:
<beans>
<import resource="containerBase.xml" />
</beans>
Now I want to adjust the property "sourceCodeLocations" of bean "codebase" within "containerSpecial.xml". I need to add a second value "src/generated/productive".
A simple approach is to override the definition of "codebase" in "containerSpecial.xml" and add both values, the one from "containerBase.xml" and the new one:
containerSpecial.xml:
<beans>
<import resource="containerBase.xml" />
<bean id="codebase" class="com.example.CodeBase">
<property name="sourceCodeLocations">
<list>
<value>src/handmade/productive</value>
<value>src/generated/productive</value>
</list>
</property>
</bean>
</beans>
Is there a way to extend the list without redefining the bean?
EDIT 2009-10-06:
The purpose of this is to have a shared standard container containerBase
that is used by a lot of different projects. Each project can override/ extend some properties that are special for that project in its own containerSpecial
. If the project doesn't override, it's using the defaults defined in containerBase
.