From ce90e852f6b259a23f18e715a2ef02952716bdf4 Mon Sep 17 00:00:00 2001 From: Ivan Chavero Date: Wed, 19 Jun 2019 00:42:25 -0500 Subject: [PATCH] ch04s04 Update java application for thorntail --- java-serverhost/pom.xml | 20 +++++++++---------- .../javaserverhost/rest/RestApplication.java | 9 +++++++++ .../rest}/ServerHostEndPoint.java | 12 ++++++++--- 3 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/RestApplication.java rename java-serverhost/src/main/java/com/redhat/training/example/{ => javaserverhost/rest}/ServerHostEndPoint.java (56%) diff --git a/java-serverhost/pom.xml b/java-serverhost/pom.xml index 0403048..bdb9d34 100644 --- a/java-serverhost/pom.xml +++ b/java-serverhost/pom.xml @@ -1,13 +1,15 @@ - + + 4.0.0 com.redhat.training.example java-serverhost - Java Server Host Application - 1.0 + Thorntail Example + 1.0.0-SNAPSHOT war - 2.1.0.Final + 2.4.0.Final 1.8 1.8 false @@ -19,7 +21,7 @@ io.thorntail bom-all - ${version.wildfly.swarm} + ${version.thorntail} import pom @@ -27,12 +29,12 @@ - java-serverhost + demo io.thorntail thorntail-maven-plugin - ${version.wildfly.swarm} + ${version.thorntail} @@ -46,14 +48,12 @@ - javax javaee-api 7.0 provided - - \ No newline at end of file + diff --git a/java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/RestApplication.java b/java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/RestApplication.java new file mode 100644 index 0000000..416d4a6 --- /dev/null +++ b/java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/RestApplication.java @@ -0,0 +1,9 @@ +package com.redhat.training.example.javaserverhost.rest; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/") +public class RestApplication extends Application { + +} diff --git a/java-serverhost/src/main/java/com/redhat/training/example/ServerHostEndPoint.java b/java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/ServerHostEndPoint.java similarity index 56% rename from java-serverhost/src/main/java/com/redhat/training/example/ServerHostEndPoint.java rename to java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/ServerHostEndPoint.java index e09ee8b..a5ff9c1 100644 --- a/java-serverhost/src/main/java/com/redhat/training/example/ServerHostEndPoint.java +++ b/java-serverhost/src/main/java/com/redhat/training/example/javaserverhost/rest/ServerHostEndPoint.java @@ -1,4 +1,4 @@ -package com.redhat.training.example.swarmhelloworld.rest; +package com.redhat.training.example.javaserverhost.rest; import javax.ws.rs.Path; @@ -13,8 +13,14 @@ public class ServerHostEndPoint { @GET @Produces("text/plain") - public Response doGet() throws Exception { - String host = InetAddress.getLocalHost().getHostName(); + public Response doGet() { + String host = ""; + try { + host = InetAddress.getLocalHost().getHostName(); + } + catch (Exception e) { + e.printStackTrace(); + } return Response.ok("I am running on server "+host+" Version 1.0 \n").build(); } }