Skip to content

Commit be6db34

Browse files
committed
refactored hello-java app to use thorntail
1 parent de66472 commit be6db34

File tree

7 files changed

+44
-103
lines changed

7 files changed

+44
-103
lines changed

hello-java/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN yum install -y --disableplugin=subscription-manager java-1.8.0-openjdk-hea
1313
mkdir -p /opt/app-root/bin
1414

1515
# Copy the runnable fat JAR to the container.
16-
ADD https://github.com/RedHatTraining/DO288-apps/releases/download/1.0/hello-swarm.jar /opt/app-root/bin/
16+
ADD https://github.com/RedHatTraining/DO288-apps/releases/download/OCP-4.1-1/hello-java.jar /opt/app-root/bin/
1717

1818
COPY run-app.sh /opt/app-root/bin/
1919

hello-java/app-src/pom.xml

+33-52
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.redhat.training.openshift</groupId>
8-
<artifactId>hello-swarm</artifactId>
8+
<artifactId>hello-java</artifactId>
99
<version>1.0</version>
1010
<packaging>war</packaging>
11-
<name>Red Hat Training ToT app</name>
12-
<description>Hello microservice using WildFly Swarm</description>
11+
<name>Red Hat Training Hello Java app</name>
12+
<description>Hello microservice using Thorntail</description>
1313

1414
<properties>
1515
<!-- Explicitly declaring the source encoding eliminates the following
1616
message: -->
1717
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
1818
resources, i.e. build is platform dependent! -->
1919
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
<failOnMissingWebXml>false</failOnMissingWebXml>
2021

21-
<!-- JBoss dependency versions -->
22-
<version.wildfly.swarm>2017.10.0</version.wildfly.swarm>
22+
<!-- Thorntail dependency versions -->
23+
<version.thorntail>2.4.0.Final</version.thorntail>
2324

2425
<!-- other plugin versions -->
2526
<version.compiler.plugin>3.1</version.compiler.plugin>
@@ -34,33 +35,25 @@
3435

3536

3637
<dependencyManagement>
37-
<dependencies>
38-
<!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill
39-
of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection)
40-
of artifacts. We use this here so that we always get the correct versions
41-
of artifacts. -->
42-
<dependency>
43-
<groupId>org.wildfly.swarm</groupId>
44-
<artifactId>bom</artifactId>
45-
<version>${version.wildfly.swarm}</version>
46-
<type>pom</type>
47-
<scope>import</scope>
48-
</dependency>
49-
</dependencies>
50-
</dependencyManagement>
38+
<dependencies>
39+
<dependency>
40+
<groupId>io.thorntail</groupId>
41+
<artifactId>bom-all</artifactId>
42+
<version>${version.thorntail}</version>
43+
<scope>import</scope>
44+
<type>pom</type>
45+
</dependency>
46+
</dependencies>
47+
</dependencyManagement>
5148

5249
<dependencies>
5350
<dependency>
54-
<groupId>org.wildfly.swarm</groupId>
55-
<artifactId>jaxrs-jsonp</artifactId>
56-
</dependency>
57-
<dependency>
58-
<groupId>org.wildfly.swarm</groupId>
59-
<artifactId>jaxrs-cdi</artifactId>
51+
<groupId>io.thorntail</groupId>
52+
<artifactId>cdi</artifactId>
6053
</dependency>
6154
<dependency>
62-
<groupId>org.wildfly.swarm</groupId>
63-
<artifactId>cdi</artifactId>
55+
<groupId>io.thorntail</groupId>
56+
<artifactId>jaxrs</artifactId>
6457
</dependency>
6558

6659
</dependencies>
@@ -70,33 +63,21 @@
7063
given to the generated war, and hence the context root) -->
7164
<finalName>hello</finalName>
7265
<plugins>
66+
<!-- The Thorntail Maven plugin creates an uber jar -->
67+
<!-- To use, run: mvn thorntail:run -->
7368
<plugin>
74-
<artifactId>maven-war-plugin</artifactId>
75-
<version>${version.war.plugin}</version>
76-
<configuration>
77-
<!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
78-
<failOnMissingWebXml>false</failOnMissingWebXml>
79-
</configuration>
80-
</plugin>
81-
<!-- The WildFly Swarm plugin creates an uber jar -->
82-
<!-- To use, run: mvn wildfly-swarm:run -->
83-
<plugin>
84-
<groupId>org.wildfly.swarm</groupId>
85-
<artifactId>wildfly-swarm-plugin</artifactId>
86-
<version>${version.wildfly.swarm}</version>
87-
<configuration>
88-
<mainClass>com.redhat.training.openshift.hello.Main</mainClass>
89-
</configuration>
90-
<executions>
91-
<execution>
92-
<goals>
93-
<goal>package</goal>
94-
</goals>
95-
</execution>
96-
</executions>
97-
</plugin>
69+
<groupId>io.thorntail</groupId>
70+
<artifactId>thorntail-maven-plugin</artifactId>
71+
<version>${version.thorntail}</version>
72+
<executions>
73+
<execution>
74+
<goals>
75+
<goal>package</goal>
76+
</goals>
77+
</execution>
78+
</executions>
79+
</plugin>
9880
</plugins>
9981
</build>
10082

101-
10283
</project>

hello-java/app-src/src/main/java/com/redhat/training/openshift/hello/HelloResource.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ public class HelloResource {
1313
@Produces("text/plain")
1414
public String hello() {
1515
String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown");
16-
String message = System.getenv().getOrDefault("APP_MSG", null);
17-
String response = "";
18-
if (message == null)
19-
response = "Hello world from host "+hostname+"\n";
20-
else
21-
response = "Hello world from host ["+hostname+"]. Message received = "+message+"\n";
16+
String message = System.getenv().getOrDefault("APP_MSG", null);
17+
String response = "";
18+
19+
if (message == null)
20+
response = "Hello world from host "+hostname+"\n";
21+
else
22+
response = "Hello world from host ["+hostname+"]. Message received = "+message+"\n";
23+
2224
return response;
2325
}
2426
}

hello-java/app-src/src/main/java/com/redhat/training/openshift/hello/Main.java

-31
This file was deleted.

hello-java/app-src/src/main/resources/WEB-INF/beans.xml

-5
This file was deleted.

hello-java/app-src/src/main/resources/WEB-INF/web.xml

-6
This file was deleted.

hello-java/run-app.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

3-
echo "Starting wildfly swarm app..."
3+
echo "Starting hello-java app..."
44
echo "JVM options => $JAVA_OPTIONS"
55
echo
66

7-
java $JAVA_OPTIONS -jar /opt/app-root/bin/hello-swarm.jar
7+
java $JAVA_OPTIONS -jar /opt/app-root/bin/hello-java.jar

0 commit comments

Comments
 (0)