From f4252631a328386157d4c2e0be1c65a3771f42ac Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Mon, 20 Apr 2020 17:56:42 +1000 Subject: [PATCH] Change dynodb to use config injection --- .../dynamodb/deployment/DynamodbProcessor.java | 9 --------- .../dynamodb/runtime/DynamodbClientProducer.java | 15 +++++---------- .../dynamodb/runtime/DynamodbRecorder.java | 13 ------------- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java b/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java index caaf3702b1555..7c320cc493ccc 100644 --- a/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java +++ b/extensions/amazon-dynamodb/deployment/src/main/java/io/quarkus/dynamodb/deployment/DynamodbProcessor.java @@ -12,7 +12,6 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.BeanContainerBuildItem; -import io.quarkus.arc.deployment.BeanContainerListenerBuildItem; import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; import io.quarkus.arc.processor.BuildExtension; import io.quarkus.arc.processor.InjectionPointInfo; @@ -145,20 +144,12 @@ DynamodbClientBuildItem analyzeDynamodbClientInjectionPoints(BeanRegistrationPha return new DynamodbClientBuildItem(createSyncClient, createAsyncClient); } - @BuildStep - @Record(ExecutionTime.STATIC_INIT) - void initializeConfiguration(BuildProducer containerListenerProducer, - DynamodbRecorder recorder) { - containerListenerProducer.produce(new BeanContainerListenerBuildItem(recorder.setDynamodbBuildConfig(buildTimeConfig))); - } - @BuildStep @Record(ExecutionTime.RUNTIME_INIT) void buildClients(DynamodbClientBuildItem clientBuildItem, DynamodbConfig runtimeConfig, DynamodbRecorder recorder, BeanContainerBuildItem beanContainer, ShutdownContextBuildItem shutdown) { if (clientBuildItem.isCreateSyncClient() || clientBuildItem.isCreateAsyncClient()) { - recorder.configureRuntimeConfig(runtimeConfig); if (clientBuildItem.isCreateSyncClient()) { recorder.createClient(beanContainer.getValue(), shutdown); diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java index 4964e1b652ce5..f01ff2a475347 100644 --- a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java +++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbClientProducer.java @@ -8,6 +8,7 @@ import javax.annotation.PreDestroy; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; +import javax.inject.Inject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,18 +36,12 @@ public class DynamodbClientProducer { private static final Log LOG = LogFactory.getLog(DynamodbClientProducer.class); - private DynamodbConfig runtimeConfig; + @Inject + DynamodbConfig runtimeConfig; private DynamoDbClient client; private DynamoDbAsyncClient asyncClient; - private DynamodbBuildTimeConfig buildTimeConfig; - - public void setBuildTimeConfig(DynamodbBuildTimeConfig buildTimeConfig) { - this.buildTimeConfig = buildTimeConfig; - } - - public void setRuntimeConfig(DynamodbConfig runtimeConfig) { - this.runtimeConfig = runtimeConfig; - } + @Inject + DynamodbBuildTimeConfig buildTimeConfig; @Produces @ApplicationScoped diff --git a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbRecorder.java b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbRecorder.java index c8aff09076412..029a8f1fc877e 100644 --- a/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbRecorder.java +++ b/extensions/amazon-dynamodb/runtime/src/main/java/io/quarkus/dynamodb/runtime/DynamodbRecorder.java @@ -1,8 +1,6 @@ package io.quarkus.dynamodb.runtime; -import io.quarkus.arc.Arc; import io.quarkus.arc.runtime.BeanContainer; -import io.quarkus.arc.runtime.BeanContainerListener; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; @@ -12,17 +10,6 @@ @Recorder public class DynamodbRecorder { - public BeanContainerListener setDynamodbBuildConfig(DynamodbBuildTimeConfig buildConfig) { - return beanContainer -> { - DynamodbClientProducer producer = beanContainer.instance(DynamodbClientProducer.class); - producer.setBuildTimeConfig(buildConfig); - }; - } - - public void configureRuntimeConfig(DynamodbConfig dynamodbConfig) { - Arc.container().instance(DynamodbClientProducer.class).get().setRuntimeConfig(dynamodbConfig); - } - public RuntimeValue createClient( BeanContainer beanContainer, ShutdownContext shutdown) {