Skip to content

Commit d0ceb69

Browse files
committed
Initial Version
1 parent 6f1c59f commit d0ceb69

File tree

12 files changed

+699
-0
lines changed

12 files changed

+699
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/maven.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Java Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set up JDK 11
12+
uses: actions/setup-java@v1
13+
with:
14+
java-version: 11
15+
- name: Cache Maven packages
16+
uses: actions/cache@v1
17+
with:
18+
path: ~/.m2
19+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
20+
restore-keys: ${{ runner.os }}-m2
21+
- name: Test with Maven
22+
run: mvn clean package -Dquarkus.container-image.build=true -DskipTests=true -Dquarkus.container-image.group=viplab -Dquarkus.container-image.name=dummy-backend -Dquarkus.container-image.tag=latest -Dquarkus.container-image.push=true -Dquarkus.container-image.username=${{ secrets.DOCKER_USERNAME }} -Dquarkus.container-image.password=${{ secrets.DOCKER_PASSWORD }}

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#Maven
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
release.properties
7+
8+
# Eclipse
9+
.project
10+
.classpath
11+
.settings/
12+
bin/
13+
14+
# IntelliJ
15+
.idea
16+
*.ipr
17+
*.iml
18+
*.iws
19+
20+
# NetBeans
21+
nb-configuration.xml
22+
23+
# Visual Studio Code
24+
.vscode
25+
.factorypath
26+
27+
# OSX
28+
.DS_Store
29+
30+
# Vim
31+
*.swp
32+
*.swo
33+
34+
# patch
35+
*.orig
36+
*.rej
37+
38+
# Local environment
39+
.env

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# code-with-quarkus project
2+
3+
This project uses Quarkus, the Supersonic Subatomic Java Framework.
4+
5+
If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
6+
7+
## Running the application in dev mode
8+
9+
You can run your application in dev mode that enables live coding using:
10+
```shell script
11+
./mvnw compile quarkus:dev
12+
```
13+
14+
## Packaging and running the application
15+
16+
The application can be packaged using:
17+
```shell script
18+
./mvnw package
19+
```
20+
It produces the `code-with-quarkus-1.0.0-SNAPSHOT-runner.jar` file in the `/target` directory.
21+
Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory.
22+
23+
If you want to build an _über-jar_, execute the following command:
24+
```shell script
25+
./mvnw package -Dquarkus.package.type=uber-jar
26+
```
27+
28+
The application is now runnable using `java -jar target/code-with-quarkus-1.0.0-SNAPSHOT-runner.jar`.
29+
30+
## Creating a native executable
31+
32+
You can create a native executable using:
33+
```shell script
34+
./mvnw package -Pnative
35+
```
36+
37+
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
38+
```shell script
39+
./mvnw package -Pnative -Dquarkus.native.container-build=true
40+
```
41+
42+
You can then execute your native executable with: `./target/code-with-quarkus-1.0.0-SNAPSHOT-runner`
43+
44+
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.
45+
46+
# RESTEasy JAX-RS
47+
48+
<p>A Hello World RESTEasy resource</p>
49+
50+
Guide: https://quarkus.io/guides/rest-json

