Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit 5502900

Browse files
cockermacockerma
authored andcommitted
Put JVM server in properties file
1 parent 49b405d commit 5502900

File tree

2 files changed

+91
-54
lines changed

2 files changed

+91
-54
lines changed

addtocicsbundle/README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,44 @@ DIRECTORY is the CICS bundle directory
3535

3636
## Example
3737

38-
This example will create a CICS bundle in directory bundles/MyBundle and add *.war web archive files that will be installed into the JVM sserver called DFHWLP.
38+
This example will create a CICS bundle in directory output/bundles/com.ibm.cics.server.examples.bundle and add *.jar and *.war archive files.
3939

40-
Note the `-a "*.jar"` parameter includes quotation marks to avoid the shell interpreter expansion.
40+
Note the `-a "javaarchives/*"` parameter includes quotation marks to avoid the shell interpreter expansion.
4141

4242
~~~~console
43-
$ addtocicsbundle -v -j DFHWLP -a "*.jar" bundles/com.example.mybundle
44-
45-
Creating directory bundles/com.example.mybundle/META-INF
46-
Creating file bundles/com.example.mybundle/com.ibm.cics.server.examples.hello_1.0.0.jar.osgibundle
47-
Adding bundle part file to the manifest file bundles/com.example.mybundle/META-INF/cics.xml
48-
Copying file com.ibm.cics.server.examples.hello_1.0.0.jar to bundles/com.example.mybundle
49-
Creating file bundles/com.example.mybundle/com.ibm.cics.server.examples.jcics_1.0.0.jar.osgibundle
50-
Adding bundle part file to the manifest file bundles/com.example.mybundle/META-INF/cics.xml
51-
Copying file com.ibm.cics.server.examples.jcics_1.0.0.jar to bundles/com.example.mybundle
52-
Creating file bundles/com.example.mybundle/com.ibm.cics.server.examples.web_1.0.0.jar.osgibundle
53-
Adding bundle part file to the manifest file bundles/com.example.mybundle/META-INF/cics.xml
54-
Copying file com.ibm.cics.server.examples.web_1.0.0.jar to bundles/com.example.mybundle
43+
$ addtocicsbundle -v -a "javaarchives/*" output/bundles/com.ibm.cics.server.examples.bundle
44+
Creating CICS bundle manifest file output/bundles/com.ibm.cics.server.examples.bundle/META-INF/cics.xml
45+
Creating CICS bundle part file output/bundles/com.ibm.cics.server.examples.bundle/com.ibm.cics.server.examples.hello.osgibundle
46+
Adding bundle part to the CICS bundle manifest file output/bundles/com.ibm.cics.server.examples.bundle/META-INF/cics.xml
47+
Adding property jvmserver.DFHOSGI=DFHOSGI to output/bundles/com.ibm.cics.server.examples.bundle/variable.properties
48+
Copying file javaarchives/com.ibm.cics.server.examples.hello_1.0.0.jar to output/bundles/com.ibm.cics.server.examples.bundle
49+
Creating CICS bundle part file output/bundles/com.ibm.cics.server.examples.bundle/com.ibm.cics.server.examples.jcics.osgibundle
50+
Adding bundle part to the CICS bundle manifest file output/bundles/com.ibm.cics.server.examples.bundle/META-INF/cics.xml
51+
Copying file javaarchives/com.ibm.cics.server.examples.jcics_1.0.0.jar to output/bundles/com.ibm.cics.server.examples.bundle
52+
Creating CICS bundle part file output/bundles/com.ibm.cics.server.examples.bundle/com.ibm.cics.server.examples.web.osgibundle
53+
Adding bundle part to the CICS bundle manifest file output/bundles/com.ibm.cics.server.examples.bundle/META-INF/cics.xml
54+
Copying file javaarchives/com.ibm.cics.server.examples.web_1.0.0.jar to output/bundles/com.ibm.cics.server.examples.bundle
55+
Creating CICS bundle part file output/bundles/com.ibm.cics.server.examples.bundle/com.ibm.cics.server.examples.wlp.hello.warbundle
56+
Adding bundle part to the CICS bundle manifest file output/bundles/com.ibm.cics.server.examples.bundle/META-INF/cics.xml
57+
Adding property jvmserver.DFHWLP=DFHWLP to output/bundles/com.ibm.cics.server.examples.bundle/variable.properties
58+
Copying file javaarchives/com.ibm.cics.server.examples.wlp.hello.war to output/bundles/com.ibm.cics.server.examples.bundle
5559
Summary for directory:
56-
bundles/com.example.mybundle:
57-
total 44
58-
-rw-r--r-- 1 cockerma cockerma 2124 May 12 04:54 com.ibm.cics.server.examples.hello_1.0.0.jar
59-
-rw-r--r-- 1 cockerma cockerma 156 May 12 04:54 com.ibm.cics.server.examples.hello_1.0.0.jar.osgibundle
60-
-rw-r--r-- 1 cockerma cockerma 15977 May 12 04:54 com.ibm.cics.server.examples.jcics_1.0.0.jar
61-
-rw-r--r-- 1 cockerma cockerma 156 May 12 04:54 com.ibm.cics.server.examples.jcics_1.0.0.jar.osgibundle
62-
-rw-r--r-- 1 cockerma cockerma 5841 May 12 04:54 com.ibm.cics.server.examples.web_1.0.0.jar
63-
-rw-r--r-- 1 cockerma cockerma 154 May 12 04:54 com.ibm.cics.server.examples.web_1.0.0.jar.osgibundle
64-
drwxr-xr-x 2 cockerma cockerma 4096 May 12 04:54 META-INF
60+
output/bundles/com.ibm.cics.server.examples.bundle:
61+
total 112
62+
-rw-r--r-- 1 cockerma cockerma 2124 May 15 15:23 com.ibm.cics.server.examples.hello_1.0.0.jar
63+
-rw-r--r-- 1 cockerma cockerma 169 May 15 15:23 com.ibm.cics.server.examples.hello.osgibundle
64+
-rw-r--r-- 1 cockerma cockerma 15977 May 15 15:23 com.ibm.cics.server.examples.jcics_1.0.0.jar
65+
-rw-r--r-- 1 cockerma cockerma 169 May 15 15:23 com.ibm.cics.server.examples.jcics.osgibundle
66+
-rw-r--r-- 1 cockerma cockerma 5841 May 15 15:23 com.ibm.cics.server.examples.web_1.0.0.jar
67+
-rw-r--r-- 1 cockerma cockerma 167 May 15 15:23 com.ibm.cics.server.examples.web.osgibundle
68+
-rw-r--r-- 1 cockerma cockerma 60618 May 15 15:23 com.ibm.cics.server.examples.wlp.hello.war
69+
-rw-r--r-- 1 cockerma cockerma 155 May 15 15:23 com.ibm.cics.server.examples.wlp.hello.warbundle
70+
drwxr-xr-x 2 cockerma cockerma 4096 May 15 15:23 META-INF
71+
-rw-r--r-- 1 cockerma cockerma 122 May 15 15:23 variable.properties
6572

