SAP Fiori和WebClient UI的有狀態和無狀態行為設計原理
As is almost known to us all, Fiori ( at least deployed in Netweaver having ABAP as backend ) has stateless behavior and CRM WebClient UI is a set of stateful application. Physically both are running on ABAP Netweaver using ABAP BSP application. How are this different behavior implemented? There are documentation in SAP help about stateful and stateless BSP application. It is mentioned there:
Stateless
In the stateless case, the context is created each time that a request is received. The context is always destroyed when the response is sent. For the BSP runtime stateless means: runtime->keep_context = 0
Stateful
In the stateful case, the context is held by gone request to the next. For the BSP runtime stateful means: runtime->keep_context = 1 As a Fiori/CRM Webclient UI developer, the above mentioned difference is taken care by framework and completely transparent to me. The only point I need to be careful is that when I am developing service in the backend for stateful application, I can consider introducing some session buffer for performance improvement which will not work in stateless scenario.
Nevertheless I am still curious how framework treats these two kinds of application differently. PRD01 is a CRM Webclient UI component which I am responsible for. In SE80 the checkbox “Stateful” is marked as true.
CRM_OPPRTNTY is for CRM Fiori application “My Opportunity”, where “Stateful” is false.
How does ABAP HTTP framework treat this flag set in BSP application?
I debug the HTTP process implementation against a HelloWorld BSP application with stateful checkbox marked with true and draw the following diagram:
The stateful related evaluation and handling are involved in the following framework process steps.
(1) Buffer check in CL_HTTP_SERVER~EXECUTE_REQUEST ( red diamond )
The buffer is maintained in internal table http_ext_instances of CL_HTTP_SERVER.
When the index.html of BSP application is initially opened, no handler is created so buffer table is empty, create instance for the first time:
The instantiation of CL_HTTP_EXT_BSP will call CONSTRUCTOR of CL_BSP_RUNTIME and CL_BSP_CONTEXT, as displayed in the diagram.
(2) CL_HTTP_EXT_BSP~HANDLE_REQUEST
Once BSP handler CL_HTTP_EXT_BSP is initialized, its method HANDLE_REQUEST is called. Inside this method, method ANALYZE_URL ( green block in diagram ) of CL_BSP_RUNTIME is called to evaluate the accessed BSP application is stateful or stateless.
From the source code below we can know that the Stateful checkbox value for a given BSP application is stored in table o2appl, field stateful:
This stateful checkbox value will be filled to c_context->m_app_stateful:
And c_context->m_app_stateful will be used to fill if_bsp_runtime~keep_context:
Notice that before method ON_REQUEST_LEAVE is entered, its field KEEP_CONTEXT has value 1, which is consistent as what SAP help mentions.
(3) CL_BSP_RUNTIME~ON_REQUEST_LEAVE In ON_REQUEST_LEAVE ( purple in diagram ), since keep_context is and server->stateful is 0 ( default value ), so IF branch starting from line 42 is executed.
Here cookie field sap-contextid is set, and server->stateful is set as 1. This flag will be evaluated in the last step.
(4) buffer insertion If flag server->stateful set in previous step has value 1, currently instance of CL_HTTP_EXT_BSP is buffered.
Later when other requests from the same BSP application is raised, EXECUTE_REQUEST will be called again and this time the buffered BSP handler instance is used to serve the request:
So far we have gone through all branches in my diagram. The relationship among CL_HTTP_EXT_BSP, CL_BSP_RUNTIME, CL_BSP_CONTEXT could be found from below picture:
Further reading
So far this blog discusses the difference of Stateful and Stateless handling done in server side. For different behavior in client side, please refer to this blog: Stateless and Stateful – Different behavior in application side.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2714423/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP BSP應用有狀態和無狀態行為差異比較
- 有狀態和無狀態的區別
- 架構設計(五):有狀態服務和無狀態服務架構
- 系統設計架構:有狀態與無狀態架構
- Spring Bean Scope 有狀態的Bean和無狀態的BeanSpringBean
- 行為和狀態的關係
- SAP CRM WebClient UI和Fiori UI混搭並存WebclientUI
- 關於有狀態和無狀態會話bean的解釋 (轉)會話Bean
- 如何證明CRM WebClient UI上的應用是有狀態(Stateful)的WebclientUI
- ssdbgrid中,設了斷點的除錯狀態和執行狀態有區別斷點除錯
- SAP 電商雲 Spartacus UI 有狀態 的 url 和 title 屬性的賦值程式碼UI賦值
- SAP 電商雲 UI State persistence 狀態持久化設計的入口 - initSyncUI持久化
- 設計模式--狀態模式State(行為型)設計模式
- FTP - 協議原理和狀態碼FTP協議
- 執行緒狀態和鎖執行緒
- 【架構設計】無狀態狀態機在程式碼中的實踐架構
- 行為型設計模式 - 狀態模式詳解設計模式
- 物件導向程式設計和根本狀態物件程式設計
- iOS UI狀態儲存和恢復(三)iOSUI
- 工作流從無狀態切換到有狀態的好處
- 狀態機設計
- 【設計模式基礎】行為模式 - 8 -狀態(State)設計模式
- 設計模式--直譯器模式和狀態模式設計模式
- Oracle資料庫的靜默狀態和掛起狀態Oracle資料庫
- HTTP狀態保持的原理HTTP
- Memcached 多執行緒和狀態機執行緒
- 狀態模式的理解和示例模式
- 更新TableView和CollectionView的狀態View
- 行為型模式:狀態模式模式
- 按鈕體驗設計:最佳的感受、形式和狀態
- 直播app原始碼,狀態列和導航欄設定成透明狀態APP原始碼
- 設計模式-狀態模式設計模式
- 設計模式:狀態模式設計模式
- 如何在SAP WebClient UI裡建立柱狀圖(bar chart)WebclientUI
- 用設計模式去掉沒必要的狀態變數 —— 狀態模式設計模式變數
- [React]屬性和狀態React
- 統計TCP連線數和狀態TCP
- 系統狀態統計和檢視