SAP HANA Cloud Platform supports 3 variants of Java runtime. The first Java runtime that was integrated with HCP was Java Web. This used OSGi based kernel and JDK 6. Next logical step was to get the runtime certified and thus came Java EE 6 web profile that is the Java EE certified runtime for HCP. It also used OSGi based Kernel and runs on JDK 7. Certainly this is more scalable and supports a lot of features. Then came the Java Web Tomcat 7 runtime which was more lightweight and simplified. It used Apache Tomcat 7 and runs on JDK 7. For most of the productive scenario, this is a quite stable and recommended runtime. You can find the feature comparisons in the table below:
However recently SAP has released a new Java runtime. The new JAVA Tomcat 8 runtime. Though, the released version is a BETA now and you cannot use this in a HCP account at this moment, pretty soon it’s gonna be GA and thus let’s have a look what brings this new runtime. Tomcat 8 runtime comes with the following specifications:
- Simplified Java Runtime for HCP (Servlet 3.1)
- Uses Apache Tomcat 8
- Runs on JDK 8 (Thankfully 🙂 )
- HTTP 2 (H2) is planned
- Beta version released
Now let’s have a look what’s the benefit of Servlet 3.1
Servlet 3.1 comes with two powerful features:
1. Non-Blocking IO: Servlet 3.1 allows you to use two Interfaces namely ReadListener and WriteListener.
These two interfaces allows call back functions on various IO events. Thus if you use this for example to read IO streams, the Servlet will not wait to get the stream, rather work in a Asynchronous mode. Similarly the write IO operation will be in a Asynchronous mode without blocking the process in the main servlet.
This is a very powerful feature in a sense esp. when a Servlet needs to cater huge stream of data in a more scalable solution like for example Millions of IOT Sensors sending sensor values within a very short time span. I will explain the feature with code example in my next blog – Part 2.
2. HTTP Protocol Upgrade: This feature allows Servlet to upgrade the protocol following a HTTP header with Upgrade command. This acts much in similar way as Web Socket works, but has more versatile effect. I will explain the feature with code example in my next blog – Part 3.
Also Tomcat 8 supports some of the good features like:
- JSP 2.3:
- Java Unified Expression Language (EL) 3.0: EL 3.0 gives you opportunity to define Lambda functions, which is very easy to express and consume. Fe example of Lambda functions are as below:
- (x -> x+1) (x=10) Result = 11
- ((x,y) -> x+y) (2,7) Result = 9
- Recursive calls:
- Factorial = n -> n==0?1:n*Factorial(n-1); Factorial (5) = 120
- Also syntax to express a Composite data type comprising SET, LIST is similar to JSON and thus it’s easy to consume JSON
- You can follow the reference in this link:
Caveat: At this time Java Web Tomcat 8 V.3.2.14 is available for download and use from HCP Tools site:
However HCP trial account has not started to support the runtime yet. So you can try it only on local environment.
Using Java Web Tomcat 8 environment:
Step 1: Download the runtime zip from HCP Tools site and save it in local folder.
Step 2: Go to Eclipse and set up runtime.
Windows Machine: Windows -> Preferences -> Server -> Runtime Environment
Mac: Preferences -> Server -> Runtime Environment
Just Add -> and choose the unzipped runtime folder where you saved the runtime in step 1.
Finish and you are ready to use the new Runtime !!! Enjoy!!!