`
JerryWang_SAP
  • 浏览: 189236 次
  • 来自: 西安
文章分类
社区版块
存档分类
最新评论
阅读更多
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的原创文章,请关注公众号"汪子熙":
 
0
0
分享到:
评论
相关资源推荐
  • SICF 激活WDA程序
  • BW事务代码SXMB_ADM、 SICF、SMICM简介 SXMB_ADM用于配置和管理XI。SAP帮助链接: http://help.sap.com/saphelp_nw04 ... 403d6a/frameset.htm SICF用于激活和创建服务,比如HTTP或SMTP,SAP帮助链接: http://help.sap.com/saphelp_nw04 ... 114084/frameset.htm http://help.
  • ABAP, JavaJavaScript三种语言的比较 写这个系列的初衷是SAP Chengdu office有越来越多的应届毕业生加入,这些新同事通过在大学的专业学习,具备了JavaJavaScript背景,但是进入SAP之后大家觉得ABAP没有JavaJavaScript好学。 其实任何编程语言总是有很多相通之处,这个系列就是把这三种语言的很多知识点拿来横向比较,即使只会其中一门,也能看懂这些post. 同时对于ABAP较之Java和J
  • SAP 如何提供 RESTful Web 服务 SAP 推荐以 OData 方式提供 Restful Service。Netweaver 7.4 之后的版本可以直接使用 OData 服务。7.4 之前的版本需要升级 GW_CORE、IW_FND 和 IW_BEP 三个核心组件(参见 SAP OSS Note:1569624)。 7.4 之前的版本也可以用另外一种方式,也即本文要介绍的方法。SAP 提供 Restful Web Service,...
  • SAP 接口之提供 Rest Web服务 前面提及了Rest 的简单介绍 下面测试下sap提供rest  web 的服务!!  如果要将SAP应用程序服务器 (application server)作为 http 服务提供者,需要定义一个类,这个类必须实现 必须用到IF_HTTP_EXTENSION 接口。IF_HTTP_EXTENSION 接口只有一个方法 HANDLE_REQUEST。自定义的这个类必须实现 HANDLE_RE...
  • https://blog.csdn.net/champaignwolf/article/details/53768941
  • SAP 如何提供 RESTful Web 服务(3) - Rest 路径处理 解决 Rest 路径问题 本篇解决路径问题。 SICF 设置的是一个固定的路径,但 Rest 风格的 API 要求使用不同的路径和不同的 HTTP 请求来实现不同的操作。比如有一个学生的数据需要 CRUD: 列出所有学生 (GET): /base-url/students, 创建新的学生 (POST): /base-rul/students/create 修改学生 (PUT):/base-...
  • abap webservice创建和删除  1.se80,实例程序-->更多实例程序-->创建web服务-->来自函数模块(来自函数组) 2.填写  服务定义,描述,不选 map names 会是大写有下划线,如果选中初始字母大写并移除下划线,选择安全模式为最低级 3.完成之后保存激活,在事务代码框中输入:soamanager,打开路径 4.打开浏览器之后,选择“Web服务配置”,选择刚新建的,然后创建服务 5.输入相应的信
  • 这些编程语言程序员工资最高!Java才第四
  • https://blog.csdn.net/zhongguomao/article/details/52437426 如果你想使用web dynpro 开发的应用,但是发现浏览器报错,那么你按照下面的步骤逐一进行检查吧。特别是返回的500错误,或者是你发现浏览器的地址栏中以http://:8000/sap/bc/webdynpro个开头的地址,是你的主机名,那么一定是你的域名解析没做好,按照下面的方式进行检查吧。 1、那么必须要激活ICF的一些服务,事物码为SICF,主要是的几个服务,     defau
  • SAP创建Web Service以及用ABAP调用 如果运行soamanager打不开,网页显示devaix.zhongpin.com,打开C:\WINDOWS\system32\drivers\etc,用记事本打开hosts文件,在最后一行加上:192.168.2.24 devaix.zhongpin.com 本次学习如何用SAP创建web service,以及如何利用ABAP调用Web Service. 步骤: 1. 创建一个RFC函
  • javaEE之Servlet的生命周期 E Servlet 生命周期:Servlet从创建直到销毁的过程。整个周期可分为如下过程: Servlet 通过调用 init () 方法进行初始化。 Servlet 调用 service() 方法来处理客户端的请求。 Servlet 通过调用 destroy() 方法终止(结束)。 最后JVM 的垃圾回收器对Servlet进行垃圾回收。 init()方法            i...
  • JavaABAP中的几种引用类型的分析和比较 Java编程语言中几种不同的引用类型是面试时经常容易被问到的问题:强引用,软引用,弱引用,虚引用。 其实除了Java之外,某些 其他编程语言也有类似概念,比如ABAP。今天我们就来比较一下。 根据ABAP帮助文档,我们可以把某个对象的引用包在一个Weak Reference的实例里。ABAP的Weak Reference实例通过类CL_ABAP_WEAK_REFERENCE实现。 看下面的例...
  • 6门主流编程语言(C、C++、Java、Python、JavaScript、PHP)特性对比 这些年来我陆陆续续已经学习了六种编程语言,有些人会说语言学到最后不都差不多吗?其实可以这样讲,也可以不这样讲。虽然每种语言的表达能力大部分是重合的,只是语法表现形式不一样,但是由于历史发展的原因,每种语言形成了自己的支撑环境,所以都有其主要的适用范围。 C、C++、Python和Java四种是通用编程语言JavaScript和PHP算是Web环境的专用编程语言。C语言由于其底...
  • JAVA是不是目前最容易学最容易上手的编程语言 作为一个超过10年以上工作经验的Java开发者,我觉得应该可以来回答一下。推荐一个学习群 java《学习》+交流 523401738首先说结论:Java绝对不是最容易学或者最容易上手的语言。我们稍微观察最近几年开始大规模进入大家实现的几门新兴编程语言,包括Python,包括苹果主推的Swift等等,它们在宣传初期都不约而同的喜欢怼一下Java,并且理由出奇一致:我们只需要一句话就能写出hello ...
  • ABAP 创建并调用WebService
  • 【基础】ABAP不同变量类型之间数值大小比较
  • 服务器系统对比、数据库对比、后台开发语言对比 服务器系统对比、数据库对比、后台开发语言对比
  • https://blog.csdn.net/i042416/article/details/80699552 事务码SICF,service name输入WEBGUI, 点右键,选择Test Service: 可以在浏览器里敲SE38进入ABAP editor了: 然么缺乏语法高亮显示: 如果想要浏览器里的语法高亮显示,参考我的SAP community blog How ABAP syntax highlight is implemented in WebIDE laun...
  • https://blog.csdn.net/zhongguomao/article/details/52381888 根据IP以及主机名到Hosts文件中进行配置。 主机名哪里可以获得呢:事务代码  SMICM 之后soamanager打开之后提示: 不要慌,右击网页 属性  去事务代码SICF中激活这个服务就可以啦,轻松搞定! 万事不求人,事事都玩转! 少年休闲海!
Global site tag (gtag.js) - Google Analytics