Friday, June 11, 2010

Spring configuration: initial a list

We often see inital a list in a bean definition, like this

    <bean id="changeSetPolicy" class="com.elasticpath.service.changeset.impl.ChangeSetPolicyImpl">
        <property name="changeSetDependentResolvers">
            <list>
                <ref bean="productChangeSetDependencyResolver" />
                <ref bean="productBundleChangeSetDependencyResolver" />
                <ref bean="categoryChangeSetDependencyResolver" />
                <ref bean="skuChangeSetDependencyResolver" />
            </list>
        </property>
    </bean>

We may need initial the list separately so that it could be override.

    <util:list id="changeSetDependentResolvers">
                <ref bean="productChangeSetDependencyResolver" />
                <ref bean="productBundleChangeSetDependencyResolver" />
                <ref bean="categoryChangeSetDependencyResolver" />
                <ref bean="skuChangeSetDependencyResolver" /> 
    </util:list>

<bean id="changeSetPolicy" class="com.elasticpath.service.changeset.impl.ChangeSetPolicyImpl">
        <property name="changeSetDependentResolvers" ref=”changeSetDependentResolvers”/>
</bean> 

No comments:

Post a Comment