Monday, September 21, 2009

Spring configuration: collection merging

We have some spring configuration like this.

<bean id="entityLocator" class="com.elasticpath.tools.sync.merge.configuration.impl.EntityLocatorDelegateImpl">
    <property name="guidLocator" ref="guidLocator"/>
    <property name="entityLocators">
        <list>
            <ref bean="priceListDescriptorLocator" />
            <ref bean="productBundleLocator" />
            …
        </list>
    </property>
</bean>


We allow the user implement their own “locator” and add them into this map. The setting for user extension would be



<bean id="customEntityLocator" parent="entityLocator">
    <property name="entityLocators">
        <list merge="true">
            CUSTOMER_ENTITY_LOCATOR…
        </list>
    </property>
</bean>


The “merge=true” could also be used for merging map and set.



http://static.springsource.org/spring/docs/2.5.x/reference/beans.html#beans-collection-elements-merging

No comments:

Post a Comment