cics java application development for everyone
TRANSCRIPT
CICS Java Application Development for EveryoneStew Francis – CICS Explorer Architect, CICS Developer Experience Technical LeadIBM
November 10th 2020Session 5as
PL/I
Java
C++
COBOLNode
• CICS is great at hosting polyglot applications
• CICS API handles transitioning between components in different languages
• CICS provides JVMs with tight integration with native applications, that can participate in business transactions
• We provide an API for interacting with CICS resources and other programs, called JCICS, in all of those JVMs
• Applications can be OSGi bundles, or Java EE web applications
Why’s Java a good choice?
WebSphere Liberty Profile• A streamlined version of WebSphere Application Server
• Runs Java web applications written to the Java EE specification
• Provides access to technologies like Servlets, JAX-RS, WebSockets, MicroProfile
• Rich set of capabilities you can use to extend and augment your existing CICS programs
5
• https://redmonk.com/sogrady/2020/02/28/language-rankings-1-20/(2020)
How popular is Java anyway?
“Over the last nine months, Java and JavaScript have remained the two dominant languages in the enterprise developer landscape…”
https://www.cloudfoundry.org/wp-content/uploads/Developer-Language-Report_FINAL.pdf (2018)
7
Why do we need CICS bundles?
A CICS bundle is a package for deploying resources into CICS
Once our Java application is deployed, we need some way of referring to it so we can e.g. un-deploy it later
CICS bundle provides us• Identity for a collection of resources• Means of life-cycling them• Means of supplying additional meta-data
For Java applications we must specify which JVM
CICS region JVMA
JVMB
JVMC
JVMD
<warbundlesymbolicname=”javaapp”jvmserver="JVMA"/>
8
What are Maven and Gradle?
Pluggable build systems and dependency management for Java applications
Dependency management:• Online catalog of libraries: Maven Central
• Used by both Maven and Gradle builds
• More than 3 million reusable components
• Applications can declare dependencies on these libraries
• Maven and Gradle take care of retrieving the library and using it at build-time / runtime
9
What are Maven and Gradle?
Pluggable build systems and dependency management for Java applications
Pluggable build systems• Create plugins which encapsulate build
logic
• Plugins are shareable across projects within an enterprise, or with the world
• Applications can declare dependencies on plugins too
10
60%
19%
11%
4%6%
0%
10%
20%
30%
40%
50%
60%
70%
Build tool
Build tool popularity
Maven Gradle Ant Other None
Source: Snyk Java ecosystem report 2018
11
How’s this fit into CICS Java development?
Not very smoothly!
• Java libraries for EXEC CICS API etc aren’t available on Maven Central
• We built bespoke support in CICS Explorer for automatically setting up a compilation environment for you• Doesn’t really help you if you want to use
Maven or Gradle, though.
• Once you have the API to code against set up locally, actually writing the code in CICS Explorer is pretty good
• However, to get your Java into CICS, need to use a CICS bundle
12
Our solution:
• Put our Java API libraries in Maven central• JCICS
com.ibm.cics.server• Annotations
com.ibm.cics.server.invocation.annotations• Annotation processor
com.ibm.cics.server.invocation
• Create a Maven plugin for authoring CICS bundles, which can be used directly in your Java application build toolchain
• Create a Gradle plugin for authoring CICS bundles, which can be used directly in your Java application build toolchain
<dependency><groupId>com.ibm.cics</groupId><artifactId>com.ibm.cics.server</artifactId><version>1.700.0-5.5-PH10453</version><scope>provided</scope>
</dependency>
<plugin><groupId>com.ibm.cics</groupId><artifactId>cics-bundle-maven-plugin</artifactId><version>0.0.1</version>
</plugin>
DevelopmentEnvironment CICS Region
Java application
Native application
DEPLOYJava application
LINK
JCICS Application
DevelopmentEnvironment CICS Region
Java applicationDeploy
JCICS Application• Have to deploy
applications to try them out
• Deploying can be awkward, especially when repeated many times
Java application
LINK
Native application
DevelopmentEnvironment CICS Region
Java applicationLINK
Native application
JCICSX Application • Can test LINK commands locally in dev environment
• JCICSX applications can then be deployed unchanged to a CICS region
Java applicationDeploy
OR
LINK
Native application
Java program
JCICSX-Native
Native program
JCICSX-HTTP Client
DEV ENVIRONMENT
CICS REGION
JCICSX-HTTPServer
• Same program can run in CICS via a native API implementation
• And remotely in development environments via an HTTP implementation
<?xml version="1.0" encoding="UTF-8"?><server description="CICS Liberty sample configuration">
<featureManager><feature>cicsts:core-1.0</feature><feature>cicsts:jcicsxServer-1.0</feature>
</featureManager>
<httpEndpoint host="*" httpPort="28953" httpsPort="-1"id="defaultHttpEndpoint"/>
<!-- CICS Bundle Installed Applications --><include location="${server.output.dir}/installedApps.xml" onConflict="IGNORE"/>
<webAppSecurity allowFailOverToBasicAuth="true"/><executor id="allowCICSconfigure" maxThreads="15"/>
</server>
<?xml version="1.0" encoding="UTF-8"?><server description="Sample Servlet server">
<featureManager><feature>jaxrs-2.0</feature><feature>usr:jcicsxClient-1.0</feature>
</featureManager>
<usr_jcicsxClient serverUri=”http://cicsex56.hursley.ibm.com:28951" />
<httpEndpoint httpPort="53331" id="defaultHttpEndpoint" host="*" /></server>
20
How does the API work?
DEV1
DEV2
DEV3
CMCI
CSD
CICSzFS
As developer As deploy user As region user
Summary
21
• JSON API-enabled a CICS program using a Java servlet
• Used Maven for development
• Tested the application locally using JCICSX remote development support
• Deployed to CICS, and verified the behaviour was identical
IntelliJ
22
VS Code
23
24
Eclipse Che
GraphQL app Native Program
CMCI JVM Server in CICS
JCICS link to program
CMCI JVM Server in CICS
GraphQL app Native Program
JCICSX link to program
CMCI JVM Server in CICS
GraphQL app Native Program
JCICSX link to program
JCICSX Server
JCICSX link to program
Local Liberty Server
Mock-based testing
Statically defined code-paths are more difficult to test with mock-based testing
JCICS includes some static methods, and requires you use the new keyword, which makes it difficult to inject test-doubles a.k.a. mocks
These tests would typically be accompanied by more exhaustive integration testing, to test all the units together
Mock-based testing
JCICSX is designed to accommodate mock-based tests, making it easy to unit test your java business logic in isolation, for exhaustive testing
program.link()
program.link()
Test success
Test failure
Put ”1” in container APut “Jones” in container B
Return to the caller
Throw an exception as if the program didn’t exist
Java program(Dev Environment) JCICSX server
Start Transaction
End Transaction
PUT CONTAINER
GET CONTAINER
PUT CONTAINER
LINK PROGRAM
• HTTP API explicitly creates and ends remote transactions
• This ensures that in development setups, transactions are the same
Spring Boot
Spring Boot • CICS TS 5.6 (and 5.5 by APAR) support Spring Boot applications
• https://developer.ibm.com/tutorials/spring-boot-java-applications-for-cics-part-1-jcics-maven-gradle/
• Starter projects are opinionated about Maven/Gradle, so fits nicely to have our dependencies there
• And now Spring Boot applications are easier to CICS Bundle
Requirements and Assumptions
• JCICSX available now in CICS TS 5.6• https://www.ibm.com/support/kno
wledgecenter/SSGMCP_5.6.0/applications/developing/java/jcicsx-api.html
• Remote development client • https://developer.ibm.com/wasdev/
downloads/#asset/features-com.ibm.cics.wlp.jcicsxClient-1.0
• Maven plugin• https://github.com/IBM/cics-
bundle-maven• Gradle plugin• https://github.com/IBM/cics-
bundle-gradle
Requirements and Assumptions
• Managed bundles API is available in CICS TS 5.6• https://www.ibm.com/support/kno
wledgecenter/SSGMCP_5.6.0/fundamentals/cpsm/cics-bundle-api.html
• Requires CPSM, we’re investigating support for standalone regions
• Maven samples• https://github.com/IBM/cics-
bundle-maven/tree/master/samples• Gradle samples• https://github.com/IBM/cics-
bundle-gradle/tree/master/samples• JCICSX Samples• https://github.com/cicsdev/cics-
java-jcicsx-samples
Q&A
Please submit your session feedback!
• Do it online at http://conferences.gse.org.uk/2020/feedback/5as
• This session is 5as
GSE UK Conference 2020 Charity
• The GSE UK Region team hope that you find this presentation and others that follow useful and help to expand your knowledge of z Systems. • Please consider showing your appreciation by kindly donating a small
sum to our charity this year, NHS Charities Together. Follow the link below or scan the QR Code:
http://uk.virginmoneygiving.com/GuideShareEuropeUKRegion