SAP Commerce(SAP Hybris)学习资料汇总

版本号:v1.04 2020年4月14日

<span id="toc"></span>
@TOC

SAP官方帮助文档

configuration

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

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

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

配置文件的编码问题:encoding

默认: 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

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

容器化支持

images

Installer-Recipe

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

License文件:<HYBRIS_HOME>/config/license/installedSaplicenses.properties
如何生成license file

也不能在一个目录里重复安装不同的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.

回到目录

Extension和Addon的概念

  • 若干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<Enter>.

一旦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: <yacceleratorstorefront>/web/webroot/_ui/addons/<addon_name>


source: <addon_name>/acceleratoraddon/web/src
target: <yacceleratorstorefront>/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.

addoninstall工具的用法

使用addon定制化Storefront

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

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="beans.xsd">
    
    <bean class="de.hybris.platform.commercefacades.product.data.ProductData">
        <property name="weight" type="int" />
        <property name="instruction" type="String" />
        <property name="additionalImage" 
                         type="de.hybris.platform.commercefacades.product.data.ImageData" />
    </bean>
    
    <enum class="de.hybris.platform.commercefacades.product.ProductOption">
        <value>DIMENSIONS</value>
        <value>MINIMAL</value>
    </enum>
</beans>

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

  1. ant extgen
  2. 自定义Storefront

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: <extension> -items.xml where <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.

localextensions.xml

在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.

Internationalization-and-localization

  • 什么是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和update过程

什么是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里定义的新类型,会施加到类型系统里。
upgrade

Model

基于items.xml的定义生成types. 通过core extension实现。

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列表

Abbreviations语法

导入product的例子:脚本

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

MediaDataTranslator负责导出media内容。

SAP-Commerce里的Spring框架

是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.

<bean class="de.hybris.platform.order.OrderService">
    <property name="stockService">
        <bean class="de.hybris.platform.stock.StockService"/>
    </property> 
</bean>

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

There you find files with the name pattern |component|-spring.xml, where <component> 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里找到。


在这里插入图片描述

AOP

[一个向导]

  • 创建新extension
  • 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
  • 创建新的controller和jsp view - hello world级别的
  • Product练习
  • Service extension
  • Extensibility的奥秘:platform/ext/platformservices/resources/product-spring.xml
<alias alias="productService" name="defaultProductService"/>

在我们自己的Extension里:
training/resources/training-spring.xml

<alias alias="productService" name="trainingProductService"/>

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.

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

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.

Autowiring的优缺点

Accelerator

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:

<alias alias="globalBeanService" name="customizedBeanService" />

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.

how to Adding Bean Definitions to Core ApplicationContext

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.

Module

开发环境相关

一定在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.

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

Service-Layer

是三层的统称: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 <coremodule> 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,用构造函数或者工厂方法新建。

Model context

  • 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.

Hook

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.

Java annotation的简介

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
    }
...

event-system

接收和发送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.

@Resource
private EventService eventService;

alias

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.

回到目录

Hybris-Type-System

类型系统是对象的模板。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.

<item code="SpecialProduct" metatype="SpecialComposedType"  extends="Product">

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

Platform-Services-and-Utilities

三大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.

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

SELECT * FROM table WHERE PK=X

回到目录

platform module architecture

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

  • extension列表:
    • catalog
    • commons: 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.
    • core extension: handles basic functionality such as persistence handling, the ordering process and contains the service layer functionality.
      • deliveryzone: ext下面。
      • hac. 可以只启动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
      * payment standard
      * platform services: forms a part of the SAP Commerce ServiceLayer and comprises the functional and business services.
      * processing: The CronJob Service, The Task Service, and the Process Engine.
      * tomcatembeddedserver : provides an API to run an embedded servlet container. The tomcatembeddedserver extension provides a Tomcat-based implementation of this API.
      * validation

    • ydocumentcart : template extension, allows you to store selected types in an alternative storage. It uses the polyglot persistence query language.
    • yempty: a predefined extension to be duplicated. The copy serves as starting point for creating a new extension, typically used for customer specific implementations. 还有yvoid.

platform module implementation

  • build framework
    只要在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.

Distribution-process

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.

cache

flexiblesearch也能被cache.

Charon

Cluster

container-support

filters

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.

Impex - 使用api导入导出数据

Internationalization-and-Localization

Jalo-Layer

已经过时了,被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

Jalo-session

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

logging

media

oauth2

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

order

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

order service

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.

europe1

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

Ordering-Process

payment

Payment Transaction and Delivery Mode Handling

Processing

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.

bean的生成逻辑

Product建模的两种方式

type-system

Configured Types vs Runtime Types

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)

所有可用的类型列表

items.xml详述

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

items.xml的schema

deployment

什么时候需要指定一个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.

类型系统的清理cleanup

dynamic-attribute

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

Enumerations

script

Groovy, BeanShell, JavaScript

search

  • 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.

用代码的方式消费
paging分页机制
restriction限制条件
一些例子
tips and trips,技巧,最佳实践
Query and JDBC Hints

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.

syntax语法

回到目录

backoffice

回到目录

其他网友的资料

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

Jerry Wang的文章:

其它文章:

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,835评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,598评论 1 295
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,569评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,159评论 0 213
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,533评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,710评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,923评论 2 313
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,674评论 0 203
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,421评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,622评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,115评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,428评论 2 254
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,114评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,097评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,875评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,753评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,649评论 2 271

推荐阅读更多精彩内容