ModifyPopulatorList
ModifyPopulatorList is somewhat a simplified ListMergeDirective and is used to modify a lists in PopulatorList objects. It adds or removes a populator from a populatorList bean. This mechanism allows new extensions to easily extend converters used in the system for propagating new data into higher layers.
Enabling ModifyPopulatorList
modifyPopulatorList is by default enabled in the SAP Commerce global application context:
Configuration Provided with Hybris
<bean id="lazyInitOverrideBeanFactoryPostProcessor" class="de.hybris.platform.spring.LazyInitOverrideBeanFactoryPostProcessor" > .. </bean> <bean class="de.hybris.platform.converters.impl.ModifyPopulatorListBeanPostProcessor"/> <bean id="modifyPopulatorList" class="de.hybris.platform.converters.impl.ModifyPopulatorList" abstract="true"/>
To enable modifyPopulatorList, add the following beans in a custom web context,:
Configuration to enable listMergeDirective
<bean id="webLazyInitOverrideBeanFactoryPostProcessor" parent="lazyInitOverrideBeanFactoryPostProcessor" /> <bean id="modifyPopulatorListBeanPostProcessor" class="de.hybris.platform.converters.impl.ModifyPopulatorListBeanPostProcessor"/>
You don't have to redefine the modifyPopulatorList bean because it is visible and accessible by all web contexts in Platform. It is important to use the same bean id because if an addon would also declare such BeanPostProcessor with different name, then every modifyPopulatorList would be applied twice.
Using ModifyPopulatorList
See the example configuration to learn how to add a populator into a list:
Adding a populator using modifyPopulatorList
<!-- populatorC will be added to populatoList bean named baseConverter --> <bean parent="modifyPopulatorList"> <property name="list" ref="baseConverter" /> <property name="add" ref="populatorC" /> </bean>
See the example configuration to learn how to remove a populator from a list:
Removing a populator using modifyPopulatorList
<!-- populatorB will be removed from populatoList bean named baseConverter --> <bean parent="modifyPopulatorList"> <property name="list" ref="baseConverter" /> <property name="remove" ref="populatorB" /> </bean>
ModifyPopulatorList doesn't have any other options but it affects all beans that use a given list as a parent bean (directly or indirectly).
How It Works
The de.hybris.platform.converters.impl.ModifyPopulatorListBeanPostProcessor class is the heart of the ModifyPopulatorList mechanism. ModifyPopulatorListBeanPostProcessor is a BeanPostProcessor class that during creation of beans reacts to beans of the de.hybris.platform.converters.impl.ModifyPopulatorList type and applies modifications stored in them. ModifyPopulatorList beans are only data structures that hold information about where and what needs to be added. They contain no logic at all. Because ModifyPopulatorListBeanPostProcessor reacts only to created beans, it is important to have ModifyPopulatorList beans eagerly loaded. This is done using LazyInitOverrideBeanFactoryPostProcessor that ensures that important configuration beans are loaded eagerly.