Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
.idea/
.vscode/*
**/.project
**/.classpath
**/.classpath
2 changes: 2 additions & 0 deletions Chapter04/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ hs_err_pid*
.classpath
.project
.settings/*
*.iml
.idea/*
540 changes: 540 additions & 0 deletions Chapter04/README.liberty.md

Large diffs are not rendered by default.

559 changes: 559 additions & 0 deletions Chapter04/README.payara.md

Large diffs are not rendered by default.

517 changes: 517 additions & 0 deletions Chapter04/README.quarkus.md

Large diffs are not rendered by default.

504 changes: 504 additions & 0 deletions Chapter04/README.wildfly.md

Large diffs are not rendered by default.

File renamed without changes.
75 changes: 75 additions & 0 deletions Chapter04/pom.xml.payara
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.packt.microprofile</groupId>
<artifactId>ch4</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>11</maven.compiler.source>
<!--
NOTE: Version 6.2021.1.Alpha1 used on LATEST got rid of most probllems. One remains that @RestClient CDI injection does not work.
NOTE: Version 5.2021.1 till 5.2021.8 had even more trouble to do anything with the code so it is no option.
NOTE: It seems possible that the misleading documentation about @RestClient annoation to identify the Resource to be injected need to be looked into.
NOTE: Other micoprofile runtimes like liberty, wildfly and quarkus are working fine with the unchanged code base.

<payaraVersion>5.2021.1</payaraVersion>
-->
<payaraVersion>LATEST</payaraVersion>
<final.name>ch4</final.name>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>4.0.1</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-auth-jwt</artifactId>
<version>3.9.5</version>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>ch4</finalName>
</build>
<profiles>
<profile>
<id>payara-micro</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>fish.payara.maven.plugins</groupId>
<artifactId>payara-micro-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<payaraVersion>${payaraVersion}</payaraVersion>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
149 changes: 149 additions & 0 deletions Chapter04/pom.xml.quarkus
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.packt.microprofile</groupId>
<artifactId>ch4</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>2.3.1.Final</quarkus.platform.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jaxb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-multipart</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<parameters>${maven.compiler.parameters}</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>
100 changes: 100 additions & 0 deletions Chapter04/pom.xml.wildfly
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.packt.microprofile</groupId>
<artifactId>ch4</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<version.wildfly>25.0.0.Final</version.wildfly>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>11</maven.compiler.source>
<final.name>ch4</final.name>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>4.0.1</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-auth-jwt</artifactId>
<version>3.9.5</version>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
<version>1.0.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>ch4</finalName>
</build>
<profiles>
<profile>
<id>wildfly</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<version>6.0.0.Final</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
<configuration>
<feature-pack-location>wildfly@maven(org.jboss.universe:community-universe)#${version.wildfly}</feature-pack-location>
<context-root>false</context-root>
<layers>
<layer>jaxrs</layer>
<layer>microprofile-platform</layer>
<layer>microprofile-config</layer>
<layer>microprofile-fault-tolerance</layer>
<layer>microprofile-health</layer>
<layer>microprofile-jwt</layer>
<layer>microprofile-metrics</layer>
<layer>microprofile-openapi</layer>
<layer>open-tracing</layer>
<layer>microprofile-rest-client</layer>
<layer>microprofile-reactive-messaging</layer>
</layers>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
<version>1.0.1.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jboss-public-repository</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>Red Hat GA</id>
<name>Red Hat GA</name>
<url>https://maven.repository.redhat.com/ga/</url>
</repository>
</repositories>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public AsyncPersonService() {
}

@GET
@Path("sync/{id}")
@Path("/sync/{id}")
public Person getPersonFromDBSync(@PathParam("id") int id) throws InterruptedException, ExecutionException {
Future<Person> someData = executor.submit(() -> getPerson(id));
return someData.get();
}

@GET
@Path("async/{id}")
@Path("/async/{id}")
public void getPersonFromDBAsync(@PathParam("id") int id, @Suspended AsyncResponse ar) {
executor.submit(() -> {
Optional<Person> p = Optional.ofNullable(getPerson(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
import org.reactivestreams.Subscription;

@Path("/test")
@Produces("text/plain")
public class MPSseConsumerResource {

private final static URI BASE_URI = URI.create("http://localhost:9080/ch4/rest");

@GET
@Path("/sse")
@Produces("text/plain")
public CompletionStage<String> getCombinedSseString() {
CompletableFuture<String> stage = new CompletableFuture<>();
StringBuilder sb = new StringBuilder();
SseClient client = RestClientBuilder.newBuilder()
.baseUri(URI.create("http://localhost:9080/ch4/rest"))
.baseUri(BASE_URI)
.build(SseClient.class);
client.receiveSSEs().subscribe(new Subscriber<String>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import org.reactivestreams.Publisher;

@Path("/sse")
@Produces(MediaType.SERVER_SENT_EVENTS)
public interface SseClient {

@GET
@Produces(MediaType.SERVER_SENT_EVENTS)
Publisher<String> receiveSSEs();
}
Loading