pom.xml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>de.uni-stuttgart.tik.viplab</groupId>
6+
<artifactId>dummy-backend</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<properties>
9+
<compiler-plugin.version>3.8.1</compiler-plugin.version>
10+
<maven.compiler.parameters>true</maven.compiler.parameters>
11+
<maven.compiler.source>11</maven.compiler.source>
12+
<maven.compiler.target>11</maven.compiler.target>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15+
<quarkus-plugin.version>1.11.3.Final</quarkus-plugin.version>
16+
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
17+
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
18+
<quarkus.platform.version>1.11.3.Final</quarkus.platform.version>
19+
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
20+
</properties>
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>${quarkus.platform.group-id}</groupId>
25+
<artifactId>${quarkus.platform.artifact-id}</artifactId>
26+
<version>${quarkus.platform.version}</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>io.quarkus</groupId>
35+
<artifactId>quarkus-jsonp</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>io.quarkus</groupId>
39+
<artifactId>quarkus-jsonp</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.quarkus</groupId>
43+
<artifactId>quarkus-undertow</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.quarkus</groupId>
47+
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.quarkus</groupId>
51+
<artifactId>quarkus-amazon-s3</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>io.quarkus</groupId>
55+
<artifactId>quarkus-arc</artifactId>
56+
</dependency>
57+
<dependency>
58+
<groupId>io.quarkus</groupId>
59+
<artifactId>quarkus-resteasy</artifactId>
60+
</dependency>
61+
<dependency>
62+
<groupId>io.quarkus</groupId>
63+
<artifactId>quarkus-junit5</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>io.rest-assured</groupId>
68+
<artifactId>rest-assured</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.quarkus</groupId>
73+
<artifactId>quarkus-container-image-jib</artifactId>
74+
</dependency>
75+
</dependencies>
76+
<build>
77+
<plugins>
78+
<plugin>
79+
<groupId>io.quarkus</groupId>
80+
<artifactId>quarkus-maven-plugin</artifactId>
81+
<version>${quarkus-plugin.version}</version>
82+
<extensions>true</extensions>
83+
<executions>
84+
<execution>
85+
<goals>
86+
<goal>build</goal>
87+
<goal>generate-code</goal>
88+
<goal>generate-code-tests</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
<plugin>
94+
<artifactId>maven-compiler-plugin</artifactId>
95+
<version>${compiler-plugin.version}</version>
96+
</plugin>
97+
<plugin>
98+
<artifactId>maven-surefire-plugin</artifactId>
99+
<version>${surefire-plugin.version}</version>
100+
<configuration>
101+
<systemPropertyVariables>
102+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
103+
<maven.home>${maven.home}</maven.home>
104+
</systemPropertyVariables>
105+
</configuration>
106+
</plugin>
107+
</plugins>
108+
</build>
109+
<profiles>
110+
<profile>
111+
<id>native</id>
112+
<activation>
113+
<property>
114+
<name>native</name>
115+
</property>
116+
</activation>
117+
<build>
118+
<plugins>
119+
<plugin>
120+
<artifactId>maven-failsafe-plugin</artifactId>
121+
<version>${surefire-plugin.version}</version>
122+
<executions>
123+
<execution>
124+
<goals>
125+
<goal>integration-test</goal>
126+
<goal>verify</goal>
127+
</goals>
128+
<configuration>
129+
<systemPropertyVariables>
130+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
131+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
132+
<maven.home>${maven.home}</maven.home>
133+
</systemPropertyVariables>
134+
</configuration>
135+
</execution>
136+
</executions>
137+
</plugin>
138+
</plugins>
139+
</build>
140+
<properties>
141+
<quarkus.package.type>native</quarkus.package.type>
142+
</properties>
143+
</profile>
144+
</profiles>
145+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package de.uni_stuttgart.tik.viplab.dummybackend;
2+
3+
import javax.ws.rs.GET;
4+
import javax.ws.rs.Path;
5+
import javax.ws.rs.Produces;
6+
import javax.ws.rs.core.MediaType;
7+
8+
@Path("/hello-resteasy")
9+
public class GreetingResource {
10+
11+
@GET
12+
@Produces(MediaType.TEXT_PLAIN)
13+
public String hello() {
14+
return "Hello RESTEasy";
15+
}
16+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package de.uni_stuttgart.tik.viplab.dummybackend;
2+
3+
import java.io.InputStream;
4+
import java.io.StringReader;
5+
import java.util.Optional;
6+
7+
import javax.enterprise.context.ApplicationScoped;
8+
import javax.inject.Inject;
9+
import javax.json.Json;
10+
import javax.json.JsonObject;
11+
import javax.json.JsonReader;
12+
13+
import org.eclipse.microprofile.config.inject.ConfigProperty;
14+
import org.eclipse.microprofile.reactive.messaging.Incoming;
15+
import org.eclipse.microprofile.reactive.messaging.Outgoing;
16+
import org.jboss.logging.Logger;
17+
18+
@ApplicationScoped
19+
public class MessageResponder {
20+
21+
@Inject
22+
Logger logger;
23+
24+
@Inject
25+
@ConfigProperty(name = "viplab.responses")
26+
private Optional<String> responseDirectory;
27+
28+
@Incoming("computations")
29+
@Outgoing("results")
30+
public String processCompuation(String message) {
31+
32+
JsonReader jsonReader = Json.createReader(new StringReader(message));
33+
JsonObject computation = jsonReader.readObject();
34+
String computationID = computation.getString("identifier");
35+
logger.info(computation);
36+
logger.info(computationID);
37+
38+
InputStream is = null;
39+
if (responseDirectory.isEmpty()) {
40+
is = getClass().getClassLoader()
41+
.getResourceAsStream("results/example1.json");
42+
} else {
43+
//TODO: setup resources
44+
}
45+
jsonReader = Json.createReader(is);
46+
JsonObject result = jsonReader.readObject();
47+
result = Json.createPatchBuilder()
48+
.replace("/computation",
49+
Json.createValue(computationID))
50+
.build()
51+
.apply(result);
52+
logger.info(result);
53+
return result.toString();
54+
}
55+
}

0 commit comments

Comments
 (0)