diff --git a/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/GreetingResource.java b/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/GreetingResource.java index 4a60eb4b..87184c1c 100644 --- a/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/GreetingResource.java +++ b/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/GreetingResource.java @@ -55,14 +55,14 @@ public String helloProtagonistFriend() { @Path("/antagonist") @Produces(MediaType.TEXT_PLAIN) public String helloAntagonist() { - return antagonist.name + " says: " + antagonist.message; + return antagonist.name() + " says: " + antagonist.message(); } @GET @Path("/antagonist/wife") @Produces(MediaType.TEXT_PLAIN) public String helloAntagonistWife() { - return antagonist.wife.name + " says: " + antagonist.wife.message; + return antagonist.wife().name() + " says: " + antagonist.wife().message(); } @GET diff --git a/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/AntagonistConfiguration.java b/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/AntagonistConfiguration.java index 749a2fe9..58443c1b 100644 --- a/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/AntagonistConfiguration.java +++ b/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/AntagonistConfiguration.java @@ -1,15 +1,18 @@ package io.quarkus.qe.config; -import io.quarkus.arc.config.ConfigProperties; +import io.smallrye.config.ConfigMapping; -@ConfigProperties(prefix = "antagonist") -public class AntagonistConfiguration { - public String message; - public String name; - public AntagonistWifeConfig wife; +@ConfigMapping(prefix = "antagonist") +public interface AntagonistConfiguration { + String message(); - public static class AntagonistWifeConfig { - public String name; - public String message; + String name(); + + AntagonistWifeConfig wife(); + + interface AntagonistWifeConfig { + String name(); + + String message(); } } diff --git a/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/interfaces/ProtagonistConfigurable.java b/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/interfaces/ProtagonistConfigurable.java index e9eaba42..b531e696 100644 --- a/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/interfaces/ProtagonistConfigurable.java +++ b/022-quarkus-properties-config-all/src/main/java/io/quarkus/qe/config/interfaces/ProtagonistConfigurable.java @@ -2,9 +2,9 @@ import org.eclipse.microprofile.config.inject.ConfigProperty; -import io.quarkus.arc.config.ConfigProperties; +import io.smallrye.config.ConfigMapping; -@ConfigProperties(prefix = "protagonist") +@ConfigMapping(prefix = "protagonist") public interface ProtagonistConfigurable extends IBiography { @ConfigProperty(name = "name") diff --git a/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/config/VertxWebClientConfig.java b/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/config/VertxWebClientConfig.java index 5116953d..f51cb74e 100644 --- a/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/config/VertxWebClientConfig.java +++ b/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/config/VertxWebClientConfig.java @@ -1,15 +1,13 @@ package io.quarkus.qe.vertx.webclient.config; -import org.eclipse.microprofile.config.inject.ConfigProperty; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithName; -import io.quarkus.arc.config.ConfigProperties; +@ConfigMapping(prefix = "vertx.webclient") +public interface VertxWebClientConfig { -@ConfigProperties(prefix = "vertx.webclient") -public class VertxWebClientConfig { + @WithName("timeout-sec") + long timeout(); - @ConfigProperty(name = "timeoutSec") - public long timeout; - - @ConfigProperty(name = "retries") - public long retries; + long retries(); } diff --git a/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/handler/ChuckNorrisResource.java b/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/handler/ChuckNorrisResource.java index 3099561c..41b20198 100644 --- a/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/handler/ChuckNorrisResource.java +++ b/300-quarkus-vertx-webClient/src/main/java/io/quarkus/qe/vertx/webclient/handler/ChuckNorrisResource.java @@ -47,8 +47,8 @@ void initialize() { @Route(methods = HttpMethod.GET, path = "/") public Uni getRandomJoke() { return getChuckQuoteAsJoke() - .ifNoItem().after(Duration.ofSeconds(httpClientConf.timeout)).fail() - .onFailure().retry().atMost(httpClientConf.retries); + .ifNoItem().after(Duration.ofSeconds(httpClientConf.timeout())).fail() + .onFailure().retry().atMost(httpClientConf.retries()); } @Route(methods = HttpMethod.GET, path = "/bodyCodec", produces = "application/json") @@ -59,8 +59,8 @@ public Uni getRandomJokeWithBodyCodec() { .expect(ResponsePredicate.status(HttpURLConnection.HTTP_OK)) .send() .map(HttpResponse::body) - .ifNoItem().after(Duration.ofSeconds(httpClientConf.timeout)).fail() - .onFailure().retry().atMost(httpClientConf.retries); + .ifNoItem().after(Duration.ofSeconds(httpClientConf.timeout())).fail() + .onFailure().retry().atMost(httpClientConf.retries()); } @Route(methods = HttpMethod.GET, path = "/combine", produces = "application/json") diff --git a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/VerticleDeployer.java b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/VerticleDeployer.java index 5259cc46..ea6528c2 100644 --- a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/VerticleDeployer.java +++ b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/VerticleDeployer.java @@ -21,7 +21,7 @@ public class VerticleDeployer { StockPriceProducer producer; public void run(@Observes StartupEvent e, Vertx vertx, Instance verticles) { - vertx.setPeriodic(config.delay, c -> producer.generate().subscribe()); + vertx.setPeriodic(config.delay(), c -> producer.generate().subscribe()); // Deploy all abstract verticles example. for (AbstractVerticle verticle : verticles) { diff --git a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/config/VertxKProducerConfig.java b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/config/VertxKProducerConfig.java index 0d8d4b8c..ba9e53a2 100644 --- a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/config/VertxKProducerConfig.java +++ b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/config/VertxKProducerConfig.java @@ -1,16 +1,13 @@ package io.quarkus.qe.kafka.config; -import org.eclipse.microprofile.config.inject.ConfigProperty; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithName; -import io.quarkus.arc.config.ConfigProperties; +@ConfigMapping(prefix = "vertx.kafka.producer") +public interface VertxKProducerConfig { -@ConfigProperties(prefix = "vertx.kafka.producer") -public class VertxKProducerConfig { - - @ConfigProperty(name = "delayMs") - public long delay; - - @ConfigProperty(name = "batchSize") - public int batchSize; + @WithName("delay-ms") + long delay(); + int batchSize(); } diff --git a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java index 737af61f..c2f2dff2 100644 --- a/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java +++ b/301-quarkus-vertx-kafka/src/main/java/io/quarkus/qe/kafka/producers/StockPriceProducer.java @@ -33,7 +33,7 @@ public class StockPriceProducer { private Random random = new Random(); public Uni generate() { - IntStream.range(0, config.batchSize).forEach(next -> { + IntStream.range(0, config.batchSize()).forEach(next -> { StockPrice event = StockPrice.newBuilder().setId("IBM").setPrice(random.nextDouble()).setStatus(status.PENDING) .build(); LOG.infov("PRODUCER -> ID: {0}, PRICE: {1}", event.getId(), event.getPrice()); diff --git a/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/auth/AuthN.java b/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/auth/AuthN.java index 82c1ec07..e7a823a5 100644 --- a/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/auth/AuthN.java +++ b/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/auth/AuthN.java @@ -30,8 +30,8 @@ JWTAuth jwtAuth() { private PubSecKeyOptions getPubSecKeyOptions() { JsonObject authConfig = new JsonObject() .put("symmetric", true) - .put("algorithm", authNConf.alg) - .put("publicKey", authNConf.secret); + .put("algorithm", authNConf.alg()) + .put("publicKey", authNConf.secret()); return new PubSecKeyOptions(authConfig).setBuffer(authConfig.getBuffer("publicKey")); } @@ -39,11 +39,11 @@ private PubSecKeyOptions getPubSecKeyOptions() { private JWTOptions getJwtOptions() { return new JWTOptions() .setIgnoreExpiration(false) - .setIssuer(authNConf.claims.iss) - .setAudience(Arrays.asList((authNConf.claims.aud))) - .setSubject(authNConf.claims.sub) - .setExpiresInMinutes(authNConf.liveSpan) - .setAlgorithm(authNConf.alg); + .setIssuer(authNConf.claims().iss()) + .setAudience(Arrays.asList((authNConf.claims().aud()))) + .setSubject(authNConf.claims().sub()) + .setExpiresInMinutes(authNConf.liveSpan()) + .setAlgorithm(authNConf.alg()); } } diff --git a/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/AuthNConfig.java b/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/AuthNConfig.java index ee49a6a2..3ac7fe0f 100644 --- a/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/AuthNConfig.java +++ b/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/AuthNConfig.java @@ -1,18 +1,25 @@ package io.quarkus.qe.vertx.web.config; -import org.eclipse.microprofile.config.inject.ConfigProperty; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithName; -import io.quarkus.arc.config.ConfigProperties; +@ConfigMapping(prefix = "authN") +public interface AuthNConfig { + String alg(); -@ConfigProperties(prefix = "authN") -public class AuthNConfig { - public String alg; + String secret(); - public String secret; + @WithName("tokenLiveSpanMin") + int liveSpan(); - @ConfigProperty(name = "tokenLiveSpanMin") - public int liveSpan; + @WithName("jwt.claims") + JwtClaims claims(); - @ConfigProperty(name = "jwt.claims") - public JwtClaims claims; + interface JwtClaims { + String iss(); + + String sub(); + + String aud(); + } } diff --git a/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/JwtClaims.java b/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/JwtClaims.java deleted file mode 100644 index 2e5177e9..00000000 --- a/302-quarkus-vertx-jwt/src/main/java/io/quarkus/qe/vertx/web/config/JwtClaims.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.quarkus.qe.vertx.web.config; - -import io.quarkus.arc.config.ConfigProperties; - -@ConfigProperties(prefix = "authN.jwt.claims") -public class JwtClaims { - public String iss; - public String sub; - public String aud; -} diff --git a/302-quarkus-vertx-jwt/src/main/resources/application.properties b/302-quarkus-vertx-jwt/src/main/resources/application.properties index 3e334a7e..2f766dc8 100644 --- a/302-quarkus-vertx-jwt/src/main/resources/application.properties +++ b/302-quarkus-vertx-jwt/src/main/resources/application.properties @@ -4,7 +4,7 @@ app.name=Vertx-jwt authN.alg=HS256 authN.secret=keepSecret -authN.tokenLiveSpanMin=10 +authN.token-live-span-min=10 authN.jwt.claims.aud=third_party authN.jwt.claims.iss=vertxJWT@redhat.com authN.jwt.claims.sub=bff diff --git a/303-quarkus-vertx-sql/src/main/java/io/quarkus/qe/vertx/sql/Application.java b/303-quarkus-vertx-sql/src/main/java/io/quarkus/qe/vertx/sql/Application.java index 553bfd21..466e5c13 100644 --- a/303-quarkus-vertx-sql/src/main/java/io/quarkus/qe/vertx/sql/Application.java +++ b/303-quarkus-vertx-sql/src/main/java/io/quarkus/qe/vertx/sql/Application.java @@ -17,9 +17,9 @@ import io.quarkus.qe.vertx.sql.services.DbPoolService; import io.quarkus.runtime.StartupEvent; import io.quarkus.runtime.configuration.ProfileManager; +import io.vertx.core.impl.logging.Logger; +import io.vertx.core.impl.logging.LoggerFactory; import io.vertx.core.json.jackson.DatabindCodec; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; import io.vertx.mutiny.db2client.DB2Pool; import io.vertx.mutiny.mysqlclient.MySQLPool; import io.vertx.mutiny.pgclient.PgPool;