Skip to content

Commit cbc2d0c

Browse files
author
Thomas Weise
committed
Added First Web Services Example and Build Scripts for All Examples
I added the first example for web services, a warehouse client and server. Both can be built with Maven. When building the client, we rely on the WSDL provided by the server after being deployed in axis2. Build scripts have been added for all examples for Linux. Their names are all make_linux.sh. The make_linux.sh in the root folder builds all examples one by one. The build script for the web service examples downloads and runs axis2. The travis builds now use the make_linux.sh build script from the root folder.
1 parent c4512f2 commit cbc2d0c

33 files changed

+1084
-22
lines changed

.gitignore

+22-2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ hs_err_pid*
5858
/.gradle
5959
/dependency-reduced-pom.xml
6060

61+
#helloWorld
62+
/helloWorld/helloWorld
63+
/helloWorld/helloWorld.exe
64+
6165
## sockets
6266
## Linux Builds of C examples
6367
/sockets/c/TCPClient_linux
@@ -90,10 +94,26 @@ hs_err_pid*
9094
/javaRMI/bin/
9195
/javaRMI/.classpath
9296

93-
9497
## XML
9598
/xml/java/target/
9699
/xml/java/temp/
97100
/xml/java/tmp/
98101
/xml/java/bin/
99-
/xml/java/.classpath
102+
/xml/java/.classpath
103+
104+
## web services
105+
### warehouse server example
106+
/webServices/warehouse/server/target/
107+
/webServices/warehouse/server/temp/
108+
/webServices/warehouse/server/tmp/
109+
/webServices/warehouse/server/bin/
110+
/webServices/warehouse/server/.classpath
111+
#
112+
### warehouse client example
113+
/webServices/warehouse/client/target/
114+
/webServices/warehouse/client/temp/
115+
/webServices/warehouse/client/tmp/
116+
/webServices/warehouse/client/bin/
117+
/webServices/warehouse/client/.classpath
118+
/webServices/warehouse/client/src/main/java/warehouseClient/WarehouseServiceCallbackHandler.java
119+
/webServices/warehouse/client/src/main/java/warehouseClient/WarehouseServiceStub.java

.travis.yml

-19
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,8 @@ cache:
1818

1919
# custom build step
2020
script:
21-
- currentDir=`pwd`
22-
# compile the sockets examples for Java and Linux
23-
- cd "$currentDir/sockets/java/src"
24-
- javac *.java
25-
- cd "$currentDir/sockets/c"
2621
- chmod 777 make_linux.sh
2722
- ./make_linux.sh
28-
# compile the Java Servlets
29-
- cd "$currentDir/javaServlets"
30-
- mvn clean compile war:war
31-
# compile the JavaServer Pages
32-
- cd "$currentDir/javaServerPages/examples"
33-
- mvn clean compile war:war
34-
- cd "$currentDir/javaServerPages/standAloneJSPsWithJetty"
35-
- mvn clean compile package
36-
# compile the Java RMI examples
37-
- cd "$currentDir/javaRMI/src"
38-
- javac *.java
39-
# compile the Java examples for XML processing
40-
- cd "$currentDir/xml/java/src"
41-
- javac *.java
4223

4324
before_install:
4425
# make sure GCC is installed

helloWorld/make_linux.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
echo "Building 'Hello World Example'."
10+
11+
rm -f helloWorld
12+
gcc helloWorld.c -o helloWorld
13+
14+
echo "Finished building 'Hello World Example'."

javaRMI/make_linux.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
echo "Building Java RMI examples."
10+
11+
rm -rf bin
12+
mkdir bin
13+
cd src
14+
rm -f *.class
15+
javac *.java
16+
mv *.class ../bin
17+
18+
echo "Finished building Java RMI examples."
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
echo "We now build the basic JavaServer Pages examples."
10+
11+
rm -rf target
12+
mvn clean compile war:war
13+
rm -rf target/generated-sources
14+
rm -rf target/maven-archiver
15+
rm -rf target/maven-status
16+
rm -rf target/myJSPs
17+
18+
echo "Successfully finished building the basic JavaServer Pages examples."

