Section 4 Lecture 2
Earlier we configured our Eclipse development environment and we are now ready to create our
Java application. Full source code for our sample RESTful application is available for download from
the CICSdev GitHub using the URL shown. Go to this address now to download the source we need
to get started.
To deploy our application into a Java EE server, we need a delivery vehicle, and for this example we
will use a simple Web Application Archive, or WAR file. We can create a suitable project in our
environment by selecting File, New, and then Project from the menu bar.
In the resulting New project dialog, select Dynamic Web Project from the Web folder, and click Next.
In my workspace I am using a project name of com.ibm.cicsdev.restapp. We do not require a target
runtime selected, and we wish to use the default dynamic web module version of 3.0. Deselect the
option to add the project to an EAR. An Enterprise Archive, or EAR, file is an advanced deployment
option that is not required for our example.
Click Next to complete this page, and then accept the defaults on the following page by clicking Next
again. In the final dialog box, select the checkbox to generate a web.xml deployment descriptor, and
click Finish.
You may be prompted to switch to the Java EE perspective. Use of the Java EE perspective is not
required to complete development of this application, but I will be using it here, because it offers
some useful views into the state of our development environment, along with providing some
helpful context-sensitive menus.
Now we have an encapsulating project, we can start building the application. First, we will create the
Java classes that will contain the response data we will return to the caller. These classes will be
simple Java beans, which use the JAXB interface.
JAXB, or the Java Architecture for XML Binding, is a framework used to map Java classes to XML. It
can also be used to map Java classes to a JSON format, and it is for this reason we will use it here.
In this example, we will use two classes: CICSInformation and CICSEnvironment.
The CICSInformation class contains three pieces of information related to the CICS JVM server. It also
contains a reference to an instance of the CICSEnvironment class, which itself holds information
relating to the CICS runtime environment.
We will now add code to the application. Using the code downloaded from the CICSdev GitHub
repository, drag and drop the top-level folder named com onto the src folder. When prompted,
select the option to Copy files and click OK.
You should now have two Java packages, as shown here: com.ibm.cicsdev.restapp, and a related
.bean package.
Importing the Java classes will produce some compile errors, due to missing classes in the build path.
We will fix the compile errors now. Right-click on the project, and select Build path, and then
Configure Build Path. In the resulting dialog, select the Libraries tab and click Add Library.
In the next dialog box, select “Liberty JVM server libraries” and click Next again. For this example
application, we do not need functionality over and above that provided by CICS TS V5.1. Select CICS
TS 5.1 from the menu and click Finish.