SAP Commerce(SAP Hybris)学习资料汇总
发布日期:2021-06-30 14:17:59 浏览次数:3 分类:技术文章

本文共 33961 字,大约阅读时间需要 113 分钟。

版本号:v1.06 2020年11月24日

所有的架构图在这个单独的里。

导航目录

SAP官方帮助文档

configuration

配置文件和运行时在admin console里两种

The HYBRIS_RUNTIME_PROPERTIES environment variable allows you to set a path that points to a custom properties file.

运行时动态更新配置:,定期轮询properties文件是否有变化。

配置文件的编码问题:

默认: ISO 8859-1

configuration template是一系列配置文件的集合,分devlelop和production两种,结构如下:

  • A local.properties file
  • Configuration files for Apache Tomcat, such as wrapper.conf or wrapper-debug.conf
  • A license file

两种配置文件:project.properties and local.properties.

Project properties are the SAP Commerce defaults, while local properties is where you may define your own configuration for your extension.

  • The project.properties file is located in the <HYBRIS_BIN_DIR>/platform directory, and provides factory default settings. It is not recommended to edit this file.
  • The local.properties file is a working copy of the project.properties file, located in the <HYBRIS_CONFIG_DIR> directory. It allows you to override default settings from the project.properties file.

  • bin/platform: The core SAP Commerce platform extensions that are loaded on startup. This directory also has the build framework, and extension templates.
  • data: Data files such as media files and LucerneSearch indexes. The directory also contains HSQLDB data files, if you are using the default database in a test or development environment.
  • log: Log files, including Tomcat and JDBC logs.

NEVER change anything within the bin directory. Do not keep any custom data configuration in this directory or any of the subdirectories. The upgrade process may replace the bin directory and subdirectories with a newer version of SAP Commerce and remove your changes.

默认的数据库:HSQLDB

  • SAP Commerce 1905 requires JDK 11 or later. It is fully compatible with SAP Machine 11.

Navigate to the <${HYBRIS_BIN_DIR}> /platform directory, call ant clean all to build the entire SAP Commerce solution.

包含一些默认filters的功能介绍。清单在

容器化支持

  • 不能用于生产用途。文件夹位置:installer/recipes. 这个包含了所有recipe的说明。

License文件:<HYBRIS_HOME>/config/license/installedSaplicenses.properties

也不能在一个目录里重复安装不同的recipe:

Don’t use the installer to run one recipe after another on the same SAP Commerce. The installer won’t uninstall previous configurations, and doesn’t restore your SAP Commerce file system to its original settings. To install a different recipe, use a clean environment.

  • 若干extensions组合在一起,以module的形式发布。

An extension can contain business logic, type definitions, a web application, or a Hybris Management Console configuration. That way, you link up in one place all of the functionality that covers a certain field of use, for example a webshop.

Addon是一种特殊的extension,扩展了Commerce Accelerator的功能。这种extension添加了UI页面,但又没有直接修改Storefront的实现。

AddOns extend the functionality of the SAP Commerce Accelerator. They are a type of extension that allow you to add front-end files such JSP, HTML, CSS, and JavaScript files, and images without modifying the storefront front-end files directly.

SAP Commerce Accelerator is built on an extensive framework that includes a template for storefront implementation. AddOns and extensions provide a well-defined infrastructure for third party developers to plug in their own functionality.

Using AddOns, you can extend the functionality of Commerce Accelerator without editing the core code base. The core code base in this context means the Commerce Platform, and all additional extensions delivered with Commerce Accelerator. An AddOn is a regular extension that may, or may not, provide additional front-end components to Commerce Accelerator.

Addon也是一种Extension,Storefront extension被addon扩展,在其extesnioninfo.xml里引用这个addon:

An AddOn is a regular SAP Commerce extension that is configured using the extensioninfo.xml file, located in the root folder of the AddOn. Additionally, the storefront extension that is extended by an AddOn has to reference this AddOn in the extensioninfo.xml file. The structure of this file is exactly the same as any regular extension.

