ModifableConfigurablePopulator

The ConfigurablePopulator interface extends the Populator interface by allowing a collection of Enum type data options to be available for use.

The DefaultModifableConfigurablePopulator class is the default implementation of the ModifiableConfigurablePopulator and ConfigurablePopulator which only invokes set Populators that add data for given data options. This functionality is vital from a performance and bandwidth perspective. The point is to only convert what is required and when it is required by specifying exactly which populators should be used programmatically.

Converting an entire object may be costly from a performance point of view. For example, consider unnecessarily evaluating promotions for a product, or attaching classification data when not required. Also, for example, a product description can be rather sizable, and therefore returning it in a web service call is not necessary. Configurable Populators also allow you to inject extra population logic into a population pipeline without the need to replace or override the existing code.

Modifiable Configurable Populators

The modifiable configurable populators enable you to modify ConfigurablePopulator that implements the ModifiableConfigurablePopulator interface. This includes adding populators to, and removing them from already configured ConfigurablePopulator beans. Modifications are configured as Spring beans that extend the abstract configurablePopulatorModification parent bean. They register themselves with a target populator during context initialization.

The converters-spring.xml file contains the definition of the abstract configurablePopulatorModification parent bean, which defines the init method that executes the registration with the target populator, as follows:

converters-spring.xml

<bean id="lazyInitOverrideBeanFactoryPostProcessor" class="de.hybris.platform.spring.LazyInitOverrideBeanFactoryPostProcessor" > ... </bean>
				<bean class="de.hybris.platform.converters.impl.ModifyPopulatorListBeanPostProcessor"/>
				<bean id="configurablePopulatorModification" class="de.hybris.platform.converters.config.ConfigurablePopulatorModification" abstract="true" />
See how to use this functionality in a web context:
<bean id="webLazyInitOverrideBeanFactoryPostProcessor" parent="lazyInitOverrideBeanFactoryPostProcessor" />
					<bean id="modifyPopulatorListBeanPostProcessor" class="de.hybris.platform.converters.impl.ModifyPopulatorListBeanPostProcessor"/>

Sample Usages of Modifiable Configurable Populators

The following example shows how to add a populator:

Adding a populator

<bean parent="configurablePopulatorModification">
				<property name="target" ref="defaultProductConfiguredPopulator" />
				<property name="keyType" value="de.hybris.platform.commercefacades.product.ProductOption" />
				<property name="key" value="VOLUME_PRICES" />
				<property name="add" ref="productVolumePricesPopulator" />
				</bean>

The following example shows how to remove a populator:

Removing a populator

<bean parent="configurablePopulatorModification">
				<property name="target" ref="defaultProductConfiguredPopulator" />
				<property name="keyType" value="de.hybris.platform.commercefacades.product.ProductOption" />
				<property name="key" value="VOLUME_PRICES" />
				<property name="remove" ref="productVolumePricesPopulator" />
				</bean>

The ConfigurablePopulatorModification type is able to resolve the following key types:

  • java.lang.String

  • java.lang.Class

  • enum types (such as the de.hybris.platform.commercefacades.product.ProductOption enum type shown in the two examples above)

How It Works

The de.hybris.platform.converters.impl.ModifableConfigurablePopulatorPostProcessor class is defined in Platform. It reacts to beans of the de.hybris.platform.converters.config.ConfigurablePopulatorModification type, and applies modifications those beans store to target beans.

Because ModifableConfigurablePopulatorPostProcessor reacts only to created beans, it is important to have ConfigurablePopulatorModification beans eagerly loaded. This is done using LazyInitOverrideBeanFactoryPostProcessor that ensures important configuration beans are loaded eagerly.