天天看点

SAP ABAP SICF服务和Java Servlet的比较Thread pool in 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”.

SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet

System.out.println("User id: " + userId + " at thread: " + Thread.currentThread().getId() + " current instance: " + this);
      
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet

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.

SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet

Thread pool in Java Servlet

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

SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet

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:

SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet
SAP ABAP SICF服务和Java Servlet的比较Thread pool in Java Servlet

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