From 6e57953cdcd6d4da269b4bf5c9c9a96fa9ad07ca Mon Sep 17 00:00:00 2001 From: Dan K Date: Tue, 16 Jul 2019 07:13:48 -0400 Subject: [PATCH] WIP:feat(ch9s6): add initial code for GE The "mvn fabric8:deploy" command still does not work, mostly because it seems that the deployed "service" contains selectors for labels that are not present on the associated Pod. --- micro-java/pom.xml | 102 ++++++++++++++++++ .../openshift/hello/HelloResource.java | 27 +++++ .../openshift/hello/JaxRsActivator.java | 8 ++ 3 files changed, 137 insertions(+) create mode 100644 micro-java/pom.xml create mode 100644 micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java create mode 100644 micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java diff --git a/micro-java/pom.xml b/micro-java/pom.xml new file mode 100644 index 0000000..79154c6 --- /dev/null +++ b/micro-java/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + com.redhat.training.openshift + micro-java + 1.0 + war + Red Hat Training Hello Java app + Hello microservice using Thorntail + + + + + UTF-8 + false + + + 2.4.0.Final + + + 3.1 + 2.16 + 2.5 + + 4.1.0 + + + 1.8 + 1.8 + + + + + + + + io.thorntail + bom-all + ${version.thorntail} + import + pom + + + + + + + io.thorntail + cdi + + + io.thorntail + jaxrs + + + + + + + hello + + + + + io.thorntail + thorntail-maven-plugin + ${version.thorntail} + + + + package + + + + + + io.fabric8 + fabric8-maven-plugin + ${version.fabric8.plugin} + + + fmp + + resource + build + + + + + + + + diff --git a/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java b/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java new file mode 100644 index 0000000..3db3118 --- /dev/null +++ b/micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java @@ -0,0 +1,27 @@ +package com.redhat.training.openshift.hello; + +import javax.inject.Inject; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +@Path("/") +public class HelloResource { + + @GET + @Path("/hello") + @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+"]."; + response += "Message received = "+message+"\n"; + + return response; + } +} diff --git a/micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java b/micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java new file mode 100644 index 0000000..7a6a14a --- /dev/null +++ b/micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java @@ -0,0 +1,8 @@ +package com.redhat.training.openshift.hello; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/api") +public class JaxRsActivator extends Application { +}