-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create two demos modules and remove resteasy-reactive-client dependen…
…cy from runtime module
- Loading branch information
Showing
11 changed files
with
200 additions
and
27 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
*/ | ||
package org.acme.configurationProvider.it; | ||
|
||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
|
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,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project 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" | ||
xmlns="http://maven.apache.org/POM/4.0.0"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.acme</groupId> | ||
<artifactId>configuration-provider-parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>configuration-provider-picocli-tests</artifactId> | ||
<name>Configuration Provider - Picocli sample application</name> | ||
<properties> | ||
<skipITs>true</skipITs> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-picocli</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.acme</groupId> | ||
<artifactId>configuration-provider</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<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> | ||
<profiles> | ||
<profile> | ||
<id>native-image</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>${native.surefire.skip}</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<properties> | ||
<skipITs>false</skipITs> | ||
<quarkus.package.type>native</quarkus.package.type> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
picocli-tests/src/main/java/org/acme/configurationProvider/it/Starter.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,21 @@ | ||
package org.acme.configurationProvider.it; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command | ||
public class Starter implements Runnable{ | ||
|
||
|
||
@ConfigProperty(name = "env.snowcamp.title") | ||
String snowcampConfTitle; | ||
@ConfigProperty(name = "env.snowcamp.author") | ||
String snowcampConfAuthor; | ||
|
||
@Override | ||
public void run() { | ||
System.out.println("******** WELCOME ! ********"); | ||
System.out.println("Welcome %s, that will present: \"%s\"%n".formatted(snowcampConfAuthor, snowcampConfTitle)); | ||
System.out.println("*********************************"); | ||
} | ||
} |
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,33 @@ | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
acme.devservices.enabled=false |
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
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
42 changes: 37 additions & 5 deletions
42
runtime/src/main/java/org/acme/configurationProvider/runtime/EnvironmentProviderClient.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,23 +1,55 @@ | ||
package org.acme.configurationProvider.runtime; | ||
|
||
import jakarta.ws.rs.client.Client; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import jakarta.ws.rs.core.UriBuilder; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.http.HttpClient; | ||
import java.net.http.HttpRequest; | ||
import java.net.http.HttpResponse; | ||
import java.util.Map; | ||
import java.util.concurrent.CompletionException; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
class EnvironmentProviderClient { | ||
|
||
private final Client restClient; | ||
private final HttpClient restClient; | ||
private final UriBuilder uriBuilder; | ||
private final UncheckedObjectMapper objectMapper; | ||
|
||
EnvironmentProviderClient(URI baseUrl) { | ||
restClient = ClientBuilder.newClient(); | ||
restClient = HttpClient.newBuilder().build(); | ||
uriBuilder = UriBuilder.fromUri(baseUrl).path("/conferences/{prefix}"); | ||
objectMapper = new UncheckedObjectMapper(); | ||
} | ||
|
||
public Map<String, String> getEnvironment(String prefix) { | ||
return restClient.target(uriBuilder.build(prefix)).request().get(Map.class); | ||
HttpRequest request = HttpRequest.newBuilder() | ||
.GET() | ||
.uri(uriBuilder.build(prefix)) | ||
.build(); | ||
try { | ||
return restClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()) | ||
.thenApply(HttpResponse::body) | ||
.thenApply(objectMapper::readValue) | ||
.get(); | ||
} catch (InterruptedException | ExecutionException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
static class UncheckedObjectMapper extends com.fasterxml.jackson.databind.ObjectMapper { | ||
/** | ||
* Parses the given JSON string into a Map. | ||
*/ | ||
Map<String, String> readValue(String content) { | ||
try { | ||
return this.readValue(content, new TypeReference<>() { | ||
}); | ||
} catch (IOException ioe) { | ||
throw new CompletionException(ioe); | ||
} | ||
} | ||
} | ||
} |