Hybris里极其重要的概念。
之前的issue谈到了Hybris MVC里的M指的是DTO,JSP作为V显示DTO的value,而DB层的Model和DTO的结构不一致。
那么,数据从DB读取之后,需要经过一个转换,写入到DTO。执行这个转换的role,就是Convertor+Populator。

注:DTO是软件设计里一个common的概念,不是Hybris特有。定义见wiki

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.
先看CRM。

line 17的方法从CDS view里读取persistent data:

这样做类比。

可以看到CRM两个layer之间的转换非常light weight,仅仅是几个赋值操作。
Hybris里把这个赋值操作封装到了两个新的object里:Converter和Populator。
为什么要搞这么麻烦:

(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.
即Converter负责创建Data object的实例(就是Java class的实例), Populator负责call这个实例的setter方法把业务数据写入data obeject,这样JSP绑定到这些data object的某个属性的field就能显示出来值。

既然Hybris基于Spring,那么也要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.

看具体的例子:

这个文件位置:
“C:\Hybris\6.5.0.0.23546\hybris\bin\ext-accelerator\acceleratorservices\src\de\hybris\platform\acceleratorservices\payment\cybersource\converters\populators\PaymentDataPopulator.java”

为什么要单独抽象这两个object出来?和CRM Genil layer的实现一对比就清楚了。

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

SAP Hybris的Convertor, Populator, Facade和DTO这几个概念是如何协同工作的相关推荐

  1. 一个基于SAP Hybris Commerce和微信的社交电商原型介绍

    本文是2020年第12篇原创文章,也是汪子熙公众号总共第195篇原创文章. 汪子熙在刚刚过去的SAP中国上海2020 DKOM大会上,SAP大佬们在Key Note讲话时提到了最近国内火爆的线上新经济 ...

  2. 我的SAP Hybris学习笔记

    问题 Hybris 产品的开发性平台怎么样,是否可以快速响应用户需求? 回答 Hybris 后台基于 Java Spring,因此开发性和扩展性极佳.采用 Spring 的依赖注入和控制反转思想,可以 ...

  3. 解读SAP Hybris为何获国内B2B用户青睐?

    过去几年来,SAP Hybris作为SAP引入中国的一个重要电商平台软件,吸引了B2C零售及消费品等行业用户的青睐,并摘取了累累硕果. 不过,记者近日自SAP召开的媒体沟通会上获悉,在过去的一年中,S ...

  4. SAP Hybris: 中国B2B电商转型势在必行

    随着互联网的迅猛发展,电子商务几乎重塑了世界贸易格局,电商的出现为全球经济注入新活力的同时,传统的经营模式和经营理念正逐渐被驱逐出商业圈,尤其是B2B商业模式的出现,对互联网经济来说,是一场具有影响力 ...

  5. SAP Hybris电子商务最新功能

    SAP Hybris 电子商务6.0中国加速器是专为中国市场设计的电子商务平台,可满足企业在全渠道销售和订单履行方面的所有需求.新版的中国加速器基于SAP Hybris核心加速器之上进行开发,通过添加 ...

  6. Eclipse 里一个 SAP Hybris Commerce 的开发插件

    在 Eclipse Marketplace 里根据关键字 Hybris 搜索,查到一个名为 SAP Hybris Commerce Development Tools for Eclipse 1.4 ...

  7. 如何在 SAP Hybris WCMS cockpit 里创建新的 website

    首先使用如下 url,登录 SAP Hybris CMS cockpit: https://localhost:9002/cmscockpit/login.zul 看到系统已有的 WebSite 列表 ...

  8. SAP Hybris和Netweaver的租户隔离(Tenant isolation)机制设计

    ABAP里的tenant isolation是通过DB table的client ID来区分的. Hybris也有multi tenant的concept: Hybris multi tenant典型 ...

  9. SAP Hybris的build callback和SAP ABAP的SGEN事务码

    这个issue AIM in CRM and C4C里介绍了C4C和CRM的After import mechanism. 在Hybris里,客户把2个G的Hybris安装包下载下来,然后在命令行里运 ...

最新文章

  1. 自绘制View---------左右滑动刻度调频View
  2. 微信分享 ajax冲突,微信jssdk分享功能开发及解决ajax跨域的问题
  3. 工作流实战_26_flowable 变量判断汇总
  4. 愤怒的小鸟的html制作,如何做html5山寨版愤怒的小鸟
  5. servlet实现登陆注册
  6. NOD32 2.7、3.0最新升级ID 每天实时同步更新
  7. 拓端tecdat|R语言CRAN软件包Meta分析
  8. VBA实战技巧精粹之按某列相同数据分入同一个sheet
  9. IsPostBack介绍
  10. 关于Android的ImageView置顶
  11. 华为----园区网络三层架构实验
  12. python爬虫--爬取小猪网的租房信息
  13. 【Android开发笔记】4.简单基站定位程序
  14. java数组位置_java数组中如何查找元素的位置?
  15. 微信小程序授权登录取消授权重新授权处理方法 附可用代码
  16. 怎样在左边增加中国农历?
  17. 【实习】解决请求参数过长问题
  18. 『VulnHub系列』Hacker Fest: 2019-Walkthrough
  19. JAVA基础知识总结:一到二十二全部总结
  20. js 模拟enter键

热门文章

  1. ListView的Adapter使用(绑定数据) 之 自定义每一项的布局去绑定数据(二)
  2. win7下删除提示没权限删除文件的方法
  3. 适合小白了解学习的DevOps实践
  4. [IDEA中SSM整合,前端页面jsp] tomcat一开始访问jsp页面就报404错误
  5. 尚硅谷_jQuery_学习笔记
  6. Leetcode 187.重复的DNA序列
  7. GALV_maptravel研究分析(1)
  8. Random Maze HDU - 4067 费用流/可行流
  9. excel表数据对比 个人收集
  10. MySQL 中NULL和空值的区别