Composition Handlers
Composition handlers compose grouped raw items into canonical items.
Composition handlers are extensions. They each have their own extension XML file, their own Spring XML file, and their own java source code. These three elements compress into a jar file and placed in the directory at /opt/datahub/extensions, which is where all Data Hub extensions are kept. There are three default composition handlers that perform important, basic composition tasks. These three default handlers are described in the following sections.
Determining the Order of Execution
The three default handlers have a set order of execution. To create a custom handler, use the order property to set the execution order of the custom handler in the Spring XML file. The default composition handler order numbers are 1, 2, and 999 and are reserved for use by Data Hub.
A sample Spring file for a custom handler follows:
<bean class="com.hybris.datahub.grouping.impl.CustomerAddressRelGroupingHandler" id="customerAddressRelGroupingHandler">
<property value="10" name="order"/>
<property name="rawItemService" ref="rawItemService"/>
</bean>
How a Composition Handler Works
- The first default handler addresses localized values. If the Grouped, raw fragment had both English and German product information, the first default handler would harvest that information, compose it, and add it to the canonical item.
- The second default handler addresses situations where an attribute has multiple values. An example would be a canonicalProduct (hat) that came in many colors. These are called collection attributes. Again, the harvested attributes are composed and added to the canonical item.
- You may have defined custom handlers. The custom handlers are applied after the second default handler.
- The last handler is also a default handler. It populates a simple value such as name or gender. All attributes not captured by previous handlers are captured by this default handler. This handler also captures, composes, and adds to the canonical item.
Each Grouped, raw fragment becomes a canonical item when all of the raw item attributes in the fragment have been processed by the various composition handlers.
What You Can Accomplish with a Composition Handler
Default composition handlers can be used to change data or add data. Additionally, a custom composition handler can be used to rearrange data in your canonical record by capturing and processing it before the final default handler.