Addon是accelerator Storefront的扩展技术。典型的文件夹层级结构:

在这里插入图片描述
the web folder contains both the src and the webroot subdirectories. After putting all the components you want to add into the proper folders, you need to run the following command on your system: ant build.

一旦build,会自动拷贝文件到Storefront Extension里,自动创建新的文件夹来容纳拷贝的文件:

在这里插入图片描述

  • web/addonsrc, which contains the source code for each installed AddOn. This gets compiled automatically.
  • web/webroot/WEB-INF/addons, which contains all the front-end components, such as images, JSP files, HTML files, and TAG files.

acc一旦升级,也不会覆盖掉我们的addon.

如果addon里直接添加jsp,css,图片等,不需要build platform, 如果添加新的java code到target Extension,就需要build platform.

The front-end items are stored in the acceleratoraddon folder of an AddOn. The structure within the acceleratoraddon folder mirrors the folder structure within the web folder, which contains the front-end components of a regular extension.

Addon里的accelerator文件夹是如何拷贝到Storefront文件夹里的?规则在这个里。

source: <addon_name>/acceleratoraddon/web/webroot/_ui

target: /web/webroot/_ui/addons/<addon_name>


source: <addon_name>/acceleratoraddon/web/src

target: /web/addonsrc/<addon_name>, 装的java代码。文件copy由build callback实现:

  1. The system scans for every extension that has a specific acceleratoraddon folder. Marker folders are defined as follows:
  • ${extension-path}/acceleratoraddon/web/webroot/_ui
  • ${extension-path}/acceleratoraddon/web/webroot/WEB-INF
  1. For each AddOn that is found, the system identifies the target extension.
    For each resource that is found in the acceleratoraddon folder, the system copies the contents to the target extension.

在beans.xml里也可以给DTO增加新的属性:

DIMENSIONS
MINIMAL

Similarly to the item.xml file, the definitions in the beans.xml file are merged automatically. In the example above, the ProductData file is not part of our example extension, but it is extended from the commerceservices extension. That means that during this process, you extended the API because you modified the data model. You do not need to replace the facade in this instance. All you need to do is plug in the populator from your extension, and it can be done multiple times.

这个包含了一个表格,可以查询Extension和Addon的ID和description.

一步步创建一个新的addon

An extension is an encapsulated piece of software that extends SAP Commerce functionality by either modifying existing features, or introduction new features.

Extension modules are structural elements of an extension.

Extension module是extension的一部分。

You can implement JUnit tests for the extension’s core extension module. The files for these JUnit tests must be located in the testsrc directory of the extension.

每个extension都有一个名叫core的 extension module,包含了该extension的type system definition,items.xml, 位于resources文件夹内。命名规范:

The name of this file is always defined accordingly: < e x t e n s i o n > − i t e m s . x m l w h e r e < extension> -items.xml where < extension>items.xmlwhere<extension> is the name of an extension.

与类型相关的Java source code文件也位于core extension module内。

Processing也是extension.

items.xml的.

  • web extension module: 是extension的一部分,可以通过浏览器访问:

To launch a web extension module via your web browser, go to the URL path to Platform on the server/name of extension/starting page. For example, if you are running myExtension locally on default settings, the URL would be http://localhost:9001/myExtension.

如何处理dependency

An extension that specifies an extension dependency will only be built once all the extensions specified in the list have been built.

Extension dependencies to the Platform extensions are very common. SAP Commerce therefore includes a special mechanism resolving such dependencies. This mechanism assumes that all extensions which are not located within the <HYBRIS_BIN_DIR> /platform/ext directory have extension dependencies on the Platform extensions.

his mechanism is enabled or disabled using the autoload attribute in the localextensions.xml file. By default the autoload attribute is set to true, and the extension dependency resolving mechanism is enabled. This means you do not need to add the Platform extensions to your extensioninfo.xml file to specify dependencies.

