`
JerryWang_SAP
  • 浏览: 1026478 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

ABAP SICF服务和Java Servlet的比较

阅读更多

In my opinion ABAP ICF handler and Java Servlet play the same role in enhancement which enables your web server with additional functionality.

This blog will not introduce how an ICF handler class in ABAP or a Servlet in Java are developed, but focus the way those instances of handler class or Servlet are spawned by Web Server.

Let’s first study the Servlet spawn behavior in Java.

Servlet in Java

According to Servlet specification, http request against a given url will be served by the same single instance of servlet.

For example, I have developed a simple Servlet which just returns “Hello world” as response. I map it with url starting with “/Hello”.

 
 

In the doGet method, I print out the current thread id and instance address to try to verify if every request is served with the SAME servlet instance.

System.out.println("User id: " + userId + " at thread: " + Thread.currentThread().getId() + " current instance: " + this);

In client side I use jQuery to send out five different request simultaneously:

var LOCAL = "http://localhost:9098/JerryServlet/Hello?userId=";
var PREFIX = "i04241";
function main() {
 for( var i = 0; i < 5; i++) {
 var url = LOCAL + PREFIX + i;
 var html = getPostByAJAX(url);
 console.log("response: " + html);
 }
}
$(function(){ 
    main();
}); 
function getPostByAJAX(requestURL){
 var html = $.ajax({
    url: requestURL, async: true}).responseText; 
 return html;
}

When executing the client JavaScript code, I observe in Server console and could find out that these five requests are handled by the same Servlet instance ,however in different threads.

 
 

Since I perform the request in an asynchronous mode, so the response of those five requests are processed and returned in parallel.

 
 

How singleton behavior of Servlet is achieved

The instance of requested Servlet will only be initialized when it is asked for the first time. The below two-fold instance checking against null is a typical thread-safe implementation pattern for Singleton in Java.

 
 

The method loadServlet in class StandardWrapper will call constructor of my sample Servlet via reflection. All subsequent request will be served by this singleton.

 
 

Thread pool in Java Servlet

This thread pool behavior is easy to observe, just set breakpoint in doGet method in my Servlet, line 58:

 
 

Perform the client code to send five requests, then in Eclipse we can see the five working threads stopped at the breakpoint at the same time:

 
 

From the bottom of callstack we get the hint that those working threads are centrally managed by the Thread pool.

 
 

ICF Handler class in ABAP

Create a simple ICF service in tcode SICF and implement its handler class.

Set a breakpoint on method HANDLE_REQUEST, then trigger the request sending in client code:

 
 

Five debugger windows will pop up for the same time, each for one separate ABAP session where the request is handled.

 
 

From this source code we know the fact that in ABAP, the instance of handler class does not behave as singleton in Java Servlet.

 
 

From debugging we can observe that different session has different ICF handler instance which are isolated among each other.

 
 

Further reading

I have written a series of blogs which compare the language feature among ABAP, JavaScript and Java. You can find a list of them below:

  • Lazy Loading, Singleton and Bridge design pattern in JavaScript and in ABAP
  • Functional programming – Simulate Curry in ABAP
  • Functional Programming – Try Reduce in JavaScript and in ABAP
  • Simulate Mockito in ABAP
  • A simulation of Java Spring dependency injection annotation @Inject in ABAP
  • Singleton bypass – ABAP and Java
  • Weak reference in ABAP and Java
  • Fibonacci Sequence in ES5, ES6 and ABAP
  • Java byte code and ABAP Load
  • How to write a correct program rejected by compiler: Exception handling in Java and in ABAP
  • An small example to learn Garbage collection in Java and in ABAP
  • String Template in ABAP, ES6, Angular and React
  • Try to access static private attribute via ABAP RTTI and Java Reflection
  • Local class in ABAP, Java and JavaScript
  • Integer in ABAP, Java and JavaScript
  • Covariance in Java and simulation in ABAP
  • Various Proxy Design Pattern implementation variants in Java and ABAP
  • Tag(Marker) Interface in ABAP and Java
  • Bitwise operation ( OR, AND, XOR ) on ABAP Integer
  • ABAP ICF handler and Java Servlet
  • ADBC and JDBC
  • CL_ABAP_CORRESPONDING, CL_JAVA_CORRESPONDING and CL_JS_CORRESPONDING
  • Build an Cross Site Scripting example in Java and ABAP
  • Play around with JSONP in nodeJS server and ABAP server

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

 


作者:JerryWangSAP
链接:https://www.jianshu.com/p/6948af3fd419
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
0
0
分享到:
评论

相关推荐

    SAP ABAP与JAVA之间通过RFC传递数据实例

    2. **建立连接**:配置完成后,SAP ABAP端将作为客户端调用JAVA端作为服务器端的服务。 3. **数据交换**:ABAP端抽取数据并通过RFC发送给JAVA端,JAVA端处理后将结果返回给ABAP端。 #### JCo服务器程序注册步骤 - ...

    sap abap调用java生成的webservice手册

    输入WSDL URL并完成生成,这将创建一系列ABAP类和接口,用于与Java Web Service通信。 5. **生成Port和实例调用** 生成代理后,需要创建一个Port实例,这个实例是实际调用Web Service的载体。在ABAP代码中,通过...

    java +abap+rfc

    Java与SAP ABAP之间的通信主要通过Remote Function Call (RFC)接口实现,这是一种标准化的方式,允许不同系统间的双向数据交换。在本项目中,我们使用了JCo3(Java Connector version 3)库,它是SAP提供的Java API...

    ABAP发布WEBSERVICE以及JAVA调用.docx

    在本文中,我们将深入探讨如何在ABAP环境中发布Web服务以及如何使用Java进行调用。Web服务是一种标准的接口,允许不同系统间进行数据交换。在SAP系统中,ABAP是主要的编程语言,我们可以使用它来创建和发布Web服务。...

    ABAP-AES-JAVA加密解密(带附件SE24-AES.RAR、JAVA-AES.RAR及测试案例)

    标题中的“ABAP-AES-JAVA加密解密”是指在ABAP和JAVA两个不同的编程环境中实现AES(Advanced Encryption Standard)加密算法的互操作性。AES是一种广泛应用的块密码标准,用于保护数据的安全,确保信息不被未经授权...

    abap objects for java developers.pdf

    综上所述,《ABAP Objects for Java Developers》是一份极具价值的参考资料,它不仅介绍了ABAP的核心概念和技术细节,还强调了ABAP与Java之间的相似性,这对于Java开发者来说是非常有用的。通过学习这份资料,开发者...

    JAVA与ABAP之间通过RFC互传数据_JCO实例及API

    在IT领域,尤其是在企业级应用开发中,Java和ABAP(Advanced Business Application Programming)是两种常用的编程语言。Java广泛应用于互联网应用,而ABAP则是SAP系统的核心编程语言。为了实现不同系统的集成和数据...

    How to Handle ABAP Function Parameters in Java.7z

    在Java中处理ABAP RFC参数,我们通常会用到SAP JCo(Java Connector)库,这是一个SAP提供的Java接口,用于连接和通信SAP系统。 1. **安装和配置SAP JCo**: 在开始编程之前,确保已经正确地安装并配置了SAP JCo库...

    ABAP开发规范和命名规则

    ABAP开发规范和命名规则是IBM提供的一套开发标准和命名惯例,为ABAP开发者提供了详细的开发指南和命名规则,以确保开发的程序代码质量和可读性。本文将对ABAP开发规范和命名规则进行详细的解释和说明。 一、文档...

    SAP ABAP 开发环境和开发工具介绍

    SAP ABAP 开发环境和开发工具介绍 SAP ABAP 开发环境和开发工具是 SAP 系统中最重要的组件之一,它提供了一个强大的开发平台,允许开发者创建、测试和部署 ABAP 程序。ABAP 是 SAP 系统中的主要编程语言,用于开发...

    ABAP Webservice接口部分

    在ABAP中,Web服务接口是一种重要的功能,允许与其他系统(如非SAP系统)进行集成和通信。本主题主要关注如何在ABAP环境中创建和使用Web服务接口,并与C#项目进行交互。 首先,让我们了解ABAP Web服务的基础。在...

    ABAP 中对HTTP的支持

    此外,ABAP 中还提供了一些其他的接口和类,例如 IF_HTTP_ENTITY、IF_HTTP_HEADER_FIELDS 等,提供了对 HTTP 头信息和主体信息的访问。 ABAP 中对 HTTP 的支持提供了灵活的方式来与外部 HTTP 服务器进行交互,实现...

    ABAP 调用ABAP PROXY

    2. **生成Proxy代码**:在目标系统中,使用SE80事务码,通过“生成ABAP Proxy”功能,输入源系统的服务接口信息,自动生成对应的ABAP Proxy类和相关代码。 3. **编译与激活**:生成的Proxy代码需要在目标系统中进行...

    HTTP+JSON--ABAP交互方法.rar

    【标签】虽为空,但我们可以推断相关的知识点可能包括:ABAP编程、HTTP客户端、HTTP服务器、JSON解析、SAP Web服务、SICF服务配置、以及可能涉及到的其他编程语言如Java和C#的接口实现。 从提供的文件名称来看,...

    30天学会ABAP很好的教程

    ABAP的另一个显著特性是其跨平台性,类似于Java,ABAP程序可以在任何操作系统上运行,兼容多种数据库,并能在不同的网络系统中无缝运行。ABAP字典实现了透明表的概念,使得开发者在ABAP层面上操作的表与底层数据库...

    SAP_ABAP_4.7.rar_SAP abap4_abap_abap chm_abap 4_abap4

    ABAP 4.7版本开始支持SOAP和RESTful Web服务,使得SAP系统能与其他系统进行集成和数据交换。 9. 调试和测试: SAP提供了强大的调试工具,如ABAP Debugger,用于查找和修复代码错误,同时支持单元测试和集成测试。...

    SAP ABAP 调用外部接口webservice案例分享

    在SAP ABAP环境中,调用外部Web服务是常见的任务,尤其在系统间集成和数据交换时。本案例将详细讲解如何配置SAP ABAP来调用外部接口Web服务。 首先,我们需要创建一个企业服务(Enterprise Service)的消费者代理。...

    ABAP培训教材

    1. ABAP和Java的互操作性:通过ABAP Java Bridge(AJB),ABAP程序可以调用Java组件,反之亦然。 2. OData服务:ABAP可以创建OData服务,实现与移动设备和Web应用的集成。 八、ABAP开发工具 SAP提供了一系列的开发...

    ABAP加密和解密.doc

    在ABAP编程中,加密和解密是两个关键的安全操作,用于保护敏感数据不被未经授权的用户访问。本文将深入探讨ABAP环境下的加密和解密技术,以及如何在实际应用中实施这些技术。 首先,我们需要理解加密的基本原理。...

    abap xlsx2 demo 程序

    "abap xlsx2 demo 程序"是一个示例项目,旨在展示如何在SAP系统中读取和写入Excel文件。在这个程序中,开发者可能使用了特定的库或者自定义开发的函数来实现与Excel的交互。 首先,要理解ABAP如何处理.xlsx文件,...

Global site tag (gtag.js) - Google Analytics