Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How SAP Hybris's Convertor, Populator, Facade and DTO concepts work together

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

SAP Hybris's Convertor, Populator, Facade and DTO concepts work together, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can get something.

An extremely important concept in Hybris.

The previous issue mentioned that M in Hybris MVC refers to the value of DTO,JSP as a V display DTO, while the structure of Model and DTO in the DB layer is inconsistent.

Then, after the data is read from the DB, it needs to be converted and written to the DTO. The role that performs this transformation is Convertor+Populator.

Note: DTO is a common concept in software design, not unique to Hybris. For the definition, see [wiki] (https://en.wikipedia.org/wiki/Data_transfer_object))

# official definition of Hybris

(1) Facade: A facade is a software design pattern that abstracts from an underlying implementation and offers an alternate, often reduced and less complex interface.

(2) DTO:Data Transfer Objects (DTOs) are objects created to only contain values and have no business logic except for getter and setter methods. Using DTOs, you can "combine" Hybris items-for example, this document adds price- and media-related data to a product object.

Let's take a look at CRM.

The method of line 17 reads persistent data from CDS view:

To make an analogy.

You can see that the conversion between CRM's two layer is very light weight, just a few assignment operations.

Hybris encapsulates this assignment in two new object: Converter and Populator.

Why go to so much trouble:

(1) Data objects are constructed from Models or other Service Layer objects using Converters and Populators. The Data object is always created from a prototype-scoped spring bean that is defined in the beans.xml file for the extension.

(2) Converters create new instances of Data objects and call Populators to populate these.

That is, Converter is responsible for creating instances of Data object (that is, instances of Java class), and Populator is responsible for writing business data to data obeject by the setter method of call, so that the field of JSP bound to one of the attributes of these data object can display the value.

Since Hybris is based on Spring, there are also some principles of follow Spring:

(1) No concrete Converters should be written, all converters should be Spring configured only and should use the AbstractConverter base class.

(2) No Populator should be called directly in code, Converters should be Spring injected and used.

(3) All conversion logic should exist in Populators and these should be well-encapsulated and independent.

# Populators

Populators break the conversion process of filling out a Data Object down into a pipeline of population tasks or steps. Each Populator carries out one or more related updates to the Data Object prototype. Each population step can invoke services or copy data from the source business object to the prototype Facade Data object. Facades always use a Converter to create a new instance of a Data Object prototype and then invoke Populators or other Converters to fulfill the task of building up the Data Object.

Look at specific examples:

This file location:

"C:\ Hybris\ 6.5.0.0.23546\ hybris\ bin\ ext-accelerator\ acceleratorservices\ src\ de\ hybris\ platform\ acceleratorservices\ payment\ cybersource\ converters\ populators\ PaymentDataPopulator.java"

Why should these two object be abstracted separately? It is clear when compared with the implementation of CRM Genil layer.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report