在config文件夹下:The localextensions.xml file overrides the extensions.xml file.

  • extensions.xml: <HYBRIS_BIN_DIR>/platform, Do not modify this file.

This file is used as a template and a fallback for the localextensions.xml file. Use localextensions.xml instead.

  • 什么是extension的core module:

A core module consists of an items.xml file (and therefore allows to add new types to the system), a manager class, classes for the JaLo Layer and the ServiceLayer and JUnit test classes. The following directories are required: /src, /resources, /testsrc.

While the Commerce Platform can run without any package, no package can run without the Commerce Platform.

Commerce platform也是由extension组成的,称为core extension. 在这些core extension之上才是build framework,和tomcat server.

ant

ant all和all clean all的区别:

If you run builds of SAP Commerce using ant all, the SAP Commerce build framework will have the compiled files from other extensions available. An extension dependency may then still exist, but will not be noticeable.

In contrast, if you run SAP Commerce builds using the ant clean all, the build framework will delete the compiled files prior to building extensions. A build failure to unmet extension dependencies is much more likely to occur this way.

什么是Hybris的initialization:

Initialization drops existing type definitions from the database prior to rebuilding, so the entire type system is created from scratch. So during an initialization, type system definitions are created to match the type system definition in the items.xml files.

Initialization的过程generate the database schema and the type system, and import any essential system data.

Platform目录下执行:ant initialize

Update: items.xml里定义的新类型,会施加到类型系统里。

  • 非常详细的讲解CMS模型的
  • 基于items.xml的定义生成types. 通过实现。

Technically, every extension that uses any SAP Commerce type depends on the core extension because the type system is part of the core extension.

An extension may depend on several other extensions. For example, if your extension allows running imports through Backoffice using a wizard, you have an extension dependency not only on the backoffice extension, but also on the impex extension.

Impex也是extension. Extension能使用其依赖的extension core module包含的resources和source,但web extension module的东西没办法访问。

Impex modifier

导入product的例子:

flexible search里的!感叹号的用法,

MediaDataTranslator负责导出media内容。

是Service Layer的foundation.

Dependent Injection: 组件的依赖不是其自身维护,而是配置在外部。

Dependency injection is a software architecture pattern in which a component’s dependencies are not managed by the component itself but are configured externally.

A so-called container (application context) reads the configuration file, resolves the dependencies, and puts together the objects. When the objects are ready, all the dependencies are already injected.

xml文件的位置:${HYBRIS_BIN_DIR}/platform/ext/core/resources

命名规范:

There you find files with the name pattern |component|-spring.xml, where is something like product, order, i18n, security, and so on. For the beans themselves, a name pattern such as xyzService is recommended, such as: productService, catalogService, and so on.

Service Layer的API通过interface暴露出来。interface的实现就是Spring beans,id name可以从SAP commerce API doc里找到。

在这里插入图片描述

[一个向导]

  • eclipse里只导入刚创建好的extension:
    <HYBRIS_BIN_DIR>/custom/training.
  • 手动添加the latest release of Spring MVC library?
  • Put the Spring MVC library JAR into the web/webroot/WEB-INF/lib folder of the training extension.

If you use Eclipse, be sure to reference the Spring MVC library JAR in the project’s build path, too. You need the spring-webmvc.jar in version 3.2.8

  • 在platform文件夹下,Call ant clean all to build the entire SAP Commerce software package.
  • 以debug方式启动服务器:hybrisserver.bat debug
  • - hello world级别的
  • Extensibility的奥秘:platform/ext/platformservices/resources/product-spring.xml

在我们自己的Extension里:

training/resources/training-spring.xml

Because your configuration file is loaded after the original configuration file, Spring uses your alias instead of the original one. Thus, wherever a reference to productService turns up, Spring uses your trainingProductService instead.

