Changed app name to hello-java and deleted junk files
This commit is contained in:
102
hello-java/app-src/pom.xml
Normal file
102
hello-java/app-src/pom.xml
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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-swarm</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>war</packaging>
|
||||
<name>Red Hat Training ToT app</name>
|
||||
<description>Hello microservice using WildFly Swarm</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>
|
||||
|
||||
<!-- JBoss dependency versions -->
|
||||
<version.wildfly.swarm>2017.10.0</version.wildfly.swarm>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
<!-- maven-compiler-plugin -->
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
</properties>
|
||||
|
||||
|
||||
<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>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>
|
||||
<artifactId>cdi</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>
|
||||
<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>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,24 @@
|
||||
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+"]. Message received = "+message+"\n";
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.redhat.training.openshift.hello;
|
||||
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
|
||||
import org.wildfly.swarm.Swarm;
|
||||
import org.wildfly.swarm.undertow.WARArchive;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// Instantiate the container
|
||||
Swarm swarm = new Swarm(args);
|
||||
|
||||
// Create one or more deployments
|
||||
WARArchive deployment = ShrinkWrap.create(WARArchive.class);
|
||||
|
||||
// Add resource to deployment
|
||||
deployment.addPackage(Main.class.getPackage());
|
||||
deployment.addAllDependencies();
|
||||
|
||||
// Add Web resources
|
||||
deployment.addAsWebInfResource(
|
||||
new ClassLoaderAsset("WEB-INF/web.xml", Main.class.getClassLoader()), "web.xml");
|
||||
deployment.addAsWebInfResource(
|
||||
new ClassLoaderAsset("WEB-INF/beans.xml", Main.class.getClassLoader()), "beans.xml");
|
||||
|
||||
swarm.start().deploy(deployment);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
5
hello-java/app-src/src/main/resources/WEB-INF/beans.xml
Normal file
5
hello-java/app-src/src/main/resources/WEB-INF/beans.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all">
|
||||
</beans>
|
||||
6
hello-java/app-src/src/main/resources/WEB-INF/web.xml
Normal file
6
hello-java/app-src/src/main/resources/WEB-INF/web.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
|
||||
|
||||
</web-app>
|
||||
Reference in New Issue
Block a user