Skip to content

Commit f9796c8

Browse files
committed
Initial sample to show appending char containers
1 parent b789132 commit f9796c8

File tree

10 files changed

+320
-0
lines changed

10 files changed

+320
-0
lines changed

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.versionsBackup
5+
pom.xml.next
6+
release.properties
7+
dependency-reduced-pom.xml
8+
buildNumber.properties
9+
.mvn/timing.properties
10+
11+
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
12+
!/.mvn/wrapper/maven-wrapper.jar
13+
14+
# Eclipse metadata
15+
.settings
16+
.project
17+
.classpath
18+
.metadata
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Append CHAR Container Sample
2+
3+
This sample shows how you can use the JCICSX API to create a channel containing a CHAR container, and then append data to this container and get the output at the end.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
4+
<groupId>com.ibm.cics</groupId>
5+
<artifactId>append-char-container-sample</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<packaging>war</packaging>
8+
9+
<dependencies>
10+
<dependency>
11+
<groupId>javax.servlet</groupId>
12+
<artifactId>javax.servlet-api</artifactId>
13+
<version>3.1.0</version>
14+
<scope>provided</scope>
15+
</dependency>
16+
<dependency>
17+
<groupId>javax.annotation</groupId>
18+
<artifactId>jsr250-api</artifactId>
19+
<version>1.0</version>
20+
<scope>provided</scope>
21+
</dependency>
22+
<dependency>
23+
<!-- <groupId>com.ibm.cics</groupId>
24+
<artifactId>com.ibm.cics.jcicsx</artifactId> -->
25+
<groupId>com.ibm.cics.exec-cics-http</groupId>
26+
<artifactId>jcicsx-http-client</artifactId>
27+
<version>0.0.8-SNAPSHOT</version>
28+
</dependency>
29+
</dependencies>
30+
31+
<build>
32+
<pluginManagement>
33+
<plugins>
34+
<plugin>
35+
<groupId>org.apache.maven.plugins</groupId>
36+
<artifactId>maven-war-plugin</artifactId>
37+
<version>3.2.2</version>
38+
<configuration>
39+
<failOnMissingWebXml>false</failOnMissingWebXml>
40+
</configuration>
41+
</plugin>
42+
<plugin>
43+
<groupId>org.apache.maven.plugins</groupId>
44+
<artifactId>maven-compiler-plugin</artifactId>
45+
<configuration>
46+
<source>1.8</source>
47+
<target>1.8</target>
48+
</configuration>
49+
</plugin>
50+
</plugins>
51+
</pluginManagement>
52+
</build>
53+
54+
55+
</project>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package sample;
2+
3+
import java.io.IOException;
4+
5+
import javax.servlet.ServletException;
6+
import javax.servlet.annotation.WebServlet;
7+
import javax.servlet.http.HttpServlet;
8+
import javax.servlet.http.HttpServletRequest;
9+
import javax.servlet.http.HttpServletResponse;
10+
11+
import com.ibm.cics.jcicsx.CHARContainer;
12+
import com.ibm.cics.jcicsx.CICSConditionException;
13+
import com.ibm.cics.jcicsx.CICSContext;
14+
15+
/**
16+
* Servlet implementation class SimpleServlet
17+
*/
18+
@WebServlet("/SampleServlet")
19+
public class SampleServlet extends HttpServlet {
20+
21+
private static final long serialVersionUID = 1L;
22+
23+
private static final String CHANNEL_NAME = "charchan";
24+
25+
private static final String CONTAINER_NAME = "charcont";
26+
27+
/**
28+
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
29+
*/
30+
@Override
31+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32+
response.setContentType("text/html");
33+
34+
response.getWriter().print("Hello world!");
35+
36+
// Gets the current CICS Context for the environment we're running in
37+
CICSContext task = CICSContext.getCICSContext();
38+
39+
try {
40+
// Create a new channel called "charchan", with a CHAR container called "charcont"
41+
// Add the text to the CHAR container
42+
CHARContainer charContainer = task.getChannel(CHANNEL_NAME)
43+
.getCHARContainer(CONTAINER_NAME)
44+
.put("I'm running under task ");
45+
46+
// Get the current task number that this unit of work is running under
47+
Integer taskNumber = task.getTaskNumber();
48+
49+
// Add the task number to the enf of the CHAR container
50+
charContainer = charContainer.append(taskNumber.toString());
51+
52+
// Get the full contents of the container, and print this
53+
String combinedString = charContainer.get();
54+
response.getWriter().println(combinedString);
55+
56+
} catch (CICSConditionException e) {
57+
System.out.println("An exception has occured with" +
58+
" RESP: " + e.getResp2() +
59+
" RESP2: " + e.getResp2() +
60+
" Message: " + e.getMessage());
61+
}
62+
}
63+
64+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
5+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
6+
version="3.1">
7+
<login-config>
8+
<auth-method>CLIENT-CERT</auth-method>
9+
</login-config>
10+
</web-app>
42.7 KB
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Java Web Starter Application</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6+
<link rel="stylesheet" href="style.css" />
7+
</head>
8+
<body>
9+
<table>
10+
<tr>
11+
<td style='width: 30%;'>
12+
<img class = "newappIcon" src='images/cics.png'>
13+
</td>
14+
<td>
15+
<!-- The message comes from /SampleServlet -->
16+
<h1 id = "message"></h1>
17+
18+
<p class='description'></p> Thanks for creating a <span class="blue">Liberty for Java Starter Application</span>.
19+
</td>
20+
</tr>
21+
</table>
22+
<!-- Call SampleServlet to get the message -->
23+
<script type="text/javascript" src="index.js"></script>
24+
</body>
25+
</html>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// index.js
2+
3+
// request message on server
4+
//Calls SampleServlet to get the message
5+
xhrGet("SampleServlet", function(responseText){
6+
// add to document
7+
var mytitle = document.getElementById('message');
8+
mytitle.innerHTML = responseText;
9+
10+
}, function(err){
11+
console.log(err);
12+
});
13+
14+
//utilities
15+
function createXHR(){
16+
if(typeof XMLHttpRequest != 'undefined'){
17+
return new XMLHttpRequest();
18+
}else{
19+
try{
20+
return new ActiveXObject('Msxml2.XMLHTTP');
21+
}catch(e){
22+
try{
23+
return new ActiveXObject('Microsoft.XMLHTTP');
24+
}catch(e){}
25+
}
26+
}
27+
return null;
28+
}
29+
function xhrGet(url, callback, errback){
30+
var xhr = new createXHR();
31+
xhr.open("GET", url, true);
32+
xhr.onreadystatechange = function(){
33+
if(xhr.readyState == 4){
34+
if(xhr.status == 200){
35+
callback(xhr.responseText);
36+
}else{
37+
errback('service not available');
38+
}
39+
}
40+
};
41+
xhr.timeout = 3000;
42+
xhr.ontimeout = errback;
43+
xhr.send();
44+
}
45+
function parseJson(str){
46+
return window.JSON ? JSON.parse(str) : eval('(' + str + ')');
47+
}
48+
function prettyJson(str){
49+
// If browser does not have JSON utilities, just print the raw string value.
50+
return window.JSON ? JSON.stringify(JSON.parse(str), null, ' ') : str;
51+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* style.css
2+
* This file provides css styles.
3+
*/
4+
5+
body,html {
6+
background-color: #3b4b54; width : 100%;
7+
height: 100%;
8+
margin: 0 auto;
9+
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
10+
color: #ffffff;
11+
}
12+
13+
a {
14+
text-decoration: none;
15+
color: #00aed1;
16+
}
17+
18+
a:hover {
19+
text-decoration: underline;
20+
}
21+
22+
.newappIcon {
23+
padding-top: 10%;
24+
display: block;
25+
margin: 0 auto;
26+
padding-bottom: 2em;
27+
max-width:200px;
28+
}
29+
30+
h1 {
31+
font-weight: bold;
32+
font-size: 2em;
33+
}
34+
35+
.leftHalf {
36+
float: left;
37+
background-color: #26343f;
38+
width: 45%;
39+
height: 100%;
40+
}
41+
42+
.rightHalf {
43+
float: right;
44+
width: 55%;
45+
background-color: #313f4a;
46+
height: 100%;
47+
overflow:auto;
48+
}
49+
50+
.description {
51+
padding-left: 50px;
52+
padding-right: 50px;
53+
text-align: center;
54+
font-size: 1.2em;
55+
}
56+
57+
.blue {
58+
color: #00aed1;
59+
}
60+
61+
62+
table {
63+
table-layout: fixed;
64+
width: 800px;
65+
margin: 0 auto;
66+
word-wrap: break-word;
67+
padding-top:10%;
68+
}
69+
70+
th {
71+
border-bottom: 1px solid #000;
72+
}
73+
74+
th, td {
75+
text-align: left;
76+
padding: 2px 20px;
77+
}
78+
79+
.env-var {
80+
text-align: right;
81+
border-right: 1px solid #000;
82+
width: 30%;
83+
}
84+
85+
pre {
86+
padding: 0;
87+
margin: 0;
88+
}

clientdb.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<com.ibm.magnolia.clientmodel:ClientModelRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.magnolia.clientmodel="http:///com/ibm/magnolia/clientmodel.ecore">
3+
<workItemEditorHistory/>
4+
<queries/>
5+
<queryViews/>
6+
</com.ibm.magnolia.clientmodel:ClientModelRoot>

0 commit comments

Comments
 (0)