javaServerPages/make_linux.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
currentDir=`pwd`
10+
echo "We now build all the JavaServer Pages examples."
11+
12+
cd "$currentDir/examples"
13+
"$currentDir/examples/make_linux.sh"
14+
15+
cd "$currentDir/standAloneJSPsWithJetty"
16+
"$currentDir/standAloneJSPsWithJetty/make_linux.sh"
17+
18+
echo "Successfully finished building all the JavaServer Pages examples."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
currentDir=`pwd`
10+
echo "We now build the 'Stand-Alone JavaServer Pages with Jetty' example."
11+
12+
rm -rf target
13+
mvn clean compile package
14+
rm -rf target/generated-sources
15+
rm -rf target/maven-archiver
16+
rm -rf target/maven-status
17+
rm -rf target/standAloneJSPs.jar
18+
rm -rf target/standAloneJSPsWithJetty-0.0.8-full.jar
19+
20+
echo "Successfully finished building the 'Stand-Alone JavaServer Pages with Jetty' example."

javaServerPages/standAloneJSPsWithJetty/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<groupId>thomasWeise</groupId>
66
<artifactId>standAloneJSPsWithJetty</artifactId>
77
<version>0.0.8</version>
8+
<packaging>jar</packaging>
89
<name>Stand-Alone JSPs with Jetty</name>
910
<description>An example for creating a stand-alone jar file to serve Java Server Pages (JSPs) and Java Servlets with Jetty.</description>
1011

javaServlets/make_linux.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
echo "We now build the Java Servlets examples."
10+
11+
rm -rf target
12+
mvn clean compile war:war
13+
rm -rf target/generated-sources
14+
rm -rf target/maven-archiver
15+
rm -rf target/maven-status
16+
rm -rf target/myServlets
17+
18+
echo "Successfully finished building the Java Servlets examples."

make_linux.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
currentDir=`pwd`
10+
echo "We now build all the examples one by one in directory '$currentDir'."
11+
12+
cd "$currentDir/helloWorld"
13+
"$currentDir/helloWorld/make_linux.sh"
14+
15+
cd "$currentDir/sockets"
16+
"$currentDir/sockets/make_linux.sh"
17+
18+
cd "$currentDir/javaServlets"
19+
"$currentDir/javaServlets/make_linux.sh"
20+
21+
cd "$currentDir/javaServerPages"
22+
"$currentDir/javaServerPages/make_linux.sh"
23+
24+
cd "$currentDir/javaRMI"
25+
"$currentDir/javaRMI/make_linux.sh"
26+
27+
cd "$currentDir/xml"
28+
"$currentDir/xml/make_linux.sh"
29+
30+
cd "$currentDir/webServices"
31+
"$currentDir/webServices/make_linux.sh"
32+
33+
34+
echo "Successfully finished building the examples in directory'$currentDir'."

sockets/c/make_linux.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ set -o errtrace # trace ERR through 'time command' and other functions
66
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
77
set -o errexit # set -e : exit the script if any statement returns a non-true return value
88

9+
echo "Building socket examples in C for Linux."
10+
11+
rm -f TCPClient_linux
12+
rm -f TCPServer_linux
13+
rm -f UDPClient_linux
14+
rm -f UDPServer_linux
15+
916
gcc TCPClient_linux.c -o TCPClient_linux
1017
gcc TCPServer_linux.c -o TCPServer_linux
1118
gcc UDPClient_linux.c -o UDPClient_linux
12-
gcc UDPServer_linux.c -o UDPServer_linux
19+
gcc UDPServer_linux.c -o UDPServer_linux
20+
21+
echo "Finished building socket examples in C for Linux."

sockets/java/make_linux.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
echo "Building socket examples in Java."
10+
11+
rm -rf bin
12+
mkdir bin
13+
cd src
14+
rm -f *.class
15+
javac *.java
16+
mv *.class ../bin
17+
18+
echo "Finished building socket examples in Java."