66-
bundles/com.example.mybundle/META-INF:
73+
output/bundles/com.ibm.cics.server.examples.bundle/META-INF:
6774
total 4
68-
-rw-r--r-- 1 cockerma cockerma 917 May 12 04:54 cics.xml
75+
-rw-r--r-- 1 cockerma cockerma 1064 May 15 15:23 cics.xml
6976
Exiting with RC=0
7077
~~~~
7178

addtocicsbundle/addtocicsbundle

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#############################################################################################
3-
# Script to add Java parts to a CICS bundle
3+
# Script to add Java pre-built arhcive files to a CICS bundle
44
#
55
# Licensed Materials - Property of IBM.
66
# (c) Copyright IBM Corporation 2017. All Rights Reserved.
@@ -30,17 +30,20 @@ show_help () {
3030
# Function to create an empty CICS bundle
3131
create_bundle() {
3232
# Create the CICS bundle directory
33-
echo "Creating directory ${MANIFEST_DIRECTORY}"
3433
mkdir -p "${MANIFEST_DIRECTORY}"
3534

3635
if [[ ! -d "${DIRECTORY}" ]] ; then
37-
echo "Could not create directory ${MANIFEST_DIRECTORY}"
36+
echo "Could not create CICS bundle manifest directory ${MANIFEST_DIRECTORY}"
3837
exit 1
3938
fi
4039

4140
# Create the CICS bundle manifest file
4241
MANIFEST_TIMESTAMP=$(date +"%Y-%m-%dT%T.%3N%:z")
4342

43+
if [[ $VERBOSE == 1 ]] ; then
44+
echo "Creating CICS bundle manifest file ${MANIFEST}"
45+
fi
46+
4447
cat > "${MANIFEST}" <<EOF
4548
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
4649
<manifest xmlns="http://www.ibm.com/xmlns/prod/cics/bundle" id="${SYMBOLICNAME}" bundleMajorVer="1" bundleMinorVer="0" bundleMicroVer="0" bundleVersion="1" bundleRelease="0">
@@ -51,6 +54,17 @@ create_bundle() {
5154
EOF
5255
}
5356

57+
# Get the value from a property in a .properties file
58+
# Modified technique from http://shrubbery.homeip.net/c/display/W/Reading+Java-style+Properties+Files+with+Shell
59+
get_property () {
60+
# If properties file does not exist, just exit
61+
if [[ ! -f $2 ]] ; then
62+
exit
63+
fi
64+
65+
echo `sed '/^\#/d' $2 | grep "${1}*=" | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
66+
}
67+
5468
# Function to add a file to a CICS bundle
5569
add_file_to_cics_bundle() {
5670
FILENAME=$(basename "${FILE}")
@@ -72,34 +86,35 @@ add_file_to_cics_bundle() {
7286
create_bundle
7387
fi
7488

75-
# Set bundle part JVMSERVER
89+
# Set the bundle part JVMSERVER
7690
if [[ -z "${JVMSERVER}" ]] ; then
77-
if [[ "${FILEEXTENSION}" -eq "jar" ]] ; then
91+
if [[ "${FILEEXTENSION}" = "jar" ]] ; then
7892
BUNDLEPARTJVMSERVER="DFHOSGI"
7993
else
8094
BUNDLEPARTJVMSERVER="DFHWLP"
8195
fi
8296
else
8397
BUNDLEPARTJVMSERVER="${JVMSERVER}"
8498
fi
99+
BUNDLEPARTJVMSERVERPROPERTY="jvmserver.${BUNDLEPARTJVMSERVER}"
85100

86101
# Relate the file type to the CICS bundle part type
87102
case "${FILEEXTENSION}" in
88103
"jar")
89104
BUNDLEPARTEXTENSION="osgibundle"
90-
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" version="'${BUNDLEPARTVERSION}'" jvmserver="'${BUNDLEPARTJVMSERVER}'"/>'
105+
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" version="'${BUNDLEPARTVERSION}'" jvmserver="${'${BUNDLEPARTJVMSERVERPROPERTY}'}"/>'
91106
;;
92107
"war")
93108
BUNDLEPARTEXTENSION="warbundle"
94-
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" jvmserver="'${BUNDLEPARTJVMSERVER}'"/>'
109+
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" jvmserver="${'${BUNDLEPARTJVMSERVERPROPERTY}'}"/>'
95110
;;
96111
"ear")
97112
BUNDLEPARTEXTENSION="earbundle"
98-
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" jvmserver="'${BUNDLEPARTJVMSERVER}'"/>'
113+
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" jvmserver="${'${BUNDLEPARTJVMSERVERPROPERTY}'}"/>'
99114
;;
100115
"eba")
101116
BUNDLEPARTEXTENSION="ebabundle"
102-
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" jvmserver="'${BUNDLEPARTJVMSERVER}'"/>'
117+
BUNDLEPART=$'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<'${BUNDLEPARTEXTENSION}' symbolicname="'${SYMBOLICNAME}'" jvmserver="${'${BUNDLEPARTJVMSERVERPROPERTY}'}"/>'
103118
;;
104119
*)
105120
BUNDLEPARTEXTENSION=""
@@ -112,30 +127,45 @@ add_file_to_cics_bundle() {
112127
fi
113128

114129
BUNDLEPARTTYPE="http://www.ibm.com/xmlns/prod/cics/bundle/${BUNDLEPARTEXTENSION^^}"
115-
BUNDLEPARTFILE="${DIRECTORY}/${FILENAME}.${BUNDLEPARTEXTENSION}"
130+
BUNDLEPARTFILE="${DIRECTORY}/${SYMBOLICNAME}.${BUNDLEPARTEXTENSION}"
116131

117132
# Check if bundle part already exists
118-
ENTRY=$(xmlstarlet sel -t -c '//_:define[@name="'"${FILENAME}"'"][@type="'"${BUNDLEPARTTYPE}"'"]' "${MANIFEST}")
133+
ENTRY=$(xmlstarlet sel -t -c '//_:define[@name="'"${SYMBOLICNAME}"'"][@type="'"${BUNDLEPARTTYPE}"'"]' "${MANIFEST}")
119134
if [[ ! -z "${ENTRY}" ]] ; then
120-
echo "Error - CICS bundle part ${FILENAME} for type ${BUNDLEPARTTYPE} in ${MANIFEST} already exists"
121-
exit 8
122-
fi
135+
if [[ $VERBOSE == 1 ]] ; then
136+
echo "CICS bundle part ${SYMBOLICNAME} for type ${BUNDLEPARTTYPE} in ${MANIFEST} already exists"
137+
fi
138+
else
139+
# Create bundle part file
140+
if [[ $VERBOSE == 1 ]] ; then
141+
echo "Creating CICS bundle part file ${BUNDLEPARTFILE}"
142+
fi
143+
echo "${BUNDLEPART}" > "${BUNDLEPARTFILE}"
123144

124-
# Create bundle part file
125-
if [[ $VERBOSE == 1 ]] ; then
126-
echo "Creating file ${BUNDLEPARTFILE}"
127-
fi
128-
echo "${BUNDLEPART}" > "${BUNDLEPARTFILE}"
145+
# Add part to the CICS bundle manifest
146+
if [[ $VERBOSE == 1 ]] ; then
147+
echo "Adding bundle part to the CICS bundle manifest file ${MANIFEST}"
148+
fi
149+
xmlstarlet ed -L -s "//_:manifest" -t elem -n define -v "" \
150+
-i "//_:manifest/define" -t attr -n name -v "${SYMBOLICNAME}" \
151+
-i "//_:manifest/define" -t attr -n type -v "${BUNDLEPARTTYPE}" \
152+
-i "//_:manifest/define" -t attr -n path -v "${FILENAME}.${BUNDLEPARTEXTENSION}" \
153+
"${MANIFEST}"
154+
155+
# Add JVMSERVER to properties file if it is not already defined
156+
PROPERTIES="${DIRECTORY}/variable.properties"
129157

130-
# Add part to the CICS bundle manifest
131-
if [[ $VERBOSE == 1 ]] ; then
132-
echo "Adding bundle part file to the manifest file ${MANIFEST}"
133-
fi
134-
xmlstarlet ed -L -s "//_:manifest" -t elem -n define -v "" \
135-
-i "//_:manifest/define" -t attr -n name -v "${FILENAME}" \
136-
-i "//_:manifest/define" -t attr -n type -v "${BUNDLEPARTTYPE}" \
137-
-i "//_:manifest/define" -t attr -n path -v "${FILENAME}.${BUNDLEPARTEXTENSION}" \
138-
"${MANIFEST}"
158+
if [[ -z $(get_property ${BUNDLEPARTJVMSERVERPROPERTY} ${PROPERTIES}) ]] ; then
159+
if [[ $VERBOSE == 1 ]] ; then
160+
echo "Adding property ${BUNDLEPARTJVMSERVERPROPERTY}=${BUNDLEPARTJVMSERVER} to ${PROPERTIES}"
161+
fi
162+
163+
echo -e \
164+
"\n# Added by script" $(basename "$0") \
165+
"\n${BUNDLEPARTJVMSERVERPROPERTY}=${BUNDLEPARTJVMSERVER}" \
166+
>> "${PROPERTIES}"
167+
fi
168+
fi
139169

140170
# Copy file to be added into CICS bundle
141171
if [[ $VERBOSE == 1 ]] ; then
@@ -274,4 +304,4 @@ if [[ $VERBOSE == 1 ]] ; then
274304

275305
echo "Exiting with RC=${TOTALRC}"
276306
fi
277-
exit ${TOTALRC}
307+
exit ${TOTALRC}

0 commit comments

Comments
 (0)