里修改Extension的items.xml可以自动生成model?

  • 什么是 - Data作为naming convention?

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” SAP Commerce items - for example, this document adds price- and media-related data to a product object.

Strategy: nA solution is to have the Business Services delegate to finer-grained components if necessary. This approach is known as Strategies.

SAP Commerce Accelerator is a ready-to-use web implementation template that enables you to jumpstart your implementation and easily build and maintain a feature-rich and flexible commerce solution.

为什么要用alias?Extensibility!

A use case maybe when you want to customize some beans that are already defined somewhere in a modular application (each module is a spring project for example), the bean maybe defined by a third-party framework/API or even your team. In that case you want that only inside your spring project call the customized version without altering other modules (projects), to do that just add the alias in your spring configuration which is indeed a powerful feature:

Hence, whenever spring find a call to the globalBeanService, it will inject customizedBeanService for you inside your specific module. Without this feature, you should go through all classes and modify the bean manually!!

yrequest scope:

may be used for binding beans to the application context for a single request. Upon session deactivation, the beans are no longer referenced from the application context, allowing them to be garbage collected. This is similar to a standard Spring request scope but is used outside of a web application context.

Bean被application context管理,所有extension的的配置文件形成core application context. 每个tenant都有自己的Application Context.

The construction process uses the classloader of the core extension. It has, as its parent, the (singleton) global application context.

bean id一定要unique,否则最后load的extension bean会overwrite之前的。

Web Application Context - why we need it?

To define the beans part of the Web Module of an extension or with scopes not available to the global ApplicationContext or core application contexts, like session or request, you need to configure a web ApplicationContext in the web.xml file. You also need access to the core ApplicationContext to access beans of the Core Module, such as services.

For this access, SAP Commerce provides a HybrisContextLoaderListener for setting the core ApplicationContext automatically as parent of your web ApplicationContext. With that, you can use the core bean definitions, for example to inject them into your web ApplicationContext beans. If you make a getBean call to your web ApplicationContext, it is checked whether there is a definition available. If not, the parent ApplicationContext is used.

也是由一系列Extension组成。

开发环境相关

一定在build之后再导入import,否则报class找不到。

If this happens, it means that you probably imported the project before you first run the initial Ant in the platform directory. The eclipse errors occur, because some classes are initially copied during this Ant process. So make sure that you first run Ant and then setup eclipse.

  • - 替换整个bin文件.
  • 调试,使用debug模式和develop configuration template.

是三层的统称:ServiceLayer Framework (including the actual ServiceLayer, the Infrastructure Services, and the Business Services)

relies on so-called models, which are POJOs. Attributes on models have automatically generated getter and setter methods. Models are generated based on types.

Service Layer的消费者为MVC controller,web service或者script.

A service holds the logic to perform business processes and provides this logic through a number of related public methods. These public methods usually are defined in a Java interface. Most often these methods operate on the same kind of model object, for example product, order, and so on.

和persistence layer是松耦合的。

所有功能都通过service暴露:

  • Business Services implement business use cases, such as cart handling or back order.
  • Infrastructure Services provide the underlying technical foundation, such as internationalization, import, export, and so on.
  • System services provide functionality required by the ServiceLayer, such as model handling and session handling.

其实就是interface,通过models和其他service交互。

Strategy

A service may delegate parts of its tasks to smaller micro-services, called strategies. The service then serves as a kind of façade to the strategies.

Clients still use the service and its stable API. But under the hood the functionality is split into multiple parts. Because these parts are smaller and very focused to their task, it is easier to adapt or replace them. Strategies therefore help to further encapsulate behavior and make it more adaptable.

其实就是策略模式。

Model

Models are a new way to represent SAP Commerce items. Each model contains all item attributes from all extensions thus unifying access to an item’s data. Models are generated from the type system of SAP Commerce.

Models are used by DAOs, services, strategies, converters, and facades.