sockets/make_linux.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
currentDir=`pwd`
10+
echo "We now build all the socket examples."
11+
12+
cd "$currentDir/c"
13+
"$currentDir/c/make_linux.sh"
14+
15+
cd "$currentDir/java"
16+
"$currentDir/java/make_linux.sh"
17+
18+
echo "Successfully finished building all the socket examples."

webServices/make_linux.sh

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# strict error handling
4+
set -o pipefail # trace ERR through pipes
5+
set -o errtrace # trace ERR through 'time command' and other functions
6+
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
7+
set -o errexit # set -e : exit the script if any statement returns a non-true return value
8+
9+
currentDir=`pwd`
10+
echo "We now build all the Web Service examples in directory '$currentDir'."
11+
12+
axisVersion="1.7.1"
13+
echo "For this purpose, we need to download, install, and run axis2 $axisVersion in a temporary directory."
14+
tempDir=$(mktemp -d)
15+
echo "Created temporary folder '$tempDir'."
16+
cd "$tempDir"
17+
18+
echo "Now downloading axis2 $axisVersion."
19+
wget -q http://www-eu.apache.org/dist/axis/axis2/java/core/$axisVersion/axis2-$axisVersion-bin.zip
20+
echo "Finished downloading axis2 $axisVersion, now unpacking it."
21+
unzip -q "axis2-$axisVersion-bin.zip"
22+
cd "$tempDir/axis2-$axisVersion/bin/"
23+
24+
echo "We need to detect JAVA_HOME for running axis2."
25+
JAVA_HOME=${JAVA_HOME:-}
26+
if [[ -z "$JAVA_HOME" ]]
27+
then
28+
JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
29+
echo "JAVA_HOME was not specified, we detect it as '$JAVA_HOME'."
30+
fi
31+
export JAVA_HOME="$JAVA_HOME"
32+
33+
echo "Now executing axis2 $axisVersion in the background."
34+
"$tempDir/axis2-$axisVersion/bin/axis2server.sh" &
35+
axisProcess="$!"
36+
echo "Axis2 $axisVersion is now running as background process $axisProcess."
37+
38+
export axisRepository="$tempDir/axis2-$axisVersion/repository/services"
39+
echo "The path to the axis2 $axisVersion service repository is '$axisRepository'."
40+
41+
echo "Now waiting for axis2 server to be up and running."
42+
set +o errexit
43+
while true; do
44+
sleep 5
45+
wget http://localhost:8080/axis2/services/
46+
if [ $? -eq 0 ]; then
47+
break
48+
fi
49+
done
50+
set -o errexit
51+
sleep 5
52+
echo "Axis2 server is up and running."
53+
54+
echo "We can now build the examples."
55+
56+
cd "$currentDir"
57+
cd "$currentDir/warehouse"
58+
"$currentDir/warehouse/make_linux.sh"
59+
60+
echo "Finished building the examples."
61+
62+
echo "Now killing axis2 $axisVersion process $axisProcess and sub-processes."
63+
# taken from http://stackoverflow.com/questions/392022
64+
# but modified to avoid hanging
65+
function killtree {
66+
echo "Now sending STOP to process '$1'."
67+
kill -STOP "$1" &
68+
sleep 5
69+
ps -e -o pid= -o ppid= | while read -r pid ppid
70+
do
71+
[[ $ppid = $1 ]] || continue
72+
killtree "$pid" || true # Skip over failures
73+
done
74+
echo "Now sending CONT to process '$1'."
75+
kill -CONT "$1" &
76+
sleep 5
77+
echo "Now sending TERM to process '$1'."
78+
kill -TERM "$1" || true
79+
}
80+
killtree "$axisProcess"
81+
82+
echo "Finished killing axis2 $axisVersion process $axisProcess."
83+
echo "Now deleting temporary axis installation from directory '$tempDir'."
84+
cd "$currentDir"
85+
rm -rf "$tempDir"
86+
87+
echo "Successfully finished building all the Web Service examples."

0 commit comments

Comments
 (0)