Ravi Srinivasan
2019-06-04 be6db34b379e564c74c11f77db4d80e4b844b7bd
refactored hello-java app to use thorntail
3 files deleted
4 files modified
149 ■■■■■ changed files
hello-java/Dockerfile 2 ●●● patch | view | raw | blame | history
hello-java/app-src/pom.xml 87 ●●●●● patch | view | raw | blame | history
hello-java/app-src/src/main/java/com/redhat/training/openshift/hello/HelloResource.java 14 ●●●●● patch | view | raw | blame | history
hello-java/app-src/src/main/java/com/redhat/training/openshift/hello/Main.java 31 ●●●●● patch | view | raw | blame | history
hello-java/app-src/src/main/resources/WEB-INF/beans.xml 5 ●●●●● patch | view | raw | blame | history
hello-java/app-src/src/main/resources/WEB-INF/web.xml 6 ●●●●● patch | view | raw | blame | history
hello-java/run-app.sh 4 ●●●● patch | view | raw | blame | history
hello-java/Dockerfile
@@ -13,7 +13,7 @@
      mkdir -p /opt/app-root/bin
# Copy the runnable fat JAR to the container.
ADD   https://github.com/RedHatTraining/DO288-apps/releases/download/1.0/hello-swarm.jar /opt/app-root/bin/
ADD   https://github.com/RedHatTraining/DO288-apps/releases/download/OCP-4.1-1/hello-java.jar /opt/app-root/bin/
COPY  run-app.sh /opt/app-root/bin/
hello-java/app-src/pom.xml
@@ -5,11 +5,11 @@
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.redhat.training.openshift</groupId>
    <artifactId>hello-swarm</artifactId>
    <artifactId>hello-java</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <name>Red Hat Training ToT app</name>
    <description>Hello microservice using WildFly Swarm</description>
    <name>Red Hat Training Hello Java app</name>
    <description>Hello microservice using Thorntail</description>
    <properties>
        <!-- Explicitly declaring the source encoding eliminates the following
@@ -17,9 +17,10 @@
        <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
            resources, i.e. build is platform dependent! -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <!-- JBoss dependency versions -->
        <version.wildfly.swarm>2017.10.0</version.wildfly.swarm>
        <!-- Thorntail dependency versions -->
        <version.thorntail>2.4.0.Final</version.thorntail>
        <!-- other plugin versions -->
        <version.compiler.plugin>3.1</version.compiler.plugin>
@@ -34,33 +35,25 @@
    <dependencyManagement>
        <dependencies>
            <!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill
                of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection)
                of artifacts. We use this here so that we always get the correct versions
                of artifacts. -->
            <dependency>
                <groupId>org.wildfly.swarm</groupId>
                <artifactId>bom</artifactId>
                <version>${version.wildfly.swarm}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.thorntail</groupId>
        <artifactId>bom-all</artifactId>
        <version>${version.thorntail}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.wildfly.swarm</groupId>
            <artifactId>jaxrs-jsonp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wildfly.swarm</groupId>
            <artifactId>jaxrs-cdi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wildfly.swarm</groupId>
            <groupId>io.thorntail</groupId>
            <artifactId>cdi</artifactId>
        </dependency>
        <dependency>
            <groupId>io.thorntail</groupId>
            <artifactId>jaxrs</artifactId>
        </dependency>
    </dependencies>
@@ -70,33 +63,21 @@
            given to the generated war, and hence the context root) -->
        <finalName>hello</finalName>
        <plugins>
            <!-- The Thorntail Maven plugin creates an uber jar -->
            <!-- To use, run: mvn thorntail:run -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>${version.war.plugin}</version>
                <configuration>
                    <!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <!-- The WildFly Swarm plugin creates an uber jar -->
            <!-- To use, run: mvn wildfly-swarm:run -->
            <plugin>
                <groupId>org.wildfly.swarm</groupId>
                <artifactId>wildfly-swarm-plugin</artifactId>
                <version>${version.wildfly.swarm}</version>
                <configuration>
                    <mainClass>com.redhat.training.openshift.hello.Main</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>package</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        <groupId>io.thorntail</groupId>
        <artifactId>thorntail-maven-plugin</artifactId>
        <version>${version.thorntail}</version>
        <executions>
          <execution>
            <goals>
              <goal>package</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
        </plugins>
    </build>
</project>
hello-java/app-src/src/main/java/com/redhat/training/openshift/hello/HelloResource.java
@@ -13,12 +13,14 @@
    @Produces("text/plain")
    public String hello() {
        String hostname = System.getenv().getOrDefault("HOSTNAME", "unknown");
    String message = System.getenv().getOrDefault("APP_MSG", null);
    String response = "";
    if (message == null)
      response = "Hello world from host "+hostname+"\n";
    else
      response = "Hello world from host ["+hostname+"]. Message received = "+message+"\n";
          String message = System.getenv().getOrDefault("APP_MSG", null);
          String response = "";
          if (message == null)
            response = "Hello world from host "+hostname+"\n";
          else
            response = "Hello world from host ["+hostname+"]. Message received = "+message+"\n";
        return response;
    }
}
hello-java/app-src/src/main/java/com/redhat/training/openshift/hello/Main.java
File was deleted
hello-java/app-src/src/main/resources/WEB-INF/beans.xml
File was deleted
hello-java/app-src/src/main/resources/WEB-INF/web.xml
File was deleted
hello-java/run-app.sh
@@ -1,7 +1,7 @@
#!/bin/sh
echo "Starting wildfly swarm app..."
echo "Starting hello-java app..."
echo "JVM options => $JAVA_OPTIONS"
echo
java $JAVA_OPTIONS -jar /opt/app-root/bin/hello-swarm.jar
java $JAVA_OPTIONS -jar /opt/app-root/bin/hello-java.jar