During a SAP Commerce build, the build framework generates Model classes and configuration files for each item type. Models are generated across all extensions, no matter whether the extension is available in source code or in binary only. The Model generation process also ignores the value of the generated attribute of the element in the extensioninfo.xml file of the extension.

Models are generated into the bootstrap/gensrc directory.

You might ask why the generated Models end up in the platform and not in the extension where the type is defined? This is due to the way the SAP Commerce Build Framework operates.

naming convention: 以Model结尾。

As Models are generated during a early phase in the SAP Commerce build process - before actually building any extension - the Models are available by compile time.

  • lifecycle

A Model represents a state in the database. The representation is not live, that means that modified Model values are not written to the database automatically. Instead, when you modify a Model, you must explicitly save it to the database to have its state reflected there.

Model可以从数据库load,用构造函数或者工厂方法新建。

  • ModelService

一个java bean:

The ModelService is a service that deals with all aspects of a Model’s life cycle. It is available in Spring under the ID modelService and implements the de.hybris.platform.servicelayer.model.

  • Loading Models by pk
  • Loading Models from items
  • Creating Models
  • Updating Models
  • Deleting Models

增删改查CRUD方法都有。

Interceptor

只for model:

Interceptors check whether constraints set for the behavior of life cycles of models are fulfilled. Use interceptors to make sure you delete or persist the correct data only, and that you handle data properly.

Hooks for Initialization and Update Process

Use the @SystemSetup annotation in any ServiceLayer class to hook ServiceLayer code into the SAP Commerce initialization and update life-cycle events. In this way, you can provide a means for creating essential and project data for any extension.

Annotate the classes whose methods are to be executed. In the following example, the method createImportantModelDuringInitProcess is executed during the initialization process when the essential data for extension myextension is created.

