forked from RedHatTraining/DO288-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:RedHatTraining/DO288-apps
- Loading branch information
Showing
25 changed files
with
770 additions
and
14 deletions.
There are no files selected for viewing
28 changes: 14 additions & 14 deletions
28
...ost/src/main/java/com/redhat/training/example/javaserverhost/rest/ServerHostEndPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
package com.redhat.training.example.javaserverhost.rest; | ||
|
||
|
||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Produces; | ||
import java.net.InetAddress; | ||
|
||
|
||
@Path("/") | ||
public class ServerHostEndPoint { | ||
|
||
@GET | ||
@Produces("text/plain") | ||
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(); | ||
} | ||
@GET | ||
@Produces("text/plain") | ||
public Response doGet() { | ||
String host = ""; | ||
try { | ||
host = InetAddress.getLocalHost().getHostName(); | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
String msg = "I am running on server "+host+" Version 1.0 \n"; | ||
return Response.ok(msg).build(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.redhat.training.openshift</groupId> | ||
<artifactId>hello</artifactId> | ||
<version>1.0</version> | ||
<packaging>war</packaging> | ||
<name>Red Hat Training Hello Java app</name> | ||
<description>Hello microservice using Thorntail</description> | ||
|
||
<properties> | ||
<!-- Explicitly declaring the source encoding eliminates the following | ||
message: --> | ||
<!-- [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> | ||
|
||
<!-- Thorntail dependency versions --> | ||
<version.thorntail>2.4.0.Final</version.thorntail> | ||
|
||
<!-- other plugin versions --> | ||
<version.compiler.plugin>3.1</version.compiler.plugin> | ||
<version.surefire.plugin>2.16</version.surefire.plugin> | ||
<version.war.plugin>2.5</version.war.plugin> | ||
<version.fabric8.plugin>4.1.0</version.fabric8.plugin> | ||
|
||
<!-- maven-compiler-plugin --> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
</properties> | ||
|
||
|
||
<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>io.thorntail</groupId> | ||
<artifactId>cdi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>jaxrs</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<!-- Maven will append the version to the finalName (which is the name | ||
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> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>thorntail-maven-plugin</artifactId> | ||
<version>${version.thorntail}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>fabric8-maven-plugin</artifactId> | ||
<version>${version.fabric8.plugin}</version> | ||
<executions> | ||
<execution> | ||
<id>fmp</id> | ||
<goals> | ||
<goal>resource</goal> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Empty file.
27 changes: 27 additions & 0 deletions
27
micro-java/src/main/java/com/redhat/training/openshift/hello/HelloResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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+"].\n"; | ||
response += "Message received = "+message+"\n"; | ||
} | ||
return response; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
micro-java/src/main/java/com/redhat/training/openshift/hello/JaxRsActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.redhat.training.example</groupId> | ||
<artifactId>todo-api</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
<name>ToDo API Thorntail Example</name> | ||
<description>ToDo API microservice using Thorntail</description> | ||
|
||
<properties> | ||
<!-- Explicitly declaring the source encoding eliminates the following | ||
message: --> | ||
<!-- [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> | ||
|
||
<!-- Thorntail dependency versions --> | ||
<version.thorntail>2.4.0.Final</version.thorntail> | ||
|
||
<!-- MySQL JDBC Connector --> | ||
<version.mysql>8.0.16</version.mysql> | ||
|
||
<!-- other plugin versions --> | ||
<version.compiler.plugin>3.1</version.compiler.plugin> | ||
<version.surefire.plugin>2.16</version.surefire.plugin> | ||
<version.war.plugin>2.5</version.war.plugin> | ||
<version.fabric8.plugin>4.1.0</version.fabric8.plugin> | ||
|
||
<!-- maven-compiler-plugin --> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
</properties> | ||
|
||
|
||
<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>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<version>7.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>jaxrs-jsonp</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>ejb</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>datasources</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>cdi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>jaxrs</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>${version.mysql}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<!-- Maven will append the version to the finalName (which is the name | ||
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> | ||
<groupId>io.thorntail</groupId> | ||
<artifactId>thorntail-maven-plugin</artifactId> | ||
<version>${version.thorntail}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>fabric8-maven-plugin</artifactId> | ||
<version>${version.fabric8.plugin}</version> | ||
<executions> | ||
<execution> | ||
<id>fmp</id> | ||
<goals> | ||
<goal>resource</goal> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- | ||
resources: | ||
requests: | ||
cpu: "0.2" | ||
# memory: 256Mi | ||
limits: | ||
cpu: "1.0" | ||
# memory: 256Mi | ||
env: | ||
- name: DATABASE_USER | ||
value: '${database.user}' | ||
- name: DATABASE_PASSWORD | ||
value: '${database.password}' | ||
- name: DATABASE_SVC_HOSTNAME | ||
value: '${database.svc.hostname}' | ||
- name: DATABASE_NAME | ||
value: '${database.name}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Route | ||
metadata: | ||
labels: | ||
expose: "true" | ||
app: ${project.artifactId} | ||
provider: fabric8 | ||
version: "1.0" | ||
group: com.redhat.training | ||
name: ${project.artifactId} | ||
spec: | ||
host: ${hostname} | ||
port: | ||
targetPort: ${service-port} | ||
to: | ||
kind: Service | ||
name: ${project.artifactId} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
fabric8.io/iconUrl: img/icons/camel.svg | ||
labels: | ||
expose: "true" | ||
app: ${project.artifactId} | ||
provider: fabric8 | ||
version: "1.0" | ||
group: com.redhat.training | ||
name: ${project.artifactId} | ||
spec: | ||
ports: | ||
- name: http | ||
port: ${service-port} | ||
protocol: TCP | ||
targetPort: ${service-port} | ||
selector: | ||
deploymentconfig: ${project.artifactId} |
19 changes: 19 additions & 0 deletions
19
...-api-micro/src/main/java/com/redhat/training/example/todoapi/rest/HelloWorldEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.redhat.training.example.todoapi.rest; | ||
|
||
|
||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Produces; | ||
|
||
|
||
@Path("/hello") | ||
public class HelloWorldEndpoint { | ||
|
||
@GET | ||
@Produces("text/plain") | ||
public Response doGet() { | ||
return Response.ok("Hello World!").build(); | ||
|
||
} | ||
} |
Oops, something went wrong.