導航目錄
SAP官方幫助文檔
configuration
如何運作
Filters
容器化支援
Installer-Recipe
Extension和Addon的概念
一步步建立一個新的addon
如何處理dependency
localextensions.xml
Internationalization-and-localization
ant
Hybris-initialization和update過程
Model
SAP-Commerce裡的Spring架構
AOP
[一個向導]
Accelerator
API-registry
search-and-navigation
solr-server
Module
開發環境相關
Service-Layer
Interceptor
Hook
event-system
Hybris-Type-System
Platform-Services-and-Utilities
platform module feature
platform module architecture
platform module implementation
Distribution-process
cache
Charon
Cluster
container-support
filters
Impex - 使用api導入導出資料
Internationalization-and-Localization
Jalo-Layer
Jalo-session
logging
media
oauth2
order
europe1
Ordering-Process
payment
Processing
Global Templates
Product模組化的兩種方式
type-system
所有可用的類型清單
items.xml詳述
dynamic-attribute
Enumerations
script
search
Chinesepaymentservices
backoffice
其他網友的資料
SAP成都研究院Commerce開發人員Zhang Jonathan的三篇概述文章:
Jerry Wang的文章:
其它文章:
配置檔案和運作時在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 /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 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的功能介紹。清單在這裡
images
不能用于生産用途。檔案夾位置:installer/recipes. 這個連結包含了所有recipe的說明。
License檔案:/config/license/installedSaplicenses.properties
如何生成license file
也不能在一個目錄裡重複安裝不同的recipe:
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.
Addon裡的accelerator檔案夾是如何拷貝到Storefront檔案夾裡的?規則在這個連結裡。
source: /acceleratoraddon/web/webroot/_ui
target: /web/webroot/_ui/addons/
source: /acceleratoraddon/web/src
target: /web/addonsrc/, 裝的java代碼。檔案copy由build callback實作:
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
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>
這個
連結包含了一個表格,可以查詢Extension和Addon的ID和description.
- 總體架構
- Extension專題 Initialization的過程generate the database schema and the type system, and import any essential system data.
Platform目錄下執行:ant initialize
Update: items.xml裡定義的新類型,會施加到類型系統裡。
upgrade
非常詳細的講解CMS模型的網頁
基于items.xml的定義生成types. 通過core extension實作。
Impex也是extension. Extension能使用其依賴的extension core module包含的resources和source,但web extension module的東西沒辦法通路。
Impex modifier清單
Abbreviations文法
導入product的例子:腳本
flexible search裡的!感歎号的用法,exclude subtype
MediaDataTranslator負責導出media内容。
是Service Layer的foundation.
Dependent Injection: 元件的依賴不是其自身維護,而是配置在外部。
在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
主要子產品 Architecture讨論 共有的一些Extension responsive? storefront 結構解析 technical design guide Accelerator for China為什麼要用alias?Extensibility!
Security
from jalo to service layer - migration and transition
after save event hook
startup tuning
disable JUnit tenant
suspend and resume
test with junit
mockito
China Accelerator
也是由一系列Extension組成。
用Eclipse搭環境
一定在build之後再導入import,否則報class找不到。
和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.
其實就是政策模式。
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.
Model可以從資料庫load,用構造函數或者工廠方法建立。
Model context- ModelService
一個java bean:
- Loading Models by pk
- Loading Models from items
- Creating Models
- Updating Models
- Deleting Models
增删改查CRUD方法都有。
隻for model:
@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.
@Resource
private EventService eventService;
類型系統是對象的模闆。platform裡每個對象都是類型的執行個體。
Types定義了持久化對象:
Attribute存儲對象的資料。
Deployment定義資料庫表
java class
A Type is the type definition in items.xml and its Java implementation.
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: Charon
Cluster 多節點共享資料庫。
容器化 Platform, solr和data Hub需要打三個鏡像。
data retension
data validation - before save: a JSR 303-compliant validation engine
digital asset management
filter for web application 一些常用filter清單:SessionFilter, ProfileFilter, Log4jFilter, RedirectWhenSystemIsNotInitializedFilter.
value change log
log
media - 檔案系統上的檔案。
[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.)
classification - 另一套分類系統?
scripting engine
security
permission
cors support
SSO
User UML
strict mode嚴格模式
Suspend and resume
Workflow
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.
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.
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 /platform directory.
build三大過程:
preparation: 檢查環境變量的檔案夾是否存在。然後解析dependency,如果A depends B,那麼B一定先于A build. Build framework進行初始化操作,将build.xml拷貝到每個Extension的檔案夾下。生成extenson的源代碼。為Service layer生成model。不管是哪種build scope,這一步都會執行。
dependency update
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.
flexiblesearch也能被cache.
已經過時了,被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
包含目前使用者的資料和設定。
位置:
C:\Code\commerce-suite-6.7.0\hybris\bin\platform\ext\platformservices\src\de\hybris\platform\order
order service
DefaultOrderService: 在附近的impl檔案夾内。行為抽象成strategy.
interface CreateOrderFromCartStrategy
CreateOrderFromCartStrategy
SaveAbstractOrderStrategy
DataAccessObjects
The europe1 extension handles all price, tax, and discount calculations in SAP Commerce.
Extensible Cart Calculation
Payment Transaction and Delivery Mode Handling
通過velocity script,一個template生成source code.
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
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?
類型系統的清理cleanup
沒有持久化存儲,就是calculated fields
Groovy, BeanShell, JavaScript
flexible search: 執行過程分兩階段:
用代碼的方式消費 paging分頁機制 restriction限制條件 一些例子 tips and trips,技巧,最佳實踐 Query and JDBC Hints- generic search syntax文法
sample store
一個實際的例子:2455449 - How-to: Hide Backoffice explorer-tree nodes based on user access rights