@SystemSetup(extension = MyExtension.EXTENSIONNAME)public class SomeClass ... {
@SystemSetup(extension = MyExtension.EXTENSIONNAME, process = Process.INIT, type = Type.ESSENTIAL) public void createImportantModelDuringInitProcess(){
//create the model here }...

接收和发送commerce的事件。

event-service基于Spring event系统。

DefaultEventService allows you to register event listeners and publish events.

There is a DefaultEventService that implements the EventService interface (de.hybris.platform.servicelayer.event package). To use this service, add a Spring resource to your class.

@Resourceprivate EventService eventService;

In addition to the actual bean definition with an ID prefixed with default, there is an alias for the bean. The idea is that you should use the alias to override instead of using the actual bean ID in a hard-wired way. This is to ensure extensibility. You can override the alias ID and still have access to the original bean.

类型系统是对象的模板。platform里每个对象都是类型的实例。

Types定义了持久化对象:

  • Attribute存储对象的数据。
  • Deployment定义数据库表
  • java class

A Type is the type definition in items.xml and its Java implementation.

在这里插入图片描述

An object instance of a type is called an item:

类型分两种:System-related types and business-related types.

System-related types又由下列类型组成:

Infrastructure types: ComposedTypes (also referred to as ItemTypes) set up type definitions and may carry attributes to hold information. In the end, every persistent object in the SAP Commerce is an instance of ComposedType or of one of its subtypes.

Business-related types: (like Order, Discount, Shoe) allow you to manage product and / or customer information so that you can run your business.

在这里插入图片描述

every object stored in SAP Commerce is an instance of a type. Even type definitions are instances of the type Type. This means that there are two aspects of a type definition: it is an item and, at the same time, it defines other items.

To differentiate between normal object instances and type definitions, non-type objects in Platform are referred to as items. The lower case spelling item refers to an object in Platform; the upper case spelling Item refers to the type definition.

小写的items代表platform里non-type对象, 大写的代表类型定义。

The following code snippet defines an item called SpecialProduct that is a subtype of Product but its type is not defined as a ComposedType, but as a SpecialComposedType (via the metatype attribute). Instances of SpecialProduct are thus subtypes of Product, but the type definition is stored as a SpecialComposedType.

类型定义attribute,如同Java 类定义fields, attribute可以是复合类型或者简单Java类型。

三大module:

在这里插入图片描述

platform module feature

provides a range of features related to the main functionality of a SAP Commerce installation, that is, containerization, data management, synchronization, security, or localization.

  • build framework:code generation, jRebel
  • Caching, persistence layer的一部分,减少到db的query,详细在, 也缓存flexible search结果。
  • Secure HTTP Transactions:
  • 多节点共享数据库。
  • Platform, solr和data Hub需要打三个镜像。
  • - before save: a JSR 303-compliant validation engine
  • 一些常用filter列表:SessionFilter, ProfileFilter, Log4jFilter, RedirectWhenSystemIsNotInitializedFilter.
  • - 文件系统上的文件。

A media item in SAP Commerce is not a physical file, but a reference to that file.

  • - 把cart的存储放到external memory
SELECT * FROM table WHERE PK=X
  • [Product classification](The classification functionality enables you to define product attributes in a way different to the typing method. Classification-based attributes are called category features; they can also sometimes referred to classification attributes. Through classification, you can flexibly allocate category features that may change frequently. You can easily define and modify them because you manage them independently of the product type.)
  • - 另一套分类系统?

platform module architecture

The core extensions are autoloaded and they are located in <HYBRIS_BIN_DIR>/platform/ext.

  • :
    • : provides core helper methods for templates. These methods are used for media neutral handling of content to be exported.
      • formatter: converting item content to PDF, for example for converting an order to PDF.
      • Translator framework mainly used for converting of HTML documents to another format, for example to Adobe InDesign.
    • : handles basic functionality such as persistence handling, the ordering process and contains the service layer functionality.
      • deliveryzone: ext下面。
      • . 可以只启动hac.

      To do this, run adminserver.bat instead of hybrisserver.bat. As you can see, web contexts are loaded for Administration Console only. You can therefore use this node strictly for administration purposes

      • : forms a part of the SAP Commerce ServiceLayer and comprises the functional and business services.
      • : The CronJob Service, The Task Service, and the Process Engine.
      • : provides an API to run an embedded servlet container. The tomcatembeddedserver extension provides a Tomcat-based implementation of this API.
    • : template extension, allows you to store selected types in an alternative storage. It uses the polyglot persistence query language.
    • : a predefined extension to be duplicated. The copy serves as starting point for creating a new extension, typically used for customer specific implementations. 还有.

platform module implementation

  • 只要在config文件夹localextensions.xml下面的Extension,都会被build framework控制。
    ant target
    在哪个目录下执行ant all决定了build scope:Platform-wide and extension-wide.
    The SAP Commerce version is included in the build.number file located in the <HYBRIS_BIN_DIR>/platform directory.
    build三大过程:
  1. preparation: 检查的文件夹是否存在。然后解析dependency,如果A depends B,那么B一定先于A build. Build framework进行初始化操作,将build.xml拷贝到每个Extension的文件夹下。生成extenson的源代码。为Service layer生成model。不管是哪种build scope,这一步都会执行。
  2. dependency update
  3. extension building:before_build callback target, 运行validation,生成源代码文件,编译Extension的core和web module. 运行after build callback.

build过程中根据items.xml里的type definition创建java文件:

  • ServiceLayer的Model文件
  • Abstract Jalo Layer classes (carrying a prefix, such as Generated). These files are generated anew if you have modified the items.xml for the extension
  • Non-abstract Jalo Layer classes. These are only generated when the file does not yet exist. If a file with the same name exists, the file is not generated anew.

基于javac ant task,比较.java和.class的timestamp.

SAP Commerce contains a process to include custom files in the <HYBRIS_BIN_DIR> directory. This process copies the content of the <HYBRIS_CONFIG_DIR>/customize directory to the <HYBRIS_BIN_DIR> directory.

All extensions and the Commerce Platform are packaged according to filtersets. You can find the standard filtersets in hybris/bin/platform/resources/ant/dist/filtersets.xml. There are three predefined filters : platform.filter, extension.source.filter and extension.binary.filter.

A .classpath file specifies which Java source files and resource files in a project are considered by the Java IDE (Eclipse, Intellij IDEA), and specifies how to find types outside of the project. When some extension ( for example commerceservices) is released as a binary, a java library file is created ( for example commerceservicesserver.jar) and a path to this file needs to be inserted to a .classpath file, instead of paths to sources. When some extension is released as a source, a .classpath file contains a path to sources and libraries. That’s why we have separate .classpath and .classpath_binary files.

flexiblesearch也能被cache.

The PlatformFilterChain is triggered on every HTTP request. The default Spring bean of the PlatformFilterChain is registered in the Spring application context in the filter-spring.xml file. It instantiates filters that are necessary for every Web application.

However, every Web application can instantiate other filters in their own Spring application context file. In other words, any filter can be easily activated or deactivated in the Spring application context for every single Web application.

在core extension里有个文件:core-filter-spring.xml

It instantiates filters that are necessary for every Web application.

- 使用api导入导出数据

已经过时了,被Service layer取代。包含data model和用Java实现的business logic.

每次build都会根据items.xml生成abstract Java类和非abstract(只生成一次)

缺点是data model和Java类紧耦合,一旦data model变了,Java类也需要调整。所以被service layer取代了。很像gateway的SEGW里的DPC,DPC_EXT. 注意这两个Java类的位置不一样:

  • gensrc/de/hybris/jalolayer/sample/GeneratedMyType.java
  • src/de/hybris/jalolayer/sample/MyType.java

包含当前用户的数据和设置。

The oauth2 core extension has replaced the webservicescommons/oauthauthorizationserver extension. It exposes the HTTP endpoint as an authorization server.

Ordering, Payment and Pricing Standards

  • order extensibility - interceptor

The Order Framework architecture is designed to provide two level separation in the framework - Separation of Concerns and Separation of AbstractOrder type.

The AbstractOrderService is the main component for the Order Framework extensibility. It delegates the particular method calls to the dedicated strategies, DAOs, and subservices.

位置:

C:\Code\commerce-suite-6.7.0\hybris\bin\platform\ext\platformservices\src\de\hybris\platform\order

DefaultOrderService: 在附近的impl文件夹内。行为抽象成strategy.

interface CreateOrderFromCartStrategy

Default implementation EventPublishingSubmitOrderStrategy sends SubmitOrderEvent. If you wish to do something else, then you can implement the interface and inject it into the Order Service that provides the list of strategies fired one after another.

The europe1 extension handles all price, tax, and discount calculations in SAP Commerce.

Payment Transaction and Delivery Mode Handling

Processing in SAP Commerce extensively uses the task service, the cronjob service, and the process engine. Each of them are provided by the processing extension.

有一个BPM, task service, cronjob service.

不同的extension可以extend同一个bean:

Definitions of these Java Beans or Enums are merged across extensions. For example, if two extensions specify a bean and enum with the same, fully classified class, the generated class includes the attributes from these two extensions. This way, you can extend already existing beans and enums, and do not have to subclass them, or replace references to the former bean and enum.

build的时候,model生成完之后就是java bean的生成。

重要:

Generated java files are located in {HYBRIS_BIN_DIR} /platform/bootstrap/gensrc directory.

Generated classes are located in {HYBRIS_BIN_DIR} /platform/bootstrap/modelclasses directory.

通过velocity script,一个template生成source code.

Global Templates

There are two default global templates to render beans and enums. These templates are used if there is no custom template defined for a specific bean or enum in the beans.xml file, or if a given template does not exist. The default templates are:

global-beantemplate.vm - for each bean

global-enumtemplate.vm - for each enum

You can find them in the platform/bootstrap/resources/pojo folder.

Runtime types: with no definition in items.xml ; they are only defined in runtime in Backoffice.

Runtime Types are as persistent as all other items, since type definitions are stored in the database as well. However, when SAP Commerce is initialized, the entire type system is discarded and re-created from the contents of the items.xml files of all extensions. As Runtime Types are not backed by a file, they are removed and not re-created during a system initialization. In other words: whenever you initialize SAP Commerce, all Runtime Types are gone.

  • atomictypes

For details on a list of the AtomicTypes that are generated upon Platform initialization, please refer to the atomictypes section of the core-items.xml file in the <HYBRIS_HOME> /bin/platform/ext/core/resources directory.

Unlike the other types, an AtomicType definition does not have a code attribute to set the unique identifier. Instead, the AtomicType class attribute is used as its reference.

SAP Commerce stores AtomicType instances in the database as strings (VARCHAR) or numbers (NUMBER)

service layer和jalo layer都和items.xml有关。

items.xml在Eclipse里修改之后立即生效的问题:

SAP Commerce comes with preconfigured builders for the Eclipse IDEInformation published on non-SAP site that support working with the items.xml file. Using Eclipse, whenever you edit an items.xml file, SAP Commerce automatically:

Jalo Layer: Generates Generated*.java source files (item classes) for all item types of your extension to the gensrc directory of your extension.

Jalo Layer: Refreshes the gensrc directory of your extension.
ServiceLayer: Generates *Model.java source files (model classes) for all item types of configured extensions to the bootstrap/gensrc directory
ServiceLayer: Refreshes the bootstrap/gensrc directory

Null Value Decorators in Models:类型JDK8的optional

什么时候需要指定一个deployment?

The typecode attribute must specify a unique number to reference the type. The value of the typecode attribute must be a positive integer between 0 and 32767 (2^15-1) and must be unique throughout SAP Commerce as it is part of the PK generation mechanism. Typecode values between 0 and 10000 are reserved for SAP Commerce-internal use. Typecode values larger than 10000 are generally free for you to use but there are lots of exceptions to that rule.

<HYBRIS_BIN_DIR>/platform/ext/core/resources/core/unittest/reservedTypecodes.txt

To see how SAP Commerce types are mapped to different databases, see the file bin/platform/ext/core/resources/core-advanced-deployment.xml.

没有持久化存储,就是calculated fields

Groovy, BeanShell, JavaScript

  • flexible search: 执行过程分两阶段:

pre-parsing into an SQL-compliant statement and running that statement on the database

例子:编写基于type syste的statement,和db无关。用大括号注明类型名称。

select {pk}, {code}, {name[de]} from {Product}

编译成SQL:

SELECT  item_t0.PK , item_t0.Code , lp_t0.p_name	FROM products item_t0 JOIN productslp lp_t0 ON item_t0.PK = lp_t0.ITEMPK AND lp_t0.LANGPK= 9013632135395968	WHERE (item_t0.TypePkString IN  ( 23087380955301264 , 23087380955663520 , 23087380955662768 , 23087380955661760 ,	23087385363574432 , 23087380955568768 , 23087380955206016 ) )

执行权限问题:

By default, the user account assigned to a session is anonymous, so any FlexibleSearch query returns the search results matching the anonymous account by default. To run FlexibleSearch queries in the context of a user account different from anonymous, the session needs to be assigned to a different user account.

similar to Hibernate Criteria Queries. Hibernate is a collection of related projects, enabling developers to utilize POJO-style domain models in their applications in ways extending well beyond Object and Relational Mapping.

backoffice

  • 一个实际的例子:

其他网友的资料

SAP成都研究院Commerce开发人员Zhang Jonathan的三篇概述文章:

Jerry Wang的文章:

其它文章:

转载地址:https://jerry.blog.csdn.net/article/details/105351822 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:SAP云平台 Document Information Extraction服务测试
下一篇:使用类似搭积木的低代码开发方式进行SAP API开发

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月24日 16时43分47秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章