From 332103781b838f0266c800bd715f5e1449b15c72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crocquesel?= <88554524+scrocquesel@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:42:25 +0100 Subject: [PATCH] feat: remove coupling with optional client implementation --- .quarkus/cli/plugins/quarkus-cli-catalog.json | 5 + .../amazon/acm/deployment/AcmProcessor.java | 177 +----- .../acm/runtime/AcmBuildTimeConfig.java | 15 +- .../ApiGatewayManagementApiProcessor.java | 180 +----- ...piGatewayManagementApiBuildTimeConfig.java | 15 +- bom/pom.xml | 5 + .../deployment/CloudWatchProcessor.java | 158 +----- .../runtime/CloudWatchBuildTimeConfig.java | 15 +- .../deployment/CloudWatchLogsProcessor.java | 161 +----- .../CloudWatchLogsBuildTimeConfig.java | 15 +- .../deployment/CognitoUserPoolsProcessor.java | 180 +----- .../CognitoUserPoolsBuildTimeConfig.java | 15 +- .../deployment-apache-client-internal/pom.xml | 4 + .../ApacheTransportBuilderProcessor.java | 63 +++ common/deployment-crt-client-internal/pom.xml | 4 + .../crt/AwsCrtTransportBuilderProcessor.java | 111 ++++ .../netty}/EventLoopGroupBuildItem.java | 2 +- .../netty/EventLoopGroupProcessor.java | 4 +- .../netty/NettyTransportBuilderProcessor.java | 69 +++ common/deployment-spi/pom.xml | 12 +- .../AmazonClientAsyncTransportBuildItem.java | 0 .../AmazonClientBuilderBuildItem.java | 36 ++ .../AmazonClientBuilderOverrideBuildItem.java | 23 + .../AmazonClientExtensionBuildItem.java | 144 +++++ .../AmazonClientSyncTransportBuildItem.java | 0 ...AmazonClientTransportBuilderBuildItem.java | 0 common/deployment/pom.xml | 1 - .../AbstractAmazonServiceProcessor.java | 511 +----------------- .../AmazonClientExtensionsProcessor.java | 466 ++++++++++++++++ .../common/deployment/AmazonHttpClients.java | 30 +- .../AmazonServicesClientsProcessor.java | 10 +- ...rlConnectionTransportBuilderProcessor.java | 60 ++ common/pom.xml | 1 + common/runtime-apache-client-internal/pom.xml | 15 + .../AmazonClientApacheTransportRecorder.java | 0 common/runtime-crt-client-internal/pom.xml | 9 + .../AmazonClientAwsCrtTransportRecorder.java | 0 common/runtime-netty-client-internal/pom.xml | 9 + .../AmazonClientNettyTransportRecorder.java | 41 +- common/runtime-spi/pom.xml | 37 ++ ...AbstractAmazonClientTransportRecorder.java | 0 .../common/runtime/AmazonClientConfig.java | 0 .../common/runtime/AmazonClientRecorder.java | 39 ++ .../AsyncHttpClientBuildTimeConfig.java | 0 .../common/runtime/AsyncHttpClientConfig.java | 26 +- .../amazon/common/runtime/AwsConfig.java | 0 .../runtime/AwsCredentialsProviderConfig.java | 0 .../runtime/AwsCredentialsProviderType.java | 0 .../amazon/common/runtime/ClientUtil.java | 0 .../common/runtime/CrtHttpClientConfig.java | 0 .../FileStoreTlsManagersProviderConfig.java | 0 .../FileStoreTlsTrustManagersProvider.java | 0 .../runtime/HasAmazonClientRuntimeConfig.java | 0 .../common/runtime/HasSdkBuildTimeConfig.java | 0 .../runtime/HasTransportBuildTimeConfig.java | 13 + .../runtime/NoneTlsTrustManagersProvider.java | 0 .../runtime/RuntimeConfigurationError.java | 0 .../common/runtime/SdkBuildTimeConfig.java | 0 .../amazon/common/runtime/SdkConfig.java | 0 .../SyncHttpClientBuildTimeConfig.java | 0 .../common/runtime/SyncHttpClientConfig.java | 0 .../runtime/TlsKeyManagersProviderConfig.java | 0 .../runtime/TlsKeyManagersProviderType.java | 0 .../TlsTrustManagersProviderConfig.java | 0 .../runtime/TlsTrustManagersProviderType.java | 0 common/runtime/pom.xml | 21 +- ....java => AmazonClientBuilderRecorder.java} | 51 +- .../AmazonClientOpenTelemetryRecorder.java | 33 +- .../common/runtime/CrtSubstitutions.java | 1 - .../deployment/DynamodbEnhancedProcessor.java | 3 +- dynamodb/deployment/pom.xml | 14 + .../deployment/DynamodbProcessor.java | 185 +------ .../runtime/DynamodbBuildTimeConfig.java | 15 +- .../amazon/ecr/deployment/EcrProcessor.java | 177 +----- .../ecr/runtime/EcrBuildTimeConfig.java | 15 +- .../ElasticLoadBalancingProcessor.java | 180 +----- .../ElasticLoadBalancingBuildTimeConfig.java | 15 +- .../ElasticLoadBalancingV2Processor.java | 180 +----- ...ElasticLoadBalancingV2BuildTimeConfig.java | 15 +- .../deployment/EventBridgeProcessor.java | 180 +----- .../runtime/EventBridgeBuildTimeConfig.java | 15 +- .../amazon/iam/deployment/IamProcessor.java | 177 +----- .../iam/runtime/IamBuildTimeConfig.java | 15 +- .../deployment/InspectorProcessor.java | 176 +----- .../runtime/InspectorBuildTimeConfig.java | 15 +- .../deployment/Inspector2Processor.java | 177 +----- .../runtime/Inspector2BuildTimeConfig.java | 15 +- .../src/main/resources/application.properties | 1 + .../kinesis/deployment/KinesisProcessor.java | 176 +----- .../runtime/KinesisBuildTimeConfig.java | 15 +- .../amazon/kms/deployment/KmsProcessor.java | 177 +----- .../kms/runtime/KmsBuildTimeConfig.java | 15 +- .../lambda/deployment/LambdaProcessor.java | 195 +------ .../lambda/runtime/LambdaBuildTimeConfig.java | 15 +- .../neptune/deployment/NeptuneProcessor.java | 176 +----- .../runtime/NeptuneBuildTimeConfig.java | 15 +- .../PaymentCryptographyProcessor.java | 180 +----- .../PaymentCryptographyBuildTimeConfig.java | 15 +- .../PaymentCryptographyDataProcessor.java | 180 +----- ...aymentCryptographyDataBuildTimeConfig.java | 15 +- .../amazon/s3/deployment/S3CrtProcessor.java | 8 +- .../amazon/s3/deployment/S3Processor.java | 183 +------ .../S3AsyncClientFullConfigTest.java | 45 ++ .../async-netty-full-config.properties | 16 + .../amazon/s3/runtime/S3BuildTimeConfig.java | 15 +- .../deployment/SecretsManagerProcessor.java | 180 +----- .../SecretsManagerBuildTimeConfig.java | 15 +- .../amazon/ses/deployment/SesProcessor.java | 178 +----- .../ses/runtime/SesBuildTimeConfig.java | 15 +- .../amazon/sfn/deployment/SfnProcessor.java | 178 +----- .../sfn/runtime/SfnBuildTimeConfig.java | 15 +- .../amazon/sns/deployment/SnsProcessor.java | 177 +----- .../sns/runtime/SnsBuildTimeConfig.java | 15 +- sqs/deployment/pom.xml | 4 + .../sqs/deployment/SqsOtelProcessor.java | 72 +++ .../amazon/sqs/deployment/SqsProcessor.java | 177 +----- .../sqs/runtime/SqsBuildTimeConfig.java | 15 +- .../sqs/runtime/SqsOpenTelemetryRecorder.java | 50 +- .../amazon/ssm/deployment/SsmProcessor.java | 177 +----- .../ssm/runtime/SsmBuildTimeConfig.java | 15 +- .../amazon/sts/deployment/StsProcessor.java | 177 +----- .../sts/runtime/StsBuildTimeConfig.java | 18 +- 122 files changed, 2083 insertions(+), 5193 deletions(-) create mode 100644 .quarkus/cli/plugins/quarkus-cli-catalog.json create mode 100644 common/deployment-apache-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/apache/ApacheTransportBuilderProcessor.java create mode 100644 common/deployment-crt-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/crt/AwsCrtTransportBuilderProcessor.java rename common/{deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/spi => deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty}/EventLoopGroupBuildItem.java (92%) create mode 100644 common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/NettyTransportBuilderProcessor.java rename common/{deployment => deployment-spi}/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientAsyncTransportBuildItem.java (100%) create mode 100644 common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderBuildItem.java create mode 100644 common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderOverrideBuildItem.java create mode 100644 common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionBuildItem.java rename common/{deployment => deployment-spi}/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientSyncTransportBuildItem.java (100%) rename common/{deployment => deployment-spi}/src/main/java/io/quarkiverse/amazon/common/deployment/RequireAmazonClientTransportBuilderBuildItem.java (100%) create mode 100644 common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionsProcessor.java create mode 100644 common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/UrlConnectionTransportBuilderProcessor.java rename common/{runtime => runtime-apache-client-internal}/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientApacheTransportRecorder.java (100%) rename common/{runtime => runtime-crt-client-internal}/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientAwsCrtTransportRecorder.java (100%) rename common/{runtime => runtime-netty-client-internal}/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java (85%) create mode 100644 common/runtime-spi/pom.xml rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AbstractAmazonClientTransportRecorder.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientConfig.java (100%) create mode 100644 common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientBuildTimeConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java (92%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AwsConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderType.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/ClientUtil.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/CrtHttpClientConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsManagersProviderConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsTrustManagersProvider.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/HasAmazonClientRuntimeConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/HasSdkBuildTimeConfig.java (100%) create mode 100644 common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasTransportBuildTimeConfig.java rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/NoneTlsTrustManagersProvider.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/RuntimeConfigurationError.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/SdkBuildTimeConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/SdkConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientBuildTimeConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderType.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderConfig.java (100%) rename common/{runtime => runtime-spi}/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderType.java (100%) rename common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/{AmazonClientRecorder.java => AmazonClientBuilderRecorder.java} (60%) create mode 100644 s3/deployment/src/test/java/io/quarkiverse/amazon/s3/deployment/S3AsyncClientFullConfigTest.java create mode 100644 s3/deployment/src/test/resources/async-netty-full-config.properties create mode 100644 sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsOtelProcessor.java diff --git a/.quarkus/cli/plugins/quarkus-cli-catalog.json b/.quarkus/cli/plugins/quarkus-cli-catalog.json new file mode 100644 index 000000000..d3a92cc24 --- /dev/null +++ b/.quarkus/cli/plugins/quarkus-cli-catalog.json @@ -0,0 +1,5 @@ +{ + "version" : "v1", + "lastUpdate" : "30/11/2024 15:41:58", + "plugins" : { } +} \ No newline at end of file diff --git a/acm/deployment/src/main/java/io/quarkiverse/amazon/acm/deployment/AcmProcessor.java b/acm/deployment/src/main/java/io/quarkiverse/amazon/acm/deployment/AcmProcessor.java index 9b450030d..4fd632458 100644 --- a/acm/deployment/src/main/java/io/quarkiverse/amazon/acm/deployment/AcmProcessor.java +++ b/acm/deployment/src/main/java/io/quarkiverse/amazon/acm/deployment/AcmProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.acm.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.acm.runtime.AcmBuildTimeConfig; import io.quarkiverse.amazon.acm.runtime.AcmRecorder; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.acm.AcmAsyncClient; import software.amazon.awssdk.services.acm.AcmAsyncClientBuilder; import software.amazon.awssdk.services.acm.AcmClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(AcmAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return AcmClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/acm/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(AcmAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return AcmAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/acm/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, AcmRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, AcmRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, AcmRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, AcmRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, AcmRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + AcmRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(AcmRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - AcmClientBuilder.class, - AcmAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/acm/runtime/src/main/java/io/quarkiverse/amazon/acm/runtime/AcmBuildTimeConfig.java b/acm/runtime/src/main/java/io/quarkiverse/amazon/acm/runtime/AcmBuildTimeConfig.java index 5201b3494..b66edf3c3 100644 --- a/acm/runtime/src/main/java/io/quarkiverse/amazon/acm/runtime/AcmBuildTimeConfig.java +++ b/acm/runtime/src/main/java/io/quarkiverse/amazon/acm/runtime/AcmBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.acm.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.acm") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface AcmBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon ACM client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon ACM client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface AcmBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/apigatewaymanagementapi/deployment/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/deployment/ApiGatewayManagementApiProcessor.java b/apigatewaymanagementapi/deployment/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/deployment/ApiGatewayManagementApiProcessor.java index e07794d19..b34a71037 100644 --- a/apigatewaymanagementapi/deployment/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/deployment/ApiGatewayManagementApiProcessor.java +++ b/apigatewaymanagementapi/deployment/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/deployment/ApiGatewayManagementApiProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.apigatewaymanagementapi.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.apigatewaymanagementapi.runtime.ApiGatewayManagementApiBuildTimeConfig; import io.quarkiverse.amazon.apigatewaymanagementapi.runtime.ApiGatewayManagementApiRecorder; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.apigatewaymanagementapi.ApiGatewayManagementApiAsyncClient; import software.amazon.awssdk.services.apigatewaymanagementapi.ApiGatewayManagementApiAsyncClientBuilder; import software.amazon.awssdk.services.apigatewaymanagementapi.ApiGatewayManagementApiClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(ApiGatewayManagementApiAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return ApiGatewayManagementApiClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/apigatewaymanagementapi/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(ApiGatewayManagementApiAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return ApiGatewayManagementApiAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/apigatewaymanagementapi/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - ApiGatewayManagementApiRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - ApiGatewayManagementApiRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - ApiGatewayManagementApiRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - ApiGatewayManagementApiRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( ApiGatewayManagementApiRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(ApiGatewayManagementApiRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - ApiGatewayManagementApiClientBuilder.class, - ApiGatewayManagementApiAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/apigatewaymanagementapi/runtime/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/runtime/ApiGatewayManagementApiBuildTimeConfig.java b/apigatewaymanagementapi/runtime/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/runtime/ApiGatewayManagementApiBuildTimeConfig.java index 48fe3ed97..36e3c468a 100644 --- a/apigatewaymanagementapi/runtime/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/runtime/ApiGatewayManagementApiBuildTimeConfig.java +++ b/apigatewaymanagementapi/runtime/src/main/java/io/quarkiverse/amazon/apigatewaymanagementapi/runtime/ApiGatewayManagementApiBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.apigatewaymanagementapi.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.apigatewaymanagementapi") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface ApiGatewayManagementApiBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Api Gateway Management Api client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Api Gateway Management Api client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface ApiGatewayManagementApiBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/bom/pom.xml b/bom/pom.xml index b8e9bbb61..14b54c3ff 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -42,6 +42,11 @@ quarkus-amazon-common ${project.version} + + io.quarkiverse.amazonservices + quarkus-amazon-common-runtime-spi + ${project.version} + io.quarkiverse.amazonservices quarkus-amazon-common-deployment-devservices-spi diff --git a/cloudwatch/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchProcessor.java b/cloudwatch/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchProcessor.java index 3d23c7e9e..1756f157f 100644 --- a/cloudwatch/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchProcessor.java +++ b/cloudwatch/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchProcessor.java @@ -1,24 +1,15 @@ package io.quarkiverse.amazon.cloudwatch.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.cloudwatch.runtime.CloudWatchBuildTimeConfig; import io.quarkiverse.amazon.cloudwatch.runtime.CloudWatchRecorder; import io.quarkiverse.amazon.common.deployment.*; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; import io.quarkiverse.amazon.common.runtime.*; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient; import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClientBuilder; import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; @@ -46,152 +37,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(CloudWatchAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return CloudWatchClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/cloudwatch/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(CloudWatchAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return CloudWatchAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/cloudwatch/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, CloudWatchRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, CloudWatchRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - CloudWatchRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, CloudWatchRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( CloudWatchRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(CloudWatchRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - CloudWatchClientBuilder.class, - CloudWatchAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/cloudwatch/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchBuildTimeConfig.java b/cloudwatch/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchBuildTimeConfig.java index e94bd94bb..3c26daeb8 100644 --- a/cloudwatch/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchBuildTimeConfig.java +++ b/cloudwatch/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.cloudwatch.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.cloudwatch") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface CloudWatchBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon CloudWatch client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon CloudWatch client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface CloudWatchBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/cloudwatchlogs/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchLogsProcessor.java b/cloudwatchlogs/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchLogsProcessor.java index 1e17bd925..156c1f4fc 100644 --- a/cloudwatchlogs/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchLogsProcessor.java +++ b/cloudwatchlogs/deployment/src/main/java/io/quarkiverse/amazon/cloudwatch/deployment/CloudWatchLogsProcessor.java @@ -1,24 +1,15 @@ package io.quarkiverse.amazon.cloudwatch.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.cloudwatch.runtime.CloudWatchLogsBuildTimeConfig; import io.quarkiverse.amazon.cloudwatch.runtime.CloudWatchLogsRecorder; import io.quarkiverse.amazon.common.deployment.*; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; import io.quarkiverse.amazon.common.runtime.*; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClient; import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClientBuilder; import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; @@ -46,155 +37,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(CloudWatchLogsAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return CloudWatchLogsClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/cloudwatchlogs/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(CloudWatchLogsAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return CloudWatchLogsAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/cloudwatchlogs/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - CloudWatchLogsRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - CloudWatchLogsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - CloudWatchLogsRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - CloudWatchLogsRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( CloudWatchLogsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(CloudWatchLogsRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - CloudWatchLogsClientBuilder.class, - CloudWatchLogsAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/cloudwatchlogs/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchLogsBuildTimeConfig.java b/cloudwatchlogs/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchLogsBuildTimeConfig.java index 05f981638..9cb4e7e75 100644 --- a/cloudwatchlogs/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchLogsBuildTimeConfig.java +++ b/cloudwatchlogs/runtime/src/main/java/io/quarkiverse/amazon/cloudwatch/runtime/CloudWatchLogsBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.cloudwatch.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.cloudwatchlogs") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface CloudWatchLogsBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon CloudWatch client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon CloudWatch client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface CloudWatchLogsBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/cognito-user-pools/deployment/src/main/java/io/quarkiverse/amazon/cognitouserpools/deployment/CognitoUserPoolsProcessor.java b/cognito-user-pools/deployment/src/main/java/io/quarkiverse/amazon/cognitouserpools/deployment/CognitoUserPoolsProcessor.java index f3fdc62ea..a59a2c846 100644 --- a/cognito-user-pools/deployment/src/main/java/io/quarkiverse/amazon/cognitouserpools/deployment/CognitoUserPoolsProcessor.java +++ b/cognito-user-pools/deployment/src/main/java/io/quarkiverse/amazon/cognitouserpools/deployment/CognitoUserPoolsProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.cognitouserpools.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.cognitouserpools.runtime.CognitoUserPoolsBuildTimeConfig; import io.quarkiverse.amazon.cognitouserpools.runtime.CognitoUserPoolsRecorder; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.cognitoidentityprovider.CognitoIdentityProviderAsyncClient; import software.amazon.awssdk.services.cognitoidentityprovider.CognitoIdentityProviderAsyncClientBuilder; import software.amazon.awssdk.services.cognitoidentityprovider.CognitoIdentityProviderClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(CognitoIdentityProviderAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return CognitoIdentityProviderClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/cognitoidentityprovider/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(CognitoIdentityProviderAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return CognitoIdentityProviderAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/cognitoidentityprovider/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - CognitoUserPoolsRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - CognitoUserPoolsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - CognitoUserPoolsRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - CognitoUserPoolsRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( CognitoUserPoolsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(CognitoUserPoolsRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - CognitoIdentityProviderClientBuilder.class, - CognitoIdentityProviderAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/cognito-user-pools/runtime/src/main/java/io/quarkiverse/amazon/cognitouserpools/runtime/CognitoUserPoolsBuildTimeConfig.java b/cognito-user-pools/runtime/src/main/java/io/quarkiverse/amazon/cognitouserpools/runtime/CognitoUserPoolsBuildTimeConfig.java index c2ac038ee..bd86a8d35 100644 --- a/cognito-user-pools/runtime/src/main/java/io/quarkiverse/amazon/cognitouserpools/runtime/CognitoUserPoolsBuildTimeConfig.java +++ b/cognito-user-pools/runtime/src/main/java/io/quarkiverse/amazon/cognitouserpools/runtime/CognitoUserPoolsBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.cognitouserpools.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.cognito-user-pools") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface CognitoUserPoolsBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Cognito Identity Provider client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Cognito Identity Provider client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface CognitoUserPoolsBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/common/deployment-apache-client-internal/pom.xml b/common/deployment-apache-client-internal/pom.xml index a24b1e4b1..9fefea22a 100644 --- a/common/deployment-apache-client-internal/pom.xml +++ b/common/deployment-apache-client-internal/pom.xml @@ -21,6 +21,10 @@ io.quarkiverse.amazonservices quarkus-amazon-apache-client-internal + + io.quarkiverse.amazonservices + quarkus-amazon-common-deployment-spi + io.quarkus quarkus-apache-httpclient-deployment diff --git a/common/deployment-apache-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/apache/ApacheTransportBuilderProcessor.java b/common/deployment-apache-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/apache/ApacheTransportBuilderProcessor.java new file mode 100644 index 000000000..f9b8885fb --- /dev/null +++ b/common/deployment-apache-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/apache/ApacheTransportBuilderProcessor.java @@ -0,0 +1,63 @@ +package io.quarkiverse.amazon.common.deployment.apache; + +import java.util.List; +import java.util.Optional; + +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; +import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; +import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientConfig; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.runtime.RuntimeValue; + +public class ApacheTransportBuilderProcessor { + + @BuildStep() + @Record(ExecutionTime.RUNTIME_INIT) + void setupApacheSyncTransport( + List extensions, + List amazonClients, + AmazonClientApacheTransportRecorder transportRecorder, + BuildProducer syncTransports) { + + extensions.forEach(extension -> createApacheSyncTransportBuilder( + extension.getConfigName(), + amazonClients, + transportRecorder, + extension.getBuildSyncConfig(), + extension.getSyncConfig(), + syncTransports)); + } + + void createApacheSyncTransportBuilder(String configName, + List amazonClients, + AmazonClientApacheTransportRecorder recorder, + SyncHttpClientBuildTimeConfig buildSyncConfig, + RuntimeValue syncConfig, + BuildProducer clientSyncTransports) { + + Optional matchingClientBuildItem = amazonClients.stream() + .filter(c -> c.getAwsClientName().equals(configName)) + .findAny(); + + matchingClientBuildItem.ifPresent(client -> { + if (!client.getSyncClassName().isPresent()) { + return; + } + if (buildSyncConfig.type() != SyncHttpClientBuildTimeConfig.SyncClientType.APACHE) { + return; + } + + clientSyncTransports.produce( + new AmazonClientSyncTransportBuildItem( + client.getAwsClientName(), + client.getSyncClassName().get(), + recorder.configureSync(configName, syncConfig))); + }); + } +} \ No newline at end of file diff --git a/common/deployment-crt-client-internal/pom.xml b/common/deployment-crt-client-internal/pom.xml index edb7eb164..326ddbee8 100644 --- a/common/deployment-crt-client-internal/pom.xml +++ b/common/deployment-crt-client-internal/pom.xml @@ -21,6 +21,10 @@ io.quarkiverse.amazonservices quarkus-amazon-crt-client-internal + + io.quarkiverse.amazonservices + quarkus-amazon-common-deployment-spi + io.quarkiverse.amazonservices quarkus-amazon-crt-deployment diff --git a/common/deployment-crt-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/crt/AwsCrtTransportBuilderProcessor.java b/common/deployment-crt-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/crt/AwsCrtTransportBuilderProcessor.java new file mode 100644 index 000000000..dc3da610b --- /dev/null +++ b/common/deployment-crt-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/crt/AwsCrtTransportBuilderProcessor.java @@ -0,0 +1,111 @@ +package io.quarkiverse.amazon.common.deployment.crt; + +import java.util.List; +import java.util.Optional; + +import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; +import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; +import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; +import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.AsyncHttpClientConfig; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientConfig; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.runtime.RuntimeValue; + +public class AwsCrtTransportBuilderProcessor { + + @BuildStep() + @Record(ExecutionTime.RUNTIME_INIT) + void setupAwsCrtSyncTransport( + List extensions, + List amazonClients, + AmazonClientAwsCrtTransportRecorder transportRecorder, + BuildProducer syncTransports) { + + extensions.forEach(extension -> createAwsCrtSyncTransportBuilder( + extension.getConfigName(), + amazonClients, + transportRecorder, + extension.getBuildSyncConfig(), + extension.getSyncConfig(), + syncTransports)); + } + + @BuildStep() + @Record(ExecutionTime.RUNTIME_INIT) + void setupAwsCrtAsyncTransport( + List extensions, + List amazonClients, + AmazonClientAwsCrtTransportRecorder transportRecorder, + BuildProducer asyncTransports) { + + extensions.forEach(extension -> createAwsCrtAsyncTransportBuilder( + extension.getConfigName(), + amazonClients, + transportRecorder, + extension.getBuildAsyncConfig(), + extension.getAsyncConfig(), + asyncTransports)); + } + + void createAwsCrtSyncTransportBuilder(String configName, + List amazonClients, + AmazonClientAwsCrtTransportRecorder recorder, + SyncHttpClientBuildTimeConfig buildSyncConfig, + RuntimeValue syncConfig, + BuildProducer clientSyncTransports) { + + Optional matchingClientBuildItem = amazonClients.stream() + .filter(c -> c.getAwsClientName().equals(configName)) + .findAny(); + + matchingClientBuildItem.ifPresent(client -> { + if (!client.getSyncClassName().isPresent()) { + return; + } + if (buildSyncConfig.type() != SyncHttpClientBuildTimeConfig.SyncClientType.AWS_CRT) { + return; + } + + clientSyncTransports.produce( + new AmazonClientSyncTransportBuildItem( + client.getAwsClientName(), + client.getSyncClassName().get(), + recorder.configureSync(configName, syncConfig))); + }); + } + + void createAwsCrtAsyncTransportBuilder( + String configName, + List amazonClients, + AmazonClientAwsCrtTransportRecorder recorder, + AsyncHttpClientBuildTimeConfig buildAsyncConfig, + RuntimeValue asyncConfig, + BuildProducer clientAsyncTransports) { + + Optional matchingClientBuildItem = amazonClients.stream() + .filter(c -> c.getAwsClientName().equals(configName)) + .findAny(); + + matchingClientBuildItem.ifPresent(client -> { + if (!client.getAsyncClassName().isPresent()) { + return; + } + if (buildAsyncConfig.type() != AsyncHttpClientBuildTimeConfig.AsyncClientType.AWS_CRT) { + return; + } + + clientAsyncTransports.produce( + new AmazonClientAsyncTransportBuildItem( + client.getAwsClientName(), + client.getAsyncClassName().get(), + recorder.configureAsync(configName, asyncConfig))); + }); + } +} diff --git a/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/spi/EventLoopGroupBuildItem.java b/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupBuildItem.java similarity index 92% rename from common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/spi/EventLoopGroupBuildItem.java rename to common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupBuildItem.java index 6eaf1a562..236f0dd3e 100644 --- a/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/spi/EventLoopGroupBuildItem.java +++ b/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupBuildItem.java @@ -1,4 +1,4 @@ -package io.quarkiverse.amazon.common.deployment.spi; +package io.quarkiverse.amazon.common.deployment.netty; import java.util.function.Supplier; diff --git a/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupProcessor.java b/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupProcessor.java index c420e3dfb..bbe46a6bc 100644 --- a/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupProcessor.java +++ b/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/EventLoopGroupProcessor.java @@ -6,8 +6,8 @@ public class EventLoopGroupProcessor { @BuildStep - io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem convert(EventLoopGroupBuildItem nettyEventLoopGroup) { - return new io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem( + io.quarkiverse.amazon.common.deployment.netty.EventLoopGroupBuildItem convert(EventLoopGroupBuildItem nettyEventLoopGroup) { + return new io.quarkiverse.amazon.common.deployment.netty.EventLoopGroupBuildItem( nettyEventLoopGroup.getBossEventLoopGroup(), nettyEventLoopGroup.getMainEventLoopGroup()); } diff --git a/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/NettyTransportBuilderProcessor.java b/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/NettyTransportBuilderProcessor.java new file mode 100644 index 000000000..c0d340a5e --- /dev/null +++ b/common/deployment-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/deployment/netty/NettyTransportBuilderProcessor.java @@ -0,0 +1,69 @@ +package io.quarkiverse.amazon.common.deployment.netty; + +import java.util.List; +import java.util.Optional; +import java.util.function.Supplier; + +import io.netty.channel.EventLoopGroup; +import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; +import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; +import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.AsyncHttpClientConfig; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.runtime.RuntimeValue; + +public class NettyTransportBuilderProcessor { + + @BuildStep() + @Record(ExecutionTime.RUNTIME_INIT) + void setupNettyAsyncTransport( + List extensions, + List amazonClients, + AmazonClientNettyTransportRecorder transportRecorder, + BuildProducer asyncTransports, + EventLoopGroupBuildItem eventLoopSupplier) { + + extensions.forEach(extension -> createNettyAsyncTransportBuilder( + extension.getConfigName(), + amazonClients, + transportRecorder, + extension.getBuildAsyncConfig(), + extension.getAsyncConfig(), + asyncTransports, + eventLoopSupplier.getMainEventLoopGroup())); + } + + void createNettyAsyncTransportBuilder(String configName, List amazonClients, + AmazonClientNettyTransportRecorder recorder, + AsyncHttpClientBuildTimeConfig buildAsyncConfig, + RuntimeValue asyncConfig, + BuildProducer clientAsyncTransports, + Supplier eventLoopSupplier) { + + Optional matchingClientBuildItem = amazonClients.stream() + .filter(c -> c.getAwsClientName().equals(configName)) + .findAny(); + + matchingClientBuildItem.ifPresent(client -> { + if (!client.getAsyncClassName().isPresent()) { + return; + } + if (buildAsyncConfig.type() != AsyncHttpClientBuildTimeConfig.AsyncClientType.NETTY) { + return; + } + + clientAsyncTransports.produce( + new AmazonClientAsyncTransportBuildItem( + client.getAwsClientName(), + client.getAsyncClassName().get(), + recorder.configureNettyAsync(recorder.configureAsync(configName, asyncConfig), eventLoopSupplier, + asyncConfig))); + }); + } + +} diff --git a/common/deployment-spi/pom.xml b/common/deployment-spi/pom.xml index 6ca296e55..764f3dc70 100644 --- a/common/deployment-spi/pom.xml +++ b/common/deployment-spi/pom.xml @@ -12,14 +12,18 @@ Quarkus - Amazon Services - Common - Deployment Spi - - io.netty - netty-transport - io.quarkus quarkus-builder + + io.smallrye + jandex + + + io.quarkiverse.amazonservices + quarkus-amazon-common-runtime-spi + \ No newline at end of file diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientAsyncTransportBuildItem.java b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientAsyncTransportBuildItem.java similarity index 100% rename from common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientAsyncTransportBuildItem.java rename to common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientAsyncTransportBuildItem.java diff --git a/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderBuildItem.java b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderBuildItem.java new file mode 100644 index 000000000..bbcf25cf4 --- /dev/null +++ b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderBuildItem.java @@ -0,0 +1,36 @@ +package io.quarkiverse.amazon.common.deployment; + +import io.quarkus.builder.item.MultiBuildItem; +import io.quarkus.runtime.RuntimeValue; +import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; + +public final class AmazonClientBuilderBuildItem extends MultiBuildItem { + private final RuntimeValue clientBuilder; + private final Class builderClass; + private final String clientName; + private final boolean hasOpenTelemetry; + + public AmazonClientBuilderBuildItem(RuntimeValue clientBuilder, Class builderClass, + String clientName, boolean hasOpenTelemetry) { + this.clientBuilder = clientBuilder; + this.builderClass = builderClass; + this.clientName = clientName; + this.hasOpenTelemetry = hasOpenTelemetry; + } + + public RuntimeValue getClientBuilder() { + return clientBuilder; + } + + public Class getBuilderClass() { + return builderClass; + } + + public String getClientName() { + return clientName; + } + + public boolean hasOpenTelemetry() { + return hasOpenTelemetry; + } +} diff --git a/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderOverrideBuildItem.java b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderOverrideBuildItem.java new file mode 100644 index 000000000..545ebf122 --- /dev/null +++ b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientBuilderOverrideBuildItem.java @@ -0,0 +1,23 @@ +package io.quarkiverse.amazon.common.deployment; + +import io.quarkus.builder.item.MultiBuildItem; + +public final class AmazonClientBuilderOverrideBuildItem extends MultiBuildItem { + private final Class builderClass; + private final String clientName; + + public AmazonClientBuilderOverrideBuildItem(Class builderClass, + String clientName) { + this.builderClass = builderClass; + this.clientName = clientName; + } + + public Class getBuilderClass() { + return builderClass; + } + + public String getClientName() { + return clientName; + } + +} diff --git a/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionBuildItem.java b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionBuildItem.java new file mode 100644 index 000000000..495e4df0e --- /dev/null +++ b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionBuildItem.java @@ -0,0 +1,144 @@ +package io.quarkiverse.amazon.common.deployment; + +import org.jboss.jandex.DotName; + +import io.quarkiverse.amazon.common.runtime.AmazonClientRecorder; +import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.AsyncHttpClientConfig; +import io.quarkiverse.amazon.common.runtime.HasAmazonClientRuntimeConfig; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientConfig; +import io.quarkus.builder.item.MultiBuildItem; +import io.quarkus.runtime.RuntimeValue; +import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder; +import software.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder; +import software.amazon.awssdk.awscore.presigner.SdkPresigner; + +public final class AmazonClientExtensionBuildItem extends MultiBuildItem { + + private final String configName; + private final HasTransportBuildTimeConfig transportBuildTimeConfig; + private final String amazonServiceClientName; + private final String builtinInterceptorsPath; + private final DotName syncClientName; + private final DotName asyncClientName; + private final DotName presignerClientName; + private final HasSdkBuildTimeConfig hasSdkBuildTimeConfig; + private final Class syncClientBuilderClass; + private final Class asyncClientBuilderClass; + private final Class presignerBuilderClass; + private final RuntimeValue syncConfig; + private final RuntimeValue asyncConfig; + private final RuntimeValue amazonClientsConfig; + private final RuntimeValue> syncBuilder; + private final RuntimeValue> asyncBuilder; + private final RuntimeValue presignerBuilder; + + public AmazonClientExtensionBuildItem( + String configName, + String amazonServiceClientName, + String builtinInterceptorsPath, + DotName syncClientName, + Class syncClientBuilderClass, + DotName asyncClientName, + Class asyncClientBuilderClass, + DotName presignerClientName, + Class presignerBuilderClass, + AmazonClientRecorder recorder, + HasTransportBuildTimeConfig transportBuildTimeConfig, + HasSdkBuildTimeConfig hasSdkBuildTimeConfig) { + this.configName = configName; + this.amazonServiceClientName = amazonServiceClientName; + this.builtinInterceptorsPath = builtinInterceptorsPath; + this.syncClientName = syncClientName; + this.syncClientBuilderClass = syncClientBuilderClass; + this.asyncClientName = asyncClientName; + this.asyncClientBuilderClass = asyncClientBuilderClass; + this.presignerClientName = presignerClientName; + this.presignerBuilderClass = presignerBuilderClass; + this.transportBuildTimeConfig = transportBuildTimeConfig; + this.hasSdkBuildTimeConfig = hasSdkBuildTimeConfig; + + // capture these runtime values so they can be reused in non @Record build step + this.syncConfig = recorder.getSyncConfig(); + this.asyncConfig = recorder.getAsyncConfig(); + this.amazonClientsConfig = recorder.getAmazonClientsConfig(); + this.syncBuilder = recorder.getSyncBuilder(); + this.asyncBuilder = recorder.getAsyncBuilder(); + this.presignerBuilder = presignerBuilderClass != null ? recorder.createPresignerBuilder() : null; + } + + public String getConfigName() { + return configName; + } + + public String getAmazonServiceClientName() { + return amazonServiceClientName; + } + + public String getBuiltinInterceptorsPath() { + return builtinInterceptorsPath; + } + + public DotName getSyncClientName() { + return syncClientName; + } + + public DotName getAsyncClientName() { + return asyncClientName; + } + + public DotName getPresignerClientName() { + return presignerClientName; + } + + public AsyncHttpClientBuildTimeConfig getBuildAsyncConfig() { + return transportBuildTimeConfig.asyncClient(); + } + + public RuntimeValue getAsyncConfig() { + return asyncConfig; + } + + public SyncHttpClientBuildTimeConfig getBuildSyncConfig() { + return transportBuildTimeConfig.syncClient(); + } + + public RuntimeValue getSyncConfig() { + return syncConfig; + } + + public HasSdkBuildTimeConfig getHasSdkBuildTimeConfig() { + return hasSdkBuildTimeConfig; + } + + public RuntimeValue getAmazonClientsConfig() { + return amazonClientsConfig; + } + + public Class getSyncClientBuilderClass() { + return syncClientBuilderClass; + } + + public Class getAsyncClientBuilderClass() { + return asyncClientBuilderClass; + } + + public Class getPresignerBuilderClass() { + return presignerBuilderClass; + } + + public RuntimeValue getCreatePresignerBuilder() { + return presignerBuilder; + } + + public RuntimeValue> getSyncBuilder() { + return syncBuilder; + } + + public RuntimeValue> getAsyncBuilder() { + return asyncBuilder; + } +} diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientSyncTransportBuildItem.java b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientSyncTransportBuildItem.java similarity index 100% rename from common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientSyncTransportBuildItem.java rename to common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientSyncTransportBuildItem.java diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/RequireAmazonClientTransportBuilderBuildItem.java b/common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/RequireAmazonClientTransportBuilderBuildItem.java similarity index 100% rename from common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/RequireAmazonClientTransportBuilderBuildItem.java rename to common/deployment-spi/src/main/java/io/quarkiverse/amazon/common/deployment/RequireAmazonClientTransportBuilderBuildItem.java diff --git a/common/deployment/pom.xml b/common/deployment/pom.xml index 457598487..a32872a5a 100644 --- a/common/deployment/pom.xml +++ b/common/deployment/pom.xml @@ -27,7 +27,6 @@ io.opentelemetry.instrumentation opentelemetry-aws-sdk-2.2 - true io.quarkiverse.amazonservices diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AbstractAmazonServiceProcessor.java b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AbstractAmazonServiceProcessor.java index 7a558cc05..87851be92 100644 --- a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AbstractAmazonServiceProcessor.java +++ b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AbstractAmazonServiceProcessor.java @@ -1,57 +1,11 @@ package io.quarkiverse.amazon.common.deployment; -import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.getNamedClientInjection; -import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.injectionPointAnnotationsBuilder; -import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.namedBuilder; -import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.namedClient; - -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ScheduledExecutorService; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import jakarta.enterprise.context.ApplicationScoped; - -import org.jboss.jandex.ClassType; import org.jboss.jandex.DotName; -import org.jboss.jandex.ParameterizedType; -import org.jboss.jandex.Type; -import io.netty.channel.EventLoopGroup; -import io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkTelemetry; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; import io.quarkiverse.amazon.common.runtime.AmazonClientRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientConfig; -import io.quarkiverse.amazon.common.runtime.HasAmazonClientRuntimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SdkAutoCloseableDestroyer; -import io.quarkiverse.amazon.common.runtime.SdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientConfig; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; -import io.quarkus.arc.processor.DotNames; -import io.quarkus.arc.processor.InjectionPointInfo; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.deployment.annotations.BuildProducer; -import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; -import io.quarkus.runtime.RuntimeValue; -import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; -import software.amazon.awssdk.awscore.presigner.SdkPresigner; -import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.async.SdkAsyncHttpClient; abstract public class AbstractAmazonServiceProcessor { @@ -61,458 +15,43 @@ abstract public class AbstractAmazonServiceProcessor { abstract protected DotName syncClientName(); + abstract protected Class syncClientBuilderClass(); + abstract protected DotName asyncClientName(); + abstract protected Class asyncClientBuilderClass(); + protected DotName presignerClientName() { return null; } - abstract protected String builtinInterceptorsPath(); - - protected void discoverClientInjectionPointsInternal(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - // Discover all clients injections - for (InjectionPointInfo injectionPoint : beanRegistrationPhase.getInjectionPoints()) { - - Type injectedType = getInjectedType(injectionPoint); - - if (syncClientName().equals(injectedType.name())) { - requireClientInjectionProducer - .produce(new RequireAmazonClientInjectionBuildItem(syncClientName(), - getNamedClientInjection(injectionPoint))); - } - if (asyncClientName().equals(injectedType.name())) { - requireClientInjectionProducer - .produce(new RequireAmazonClientInjectionBuildItem(asyncClientName(), - getNamedClientInjection(injectionPoint))); - } - if (presignerClientName() != null && presignerClientName().equals(injectedType.name())) { - requireClientInjectionProducer - .produce(new RequireAmazonClientInjectionBuildItem(presignerClientName(), - getNamedClientInjection(injectionPoint))); - } - } - } - - @BuildStep - protected void discoverClient( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - Optional syncClassName = Optional.empty(); - Optional asyncClassName = Optional.empty(); - - for (RequireAmazonClientInjectionBuildItem requireInjectionPoint : amazonClientInjectionPoints) { - if (syncClientName().equals(requireInjectionPoint.getClassName())) { - syncClassName = Optional.of(syncClientName()); - } - if (asyncClientName().equals(requireInjectionPoint.getClassName())) { - asyncClassName = Optional.of(asyncClientName()); - } - } - - if (syncClassName.isPresent() || asyncClassName.isPresent()) { - requireClientProducer.produce(new RequireAmazonClientBuildItem(syncClassName, asyncClassName)); - } - } - - protected void discoverTelemetry(BuildProducer telemetryProducer, - SdkBuildTimeConfig buildTimeSdkConfig) { - if (buildTimeSdkConfig.telemetry().orElse(false)) { - telemetryProducer.produce(new RequireAmazonTelemetryBuildItem(configName())); - } + protected Class presignerBuilderClass() { + return null; } - protected void setupClient(List clientRequirements, - BuildProducer clientProducer, - SdkBuildTimeConfig buildTimeSdkConfig, - SyncHttpClientBuildTimeConfig buildTimeSyncConfig, - AsyncHttpClientBuildTimeConfig buildTimeAsyncConfig) { - - Optional syncClassName = Optional.empty(); - Optional asyncClassName = Optional.empty(); + abstract protected String builtinInterceptorsPath(); - for (RequireAmazonClientBuildItem clientRequirement : clientRequirements) { + abstract protected HasTransportBuildTimeConfig transportBuildTimeConfig(); - if (clientRequirement.getSyncClassName().filter(syncClientName()::equals).isPresent()) { - syncClassName = Optional.of(syncClientName()); - } - if (clientRequirement.getAsyncClassName().filter(asyncClientName()::equals).isPresent()) { - asyncClassName = Optional.of(asyncClientName()); - } - } - if (syncClassName.isPresent() || asyncClassName.isPresent()) { - clientProducer.produce(new RequireAmazonClientTransportBuilderBuildItem(syncClassName, asyncClassName, configName(), - buildTimeSdkConfig, buildTimeSyncConfig, buildTimeAsyncConfig)); - } - } + abstract protected HasSdkBuildTimeConfig sdkBuildTimeConfig(); protected void setupExtension( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - feature.produce(new FeatureBuildItem(amazonServiceClientName())); - extensionSslNativeSupport.produce(new ExtensionSslNativeSupportBuildItem(amazonServiceClientName())); - interceptors.produce(new AmazonClientInterceptorsPathBuildItem(builtinInterceptorsPath())); - } - - protected void createApacheSyncTransportBuilder(List amazonClients, - AmazonClientApacheTransportRecorder recorder, - SyncHttpClientBuildTimeConfig buildSyncConfig, - RuntimeValue syncConfig, - BuildProducer clientSyncTransports) { - - Optional matchingClientBuildItem = amazonClients.stream() - .filter(c -> c.getAwsClientName().equals(configName())) - .findAny(); - - matchingClientBuildItem.ifPresent(client -> { - if (!client.getSyncClassName().isPresent()) { - return; - } - if (buildSyncConfig.type() != SyncHttpClientBuildTimeConfig.SyncClientType.APACHE) { - return; - } - - clientSyncTransports.produce( - new AmazonClientSyncTransportBuildItem( - client.getAwsClientName(), - client.getSyncClassName().get(), - recorder.configureSync(configName(), syncConfig))); - }); - } - - protected void createAwsCrtSyncTransportBuilder(List amazonClients, - AmazonClientAwsCrtTransportRecorder recorder, - SyncHttpClientBuildTimeConfig buildSyncConfig, - RuntimeValue syncConfig, - BuildProducer clientSyncTransports) { - - Optional matchingClientBuildItem = amazonClients.stream() - .filter(c -> c.getAwsClientName().equals(configName())) - .findAny(); - - matchingClientBuildItem.ifPresent(client -> { - if (!client.getSyncClassName().isPresent()) { - return; - } - if (buildSyncConfig.type() != SyncHttpClientBuildTimeConfig.SyncClientType.AWS_CRT) { - return; - } - - clientSyncTransports.produce( - new AmazonClientSyncTransportBuildItem( - client.getAwsClientName(), - client.getSyncClassName().get(), - recorder.configureSync(configName(), syncConfig))); - }); - } - - protected void createUrlConnectionSyncTransportBuilder(List amazonClients, - AmazonClientUrlConnectionTransportRecorder recorder, - SyncHttpClientBuildTimeConfig buildSyncConfig, - RuntimeValue syncConfig, - BuildProducer clientSyncTransports) { - - Optional matchingClientBuildItem = amazonClients.stream() - .filter(c -> c.getAwsClientName().equals(configName())) - .findAny(); - - matchingClientBuildItem.ifPresent(client -> { - if (!client.getSyncClassName().isPresent()) { - return; - } - if (buildSyncConfig.type() != SyncHttpClientBuildTimeConfig.SyncClientType.URL) { - return; - } - - clientSyncTransports.produce( - new AmazonClientSyncTransportBuildItem( - client.getAwsClientName(), - client.getSyncClassName().get(), - recorder.configureSync(configName(), syncConfig))); - }); - } - - protected void createNettyAsyncTransportBuilder(List amazonClients, - AmazonClientNettyTransportRecorder recorder, - AsyncHttpClientBuildTimeConfig buildAsyncConfig, - RuntimeValue asyncConfig, - BuildProducer clientAsyncTransports, - Supplier eventLoopSupplier) { - - Optional matchingClientBuildItem = amazonClients.stream() - .filter(c -> c.getAwsClientName().equals(configName())) - .findAny(); - - matchingClientBuildItem.ifPresent(client -> { - if (!client.getAsyncClassName().isPresent()) { - return; - } - if (buildAsyncConfig.type() != AsyncHttpClientBuildTimeConfig.AsyncClientType.NETTY) { - return; - } - - clientAsyncTransports.produce( - new AmazonClientAsyncTransportBuildItem( - client.getAwsClientName(), - client.getAsyncClassName().get(), - recorder.configureNettyAsync(recorder.configureAsync(configName(), asyncConfig), eventLoopSupplier, - asyncConfig))); - }); - } - - protected void createAwsCrtAsyncTransportBuilder(List amazonClients, - AmazonClientAwsCrtTransportRecorder recorder, - AsyncHttpClientBuildTimeConfig buildAsyncConfig, - RuntimeValue asyncConfig, - BuildProducer clientAsyncTransports) { - - Optional matchingClientBuildItem = amazonClients.stream() - .filter(c -> c.getAwsClientName().equals(configName())) - .findAny(); - - matchingClientBuildItem.ifPresent(client -> { - if (!client.getAsyncClassName().isPresent()) { - return; - } - if (buildAsyncConfig.type() != AsyncHttpClientBuildTimeConfig.AsyncClientType.AWS_CRT) { - return; - } - - clientAsyncTransports.produce( - new AmazonClientAsyncTransportBuildItem( - client.getAwsClientName(), - client.getAsyncClassName().get(), - recorder.configureAsync(configName(), asyncConfig))); - }); - } - - protected void createClientBuilders( AmazonClientRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - HasSdkBuildTimeConfig sdkBuildConfig, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - Class syncClientBuilderClass, - Class asyncClientBuilderClass, - Class presignerBuilderClass, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - Supplier> presignerBuilderSupplier = null; - if (presignerBuilderClass != null) { - presignerBuilderSupplier = () -> recorder.createPresignerBuilder(); - } - - createClientBuilders( - commonRecorder, - otelRecorder, - recorder.getAmazonClientsConfig(), - sdkBuildConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - syncClientBuilderClass, - (syncTransport) -> recorder.createSyncBuilder(syncTransport), - asyncClientBuilderClass, - (asyncTransport) -> recorder.createAsyncBuilder(asyncTransport, launchModeBuildItem.getLaunchMode(), - executorBuildItem.getExecutorProxy()), - presignerBuilderClass, - presignerBuilderSupplier, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); - } - - private void createClientBuilders( - AmazonClientCommonRecorder recorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - RuntimeValue amazonClientConfigRuntime, - HasSdkBuildTimeConfig sdkBuildConfig, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List amazonClientSyncTransports, - List amazonClientAsyncTransports, - Class syncClientBuilderClass, - Function, RuntimeValue> syncClientBuilderFunction, - Class asyncClientBuilderClass, - Function, RuntimeValue> asyncClientBuilderFunction, - Class presignerBuilderClass, - Supplier> presignerBuilderSupplier, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - String configName = configName(); - - Optional> syncSdkHttpClientBuilder = amazonClientSyncTransports.stream() - .filter(c -> configName.equals(c.getAwsClientName())) - .map(c -> c.getClientBuilder()) - .findFirst(); - Optional> asyncSdkAsyncHttpClientBuilder = amazonClientAsyncTransports - .stream() - .filter(c -> configName.equals(c.getAwsClientName())) - .map(c -> c.getClientBuilder()) - .findFirst(); - - boolean addOpenTelemetry = amazonRequireTelemtryClients - .stream() - .anyMatch(c -> configName.equals(c.getConfigName())); - - if (!syncSdkHttpClientBuilder.isPresent() && !asyncSdkAsyncHttpClientBuilder.isPresent() - && presignerBuilderSupplier == null) { - return; - } - - // requiring named clients can originate from multiple sources and we may have duplicates - Collection syncClientNames = amazonClientInjections.stream() - .filter(c -> syncClientName().equals(c.getClassName())) - .map(c -> c.getName()) - .distinct() - .collect(Collectors.toSet()); - - Collection asyncClientNames = amazonClientInjections.stream() - .filter(c -> asyncClientName().equals(c.getClassName())) - .map(c -> c.getName()) - .distinct() - .collect(Collectors.toSet()); - - Collection presignerClientNames = amazonClientInjections.stream() - .filter(c -> presignerClientName() != null && presignerClientName().equals(c.getClassName())) - .map(c -> c.getName()) - .distinct() - .collect(Collectors.toSet()); - - ScheduledExecutorService sharedExecutorService = executorBuildItem.getExecutorProxy(); - - if (syncSdkHttpClientBuilder.isPresent() && !syncClientNames.isEmpty()) { - for (String clientName : syncClientNames) { - RuntimeValue syncClientBuilder = syncClientBuilderFunction - .apply(syncSdkHttpClientBuilder.get()); - - syncClientBuilder = recorder.configure(syncClientBuilder, amazonClientConfigRuntime, - sdkBuildConfig, sharedExecutorService, configName(), clientName); - if (addOpenTelemetry) { - syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(syncClientBuilderClass), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .createWith(otelRecorder.configureSync(syncClientBuilder)) - .addInjectionPoint(ClassType.create(AwsSdkTelemetry.class)).done()); - } else { - syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(syncClientBuilderClass), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .runtimeValue(syncClientBuilder) - .done()); - } - syntheticBeans - .produce( - namedClient(SyntheticBeanBuildItem.configure(syncClientName()), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .createWith(recorder.build(syncClientBuilderClass, clientName)) - .addInjectionPoint(ClassType.create(syncClientBuilderClass), - injectionPointAnnotationsBuilder(clientName)) - .destroyer(SdkAutoCloseableDestroyer.class) - .done()); - - clientSync.produce(new AmazonClientSyncResultBuildItem(configName, clientName)); - } - } - if (asyncSdkAsyncHttpClientBuilder.isPresent() && !asyncClientNames.isEmpty()) { - for (String clientName : asyncClientNames) { - RuntimeValue asyncClientBuilder = asyncClientBuilderFunction - .apply(asyncSdkAsyncHttpClientBuilder.get()); - - asyncClientBuilder = recorder.configure(asyncClientBuilder, amazonClientConfigRuntime, - sdkBuildConfig, sharedExecutorService, configName(), clientName); - if (addOpenTelemetry) { - syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(asyncClientBuilderClass), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .createWith(otelRecorder.configureAsync(asyncClientBuilder)) - .addInjectionPoint(ClassType.create(AwsSdkTelemetry.class)).done()); - } else { - syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(asyncClientBuilderClass), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .runtimeValue(asyncClientBuilder) - .done()); - } - syntheticBeans.produce( - namedClient(SyntheticBeanBuildItem.configure(asyncClientName()), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .createWith(recorder.build(asyncClientBuilderClass, clientName)) - .addInjectionPoint(ClassType.create(asyncClientBuilderClass), - injectionPointAnnotationsBuilder(clientName)) - .destroyer(SdkAutoCloseableDestroyer.class) - .done()); - - clientAsync.produce(new AmazonClientAsyncResultBuildItem(configName, clientName)); - } - } - if (presignerBuilderSupplier != null && !presignerClientNames.isEmpty()) { - for (String clientName : presignerClientNames) { - RuntimeValue presignerBuilder = presignerBuilderSupplier.get(); - - presignerBuilder = recorder.configurePresigner(presignerBuilder, amazonClientConfigRuntime, - configName(), clientName); - syntheticBeans.produce( - namedBuilder(SyntheticBeanBuildItem.configure(presignerBuilderClass), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .runtimeValue(presignerBuilder) - .done()); - syntheticBeans.produce( - namedClient(SyntheticBeanBuildItem.configure(presignerClientName()), clientName) - .unremovable() - .defaultBean() - .setRuntimeInit() - .scope(ApplicationScoped.class) - .createWith(recorder.buildPresigner(presignerBuilderClass, clientName)) - .addInjectionPoint(ClassType.create(presignerBuilderClass), - injectionPointAnnotationsBuilder(clientName)) - .destroyer(SdkAutoCloseableDestroyer.class) - .done()); - } - } + BuildProducer amazonExtensions) { + amazonExtensions.produce( + new AmazonClientExtensionBuildItem( + configName(), + amazonServiceClientName(), + builtinInterceptorsPath(), + syncClientName(), + syncClientBuilderClass(), + asyncClientName(), + asyncClientBuilderClass(), + presignerClientName(), + presignerBuilderClass(), + recorder, + transportBuildTimeConfig(), + sdkBuildTimeConfig())); } - private Type getInjectedType(InjectionPointInfo injectionPoint) { - Type requiredType = injectionPoint.getRequiredType(); - Type injectedType = requiredType; - - if (DotNames.INSTANCE.equals(requiredType.name()) && requiredType instanceof ParameterizedType) { - injectedType = requiredType.asParameterizedType().arguments().get(0); - } - - return injectedType; - } } diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionsProcessor.java b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionsProcessor.java new file mode 100644 index 000000000..1d68ac9ae --- /dev/null +++ b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonClientExtensionsProcessor.java @@ -0,0 +1,466 @@ +package io.quarkiverse.amazon.common.deployment; + +import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.getNamedClientInjection; +import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.injectionPointAnnotationsBuilder; +import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.namedBuilder; +import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.namedClient; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ScheduledExecutorService; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +import jakarta.enterprise.context.ApplicationScoped; + +import org.jboss.jandex.ClassType; +import org.jboss.jandex.DotName; +import org.jboss.jandex.ParameterizedType; +import org.jboss.jandex.Type; + +import io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkTelemetry; +import io.quarkiverse.amazon.common.runtime.AmazonClientBuilderRecorder; +import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; +import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; +import io.quarkiverse.amazon.common.runtime.HasAmazonClientRuntimeConfig; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.SdkAutoCloseableDestroyer; +import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; +import io.quarkus.arc.deployment.SyntheticBeanBuildItem; +import io.quarkus.arc.processor.DotNames; +import io.quarkus.arc.processor.InjectionPointInfo; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.ExecutorBuildItem; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.LaunchModeBuildItem; +import io.quarkus.runtime.RuntimeValue; +import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; +import software.amazon.awssdk.awscore.presigner.SdkPresigner; +import software.amazon.awssdk.http.SdkHttpClient; +import software.amazon.awssdk.http.async.SdkAsyncHttpClient; + +public class AmazonClientExtensionsProcessor { + + @BuildStep + void setup( + List amazonExtensions, + BuildProducer extensionSslNativeSupport, + BuildProducer feature, + BuildProducer interceptors) { + + amazonExtensions.forEach(extension -> setupExtension(extension, extensionSslNativeSupport, feature, interceptors)); + } + + protected void setupExtension( + AmazonClientExtensionBuildItem extension, + BuildProducer extensionSslNativeSupport, + BuildProducer feature, + BuildProducer interceptors) { + + feature.produce(new FeatureBuildItem(extension.getAmazonServiceClientName())); + extensionSslNativeSupport.produce(new ExtensionSslNativeSupportBuildItem(extension.getAmazonServiceClientName())); + interceptors.produce(new AmazonClientInterceptorsPathBuildItem(extension.getBuiltinInterceptorsPath())); + } + + @BuildStep + void discoverClientInjectionPoints( + List amazonExtensions, + BeanRegistrationPhaseBuildItem beanRegistrationPhase, + BuildProducer requireClientInjectionProducer) { + + amazonExtensions.forEach(extension -> discoverClientInjectionPointsInternal(extension, beanRegistrationPhase, + requireClientInjectionProducer)); + } + + protected void discoverClientInjectionPointsInternal( + AmazonClientExtensionBuildItem extension, + BeanRegistrationPhaseBuildItem beanRegistrationPhase, + BuildProducer requireClientInjectionProducer) { + + // Discover all clients injections + for (InjectionPointInfo injectionPoint : beanRegistrationPhase.getInjectionPoints()) { + + Type injectedType = getInjectedType(injectionPoint); + + if (extension.getSyncClientName().equals(injectedType.name())) { + requireClientInjectionProducer + .produce(new RequireAmazonClientInjectionBuildItem(extension.getSyncClientName(), + getNamedClientInjection(injectionPoint))); + } + if (extension.getAsyncClientName().equals(injectedType.name())) { + requireClientInjectionProducer + .produce(new RequireAmazonClientInjectionBuildItem(extension.getAsyncClientName(), + getNamedClientInjection(injectionPoint))); + } + if (extension.getPresignerClientName() != null && extension.getPresignerClientName().equals(injectedType.name())) { + requireClientInjectionProducer + .produce(new RequireAmazonClientInjectionBuildItem(extension.getPresignerClientName(), + getNamedClientInjection(injectionPoint))); + } + } + } + + private Type getInjectedType(InjectionPointInfo injectionPoint) { + Type requiredType = injectionPoint.getRequiredType(); + Type injectedType = requiredType; + + if (DotNames.INSTANCE.equals(requiredType.name()) && requiredType instanceof ParameterizedType) { + injectedType = requiredType.asParameterizedType().arguments().get(0); + } + + return injectedType; + } + + @BuildStep + void discover( + List amazonExtensions, + List amazonClientInjectionPoints, + BuildProducer requireClientProducer) { + + amazonExtensions.forEach(extension -> discoverClient(extension, amazonClientInjectionPoints, requireClientProducer)); + } + + protected void discoverClient( + AmazonClientExtensionBuildItem extension, + List amazonClientInjectionPoints, + BuildProducer requireClientProducer) { + Optional syncClassName = Optional.empty(); + Optional asyncClassName = Optional.empty(); + + for (RequireAmazonClientInjectionBuildItem requireInjectionPoint : amazonClientInjectionPoints) { + if (extension.getSyncClientName().equals(requireInjectionPoint.getClassName())) { + syncClassName = Optional.of(extension.getSyncClientName()); + } + if (extension.getAsyncClientName().equals(requireInjectionPoint.getClassName())) { + asyncClassName = Optional.of(extension.getAsyncClientName()); + } + } + + if (syncClassName.isPresent() || asyncClassName.isPresent()) { + requireClientProducer.produce(new RequireAmazonClientBuildItem(syncClassName, asyncClassName)); + } + } + + @BuildStep + void discoverTelemetry( + List amazonExtensions, + BuildProducer telemetryProducer) { + + amazonExtensions.forEach(extension -> discoverTelemetry(extension, telemetryProducer)); + } + + protected void discoverTelemetry( + AmazonClientExtensionBuildItem extension, + BuildProducer telemetryProducer) { + if (extension.getHasSdkBuildTimeConfig().sdk().telemetry().orElse(false)) { + telemetryProducer.produce(new RequireAmazonTelemetryBuildItem(extension.getConfigName())); + } + } + + @BuildStep + void setupClient( + List amazonExtensions, + List clientRequirements, + BuildProducer clientProducer) { + + amazonExtensions.forEach(extension -> setupClient(extension, clientRequirements, clientProducer)); + } + + protected void setupClient( + AmazonClientExtensionBuildItem extension, + List clientRequirements, + BuildProducer clientProducer) { + + Optional syncClassName = Optional.empty(); + Optional asyncClassName = Optional.empty(); + + for (RequireAmazonClientBuildItem clientRequirement : clientRequirements) { + + if (clientRequirement.getSyncClassName().filter(extension.getSyncClientName()::equals).isPresent()) { + syncClassName = Optional.of(extension.getSyncClientName()); + } + if (clientRequirement.getAsyncClassName().filter(extension.getAsyncClientName()::equals).isPresent()) { + asyncClassName = Optional.of(extension.getAsyncClientName()); + } + } + if (syncClassName.isPresent() || asyncClassName.isPresent()) { + clientProducer.produce( + new RequireAmazonClientTransportBuilderBuildItem(syncClassName, asyncClassName, extension.getConfigName(), + extension.getHasSdkBuildTimeConfig().sdk(), extension.getBuildSyncConfig(), + extension.getBuildAsyncConfig())); + } + } + + @BuildStep + @Record(ExecutionTime.RUNTIME_INIT) + void createClientBuilders( + List amazonExtensions, + AmazonClientCommonRecorder commonRecorder, + AmazonClientBuilderRecorder builderRecorder, + List amazonClientInjections, + List amazonRequireTelemtryClients, + List syncTransports, + List asyncTransports, + BuildProducer clientBuilders, + BuildProducer syntheticBeans, + BuildProducer clientSync, + BuildProducer clientAsync, + LaunchModeBuildItem launchModeBuildItem, + ExecutorBuildItem executorBuildItem) { + amazonExtensions.forEach(extension -> createClientBuilders( + extension, + commonRecorder, + builderRecorder, + amazonClientInjections, + amazonRequireTelemtryClients, + syncTransports, + asyncTransports, + clientBuilders, + syntheticBeans, + clientSync, + clientAsync, + launchModeBuildItem, + executorBuildItem)); + } + + protected void createClientBuilders( + AmazonClientExtensionBuildItem extension, + AmazonClientCommonRecorder commonRecorder, + AmazonClientBuilderRecorder builderRecorder, + List amazonClientInjections, + List amazonRequireTelemtryClients, + List syncTransports, + List asyncTransports, + BuildProducer clientBuilders, + BuildProducer syntheticBeans, + BuildProducer clientSync, + BuildProducer clientAsync, + LaunchModeBuildItem launchModeBuildItem, + ExecutorBuildItem executorBuildItem) { + + Supplier> presignerBuilderSupplier = null; + if (extension.getPresignerBuilderClass() != null) { + presignerBuilderSupplier = () -> extension.getCreatePresignerBuilder(); + } + + createClientBuilders( + extension.getConfigName(), + commonRecorder, + builderRecorder, + extension.getAmazonClientsConfig(), + extension.getHasSdkBuildTimeConfig(), + amazonClientInjections, + amazonRequireTelemtryClients, + syncTransports, + asyncTransports, + extension.getSyncClientName(), + extension.getSyncClientBuilderClass(), + (syncTransport) -> builderRecorder.createSyncBuilder(extension.getSyncBuilder(), syncTransport), + extension.getAsyncClientName(), + extension.getAsyncClientBuilderClass(), + (asyncTransport) -> builderRecorder.createAsyncBuilder(extension.getAsyncBuilder(), asyncTransport, + launchModeBuildItem.getLaunchMode(), + executorBuildItem.getExecutorProxy(), extension.getAsyncConfig()), + extension.getPresignerClientName(), + extension.getPresignerBuilderClass(), + presignerBuilderSupplier, + clientBuilders, + syntheticBeans, + clientSync, + clientAsync, + launchModeBuildItem, + executorBuildItem); + } + + private void createClientBuilders( + String configName, + AmazonClientCommonRecorder recorder, + AmazonClientBuilderRecorder builderRecorder, + RuntimeValue amazonClientConfigRuntime, + HasSdkBuildTimeConfig sdkBuildConfig, + List amazonClientInjections, + List amazonRequireTelemtryClients, + List amazonClientSyncTransports, + List amazonClientAsyncTransports, + DotName syncClientName, + Class syncClientBuilderClass, + Function, RuntimeValue> syncClientBuilderFunction, + DotName asyncClientName, + Class asyncClientBuilderClass, + Function, RuntimeValue> asyncClientBuilderFunction, + DotName presignerClientName, + Class presignerBuilderClass, + Supplier> presignerBuilderSupplier, + BuildProducer clientBuilders, + BuildProducer syntheticBeans, + BuildProducer clientSync, + BuildProducer clientAsync, + LaunchModeBuildItem launchModeBuildItem, + ExecutorBuildItem executorBuildItem) { + + Optional> syncSdkHttpClientBuilder = amazonClientSyncTransports.stream() + .filter(c -> configName.equals(c.getAwsClientName())) + .map(c -> c.getClientBuilder()) + .findFirst(); + Optional> asyncSdkAsyncHttpClientBuilder = amazonClientAsyncTransports + .stream() + .filter(c -> configName.equals(c.getAwsClientName())) + .map(c -> c.getClientBuilder()) + .findFirst(); + + boolean addOpenTelemetry = amazonRequireTelemtryClients + .stream() + .anyMatch(c -> configName.equals(c.getConfigName())); + + if (!syncSdkHttpClientBuilder.isPresent() && !asyncSdkAsyncHttpClientBuilder.isPresent() + && presignerBuilderSupplier == null) { + return; + } + + // requiring named clients can originate from multiple sources and we may have duplicates + Collection syncClientNames = amazonClientInjections.stream() + .filter(c -> syncClientName.equals(c.getClassName())) + .map(c -> c.getName()) + .distinct() + .collect(Collectors.toSet()); + + Collection asyncClientNames = amazonClientInjections.stream() + .filter(c -> asyncClientName.equals(c.getClassName())) + .map(c -> c.getName()) + .distinct() + .collect(Collectors.toSet()); + + Collection presignerClientNames = amazonClientInjections.stream() + .filter(c -> presignerClientName != null && presignerClientName.equals(c.getClassName())) + .map(c -> c.getName()) + .distinct() + .collect(Collectors.toSet()); + + ScheduledExecutorService sharedExecutorService = executorBuildItem.getExecutorProxy(); + + if (syncSdkHttpClientBuilder.isPresent() && !syncClientNames.isEmpty()) { + for (String clientName : syncClientNames) { + RuntimeValue syncClientBuilder = syncClientBuilderFunction + .apply(syncSdkHttpClientBuilder.get()); + + syncClientBuilder = recorder.configure(syncClientBuilder, amazonClientConfigRuntime, + sdkBuildConfig, sharedExecutorService, configName, clientName); + + clientBuilders.produce(new AmazonClientBuilderBuildItem(syncClientBuilder, syncClientBuilderClass, + clientName, addOpenTelemetry)); + + syntheticBeans + .produce( + namedClient(SyntheticBeanBuildItem.configure(syncClientName), clientName) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .createWith(recorder.build(syncClientBuilderClass, clientName)) + .addInjectionPoint(ClassType.create(syncClientBuilderClass), + injectionPointAnnotationsBuilder(clientName)) + .destroyer(SdkAutoCloseableDestroyer.class) + .done()); + + clientSync.produce(new AmazonClientSyncResultBuildItem(configName, clientName)); + } + } + if (asyncSdkAsyncHttpClientBuilder.isPresent() && !asyncClientNames.isEmpty()) { + for (String clientName : asyncClientNames) { + RuntimeValue asyncClientBuilder = asyncClientBuilderFunction + .apply(asyncSdkAsyncHttpClientBuilder.get()); + + asyncClientBuilder = recorder.configure(asyncClientBuilder, amazonClientConfigRuntime, + sdkBuildConfig, sharedExecutorService, configName, clientName); + + clientBuilders.produce(new AmazonClientBuilderBuildItem(asyncClientBuilder, asyncClientBuilderClass, + clientName, addOpenTelemetry)); + + syntheticBeans.produce( + namedClient(SyntheticBeanBuildItem.configure(asyncClientName), clientName) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .createWith(recorder.build(asyncClientBuilderClass, clientName)) + .addInjectionPoint(ClassType.create(asyncClientBuilderClass), + injectionPointAnnotationsBuilder(clientName)) + .destroyer(SdkAutoCloseableDestroyer.class) + .done()); + + clientAsync.produce(new AmazonClientAsyncResultBuildItem(configName, clientName)); + } + } + if (presignerBuilderSupplier != null && !presignerClientNames.isEmpty()) { + for (String clientName : presignerClientNames) { + RuntimeValue presignerBuilder = presignerBuilderSupplier.get(); + + presignerBuilder = recorder.configurePresigner(presignerBuilder, amazonClientConfigRuntime, + configName, clientName); + syntheticBeans.produce( + namedBuilder(SyntheticBeanBuildItem.configure(presignerBuilderClass), clientName) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .runtimeValue(presignerBuilder) + .done()); + syntheticBeans.produce( + namedClient(SyntheticBeanBuildItem.configure(presignerClientName), clientName) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .createWith(recorder.buildPresigner(presignerBuilderClass, clientName)) + .addInjectionPoint(ClassType.create(presignerBuilderClass), + injectionPointAnnotationsBuilder(clientName)) + .destroyer(SdkAutoCloseableDestroyer.class) + .done()); + } + } + } + + @BuildStep + @Record(ExecutionTime.RUNTIME_INIT) + void produceSyntheticBeans( + AmazonClientOpenTelemetryRecorder otelRecorder, + List clientBuilders, + List clientBuilderOverride, + BuildProducer syntheticBeans) { + + for (AmazonClientBuilderBuildItem clientBuilder : clientBuilders) { + Optional override = clientBuilderOverride.stream() + .filter(o -> o.getBuilderClass().equals(clientBuilder.getBuilderClass()) && + o.getClientName().equals(clientBuilder.getClientName())) + .findFirst(); + + if (override.isEmpty()) { + if (clientBuilder.hasOpenTelemetry()) { + syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(clientBuilder.getBuilderClass()), + clientBuilder.getClientName()) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .createWith(otelRecorder.configure(clientBuilder.getClientBuilder())) + .addInjectionPoint(ClassType.create(AwsSdkTelemetry.class)).done()); + } else { + syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(clientBuilder.getBuilderClass()), + clientBuilder.getClientName()) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .runtimeValue(clientBuilder.getClientBuilder()) + .done()); + } + } + } + } +} diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonHttpClients.java b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonHttpClients.java index f76231a62..e6fd14373 100644 --- a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonHttpClients.java +++ b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonHttpClients.java @@ -2,6 +2,8 @@ import java.util.function.BooleanSupplier; +import io.quarkus.bootstrap.classloading.QuarkusClassLoader; + public class AmazonHttpClients { public static final String APACHE_HTTP_SERVICE = "software.amazon.awssdk.http.apache.ApacheSdkHttpService"; @@ -12,48 +14,28 @@ public class AmazonHttpClients { public static class IsAmazonApacheHttpServicePresent implements BooleanSupplier { @Override public boolean getAsBoolean() { - try { - Class.forName(APACHE_HTTP_SERVICE); - return true; - } catch (Exception e) { - return false; - } + return QuarkusClassLoader.isClassPresentAtRuntime(APACHE_HTTP_SERVICE); } }; public static class IsAmazonNettyHttpServicePresent implements BooleanSupplier { @Override public boolean getAsBoolean() { - try { - Class.forName(NETTY_HTTP_SERVICE); - return true; - } catch (Exception e) { - return false; - } + return QuarkusClassLoader.isClassPresentAtRuntime(NETTY_HTTP_SERVICE); } }; public static class IsAmazonUrlConnectionHttpServicePresent implements BooleanSupplier { @Override public boolean getAsBoolean() { - try { - Class.forName(URL_CONNECTION_HTTP_SERVICE); - return true; - } catch (Exception e) { - return false; - } + return QuarkusClassLoader.isClassPresentAtRuntime(URL_CONNECTION_HTTP_SERVICE); } }; public static class IsAmazonAwsCrtHttpServicePresent implements BooleanSupplier { @Override public boolean getAsBoolean() { - try { - Class.forName(AWS_CRT_HTTP_SERVICE); - return true; - } catch (Exception e) { - return false; - } + return QuarkusClassLoader.isClassPresentAtRuntime(AWS_CRT_HTTP_SERVICE); } } } diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonServicesClientsProcessor.java b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonServicesClientsProcessor.java index fd66d179c..3e3c45306 100644 --- a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonServicesClientsProcessor.java +++ b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/AmazonServicesClientsProcessor.java @@ -18,7 +18,6 @@ import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig.SyncClientType; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.UnremovableBeanBuildItem; -import io.quarkus.bootstrap.classloading.QuarkusClassLoader; import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.Capability; import io.quarkus.deployment.annotations.BuildProducer; @@ -153,11 +152,10 @@ void setup( // Register what's needed depending on the clients in the classpath and the configuration. // We use the configuration to guide us but if we don't have any clients configured, // we still register what's needed depending on what is in the classpath. - boolean isSyncApacheInClasspath = QuarkusClassLoader.isClassPresentAtRuntime(AmazonHttpClients.APACHE_HTTP_SERVICE); - boolean isSyncUrlConnectionInClasspath = QuarkusClassLoader - .isClassPresentAtRuntime(AmazonHttpClients.URL_CONNECTION_HTTP_SERVICE); - boolean isAsyncNettyInClasspath = QuarkusClassLoader.isClassPresentAtRuntime(AmazonHttpClients.NETTY_HTTP_SERVICE); - boolean isAwsCrtInClasspath = QuarkusClassLoader.isClassPresentAtRuntime(AmazonHttpClients.AWS_CRT_HTTP_SERVICE); + boolean isSyncApacheInClasspath = new AmazonHttpClients.IsAmazonApacheHttpServicePresent().getAsBoolean(); + boolean isSyncUrlConnectionInClasspath = new AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent().getAsBoolean(); + boolean isAsyncNettyInClasspath = new AmazonHttpClients.IsAmazonNettyHttpServicePresent().getAsBoolean(); + boolean isAwsCrtInClasspath = new AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent().getAsBoolean(); // Check that the clients required by the configuration are available if (syncTransportNeeded) { diff --git a/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/UrlConnectionTransportBuilderProcessor.java b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/UrlConnectionTransportBuilderProcessor.java new file mode 100644 index 000000000..09508041a --- /dev/null +++ b/common/deployment/src/main/java/io/quarkiverse/amazon/common/deployment/UrlConnectionTransportBuilderProcessor.java @@ -0,0 +1,60 @@ +package io.quarkiverse.amazon.common.deployment; + +import java.util.List; +import java.util.Optional; + +import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.SyncHttpClientConfig; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.runtime.RuntimeValue; + +public class UrlConnectionTransportBuilderProcessor { + + @BuildStep() + @Record(ExecutionTime.RUNTIME_INIT) + void setupUrlConnectionSyncTransport( + List extensions, + List amazonClients, + AmazonClientUrlConnectionTransportRecorder transportRecorder, + BuildProducer syncTransports) { + + extensions.forEach(extension -> createUrlConnectionSyncTransportBuilder( + extension.getConfigName(), + amazonClients, + transportRecorder, + extension.getBuildSyncConfig(), + extension.getSyncConfig(), + syncTransports)); + } + + void createUrlConnectionSyncTransportBuilder(String configName, + List amazonClients, + AmazonClientUrlConnectionTransportRecorder recorder, + SyncHttpClientBuildTimeConfig buildSyncConfig, + RuntimeValue syncConfig, + BuildProducer clientSyncTransports) { + + Optional matchingClientBuildItem = amazonClients.stream() + .filter(c -> c.getAwsClientName().equals(configName)) + .findAny(); + + matchingClientBuildItem.ifPresent(client -> { + if (!client.getSyncClassName().isPresent()) { + return; + } + if (buildSyncConfig.type() != SyncHttpClientBuildTimeConfig.SyncClientType.URL) { + return; + } + + clientSyncTransports.produce( + new AmazonClientSyncTransportBuildItem( + client.getAwsClientName(), + client.getSyncClassName().get(), + recorder.configureSync(configName, syncConfig))); + }); + } +} diff --git a/common/pom.xml b/common/pom.xml index ef6037fc3..b633c6bbb 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -14,6 +14,7 @@ pom + runtime-spi runtime-apache-client-internal runtime-netty-client-internal runtime-crt-client-internal diff --git a/common/runtime-apache-client-internal/pom.xml b/common/runtime-apache-client-internal/pom.xml index 0b5a42d3a..0cca1aa73 100644 --- a/common/runtime-apache-client-internal/pom.xml +++ b/common/runtime-apache-client-internal/pom.xml @@ -17,6 +17,21 @@ io.quarkus quarkus-core + + io.quarkiverse.amazonservices + quarkus-amazon-common-runtime-spi + + + software.amazon.awssdk + apache-client + provided + + + commons-logging + commons-logging + + + io.quarkus quarkus-apache-httpclient diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientApacheTransportRecorder.java b/common/runtime-apache-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientApacheTransportRecorder.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientApacheTransportRecorder.java rename to common/runtime-apache-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientApacheTransportRecorder.java diff --git a/common/runtime-crt-client-internal/pom.xml b/common/runtime-crt-client-internal/pom.xml index c6584c89a..9e1aea837 100644 --- a/common/runtime-crt-client-internal/pom.xml +++ b/common/runtime-crt-client-internal/pom.xml @@ -17,6 +17,15 @@ io.quarkus quarkus-core + + io.quarkiverse.amazonservices + quarkus-amazon-common-runtime-spi + + + software.amazon.awssdk + aws-crt-client + provided + io.quarkiverse.amazonservices quarkus-amazon-crt diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientAwsCrtTransportRecorder.java b/common/runtime-crt-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientAwsCrtTransportRecorder.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientAwsCrtTransportRecorder.java rename to common/runtime-crt-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientAwsCrtTransportRecorder.java diff --git a/common/runtime-netty-client-internal/pom.xml b/common/runtime-netty-client-internal/pom.xml index 61a6791f2..460f33bdf 100644 --- a/common/runtime-netty-client-internal/pom.xml +++ b/common/runtime-netty-client-internal/pom.xml @@ -17,6 +17,15 @@ io.quarkus quarkus-core + + io.quarkiverse.amazonservices + quarkus-amazon-common-runtime-spi + + + software.amazon.awssdk + netty-nio-client + provided + io.quarkus quarkus-netty diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java b/common/runtime-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java similarity index 85% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java rename to common/runtime-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java index 5978ad71e..bdab105a0 100644 --- a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java +++ b/common/runtime-netty-client-internal/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientNettyTransportRecorder.java @@ -5,7 +5,7 @@ import java.util.function.Supplier; import io.netty.channel.EventLoopGroup; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientConfig.SslProviderType; +import io.netty.handler.ssl.SslProvider; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.Recorder; import software.amazon.awssdk.http.TlsTrustManagersProvider; @@ -36,7 +36,7 @@ public RuntimeValue configureAsync(String clientName builder.readTimeout(asyncConfig.readTimeout()); builder.writeTimeout(asyncConfig.writeTimeout()); builder.tcpKeepAlive(asyncConfig.tcpKeepAlive()); - asyncConfig.sslProvider().map(SslProviderType::create).ifPresent(builder::sslProvider); + asyncConfig.sslProvider().map(this::map).map(SslProviderTypeNetty::create).ifPresent(builder::sslProvider); builder.useIdleConnectionReaper(asyncConfig.useIdleConnectionReaper()); if (asyncConfig.http2().initialWindowSize().isPresent() || asyncConfig.http2().maxStreams().isPresent()) { @@ -124,4 +124,41 @@ private void validateNettyClientConfig(String extension, AsyncHttpClientConfig c validateTlsKeyManagersProvider(extension, config.tlsKeyManagersProvider(), "async"); validateTlsTrustManagersProvider(extension, config.tlsTrustManagersProvider(), "async"); } + + public SslProviderTypeNetty map(AsyncHttpClientConfig.SslProviderType sslProviderType) { + switch (sslProviderType) { + case JDK: + return SslProviderTypeNetty.JDK; + case OPENSSL: + return SslProviderTypeNetty.OPENSSL; + case OPENSSL_REFCNT: + return SslProviderTypeNetty.OPENSSL_REFCNT; + default: + return SslProviderTypeNetty.JDK; + } + } + + public enum SslProviderTypeNetty { + + JDK { + @Override + SslProvider create() { + return io.netty.handler.ssl.SslProvider.JDK; + } + }, + OPENSSL { + @Override + SslProvider create() { + return io.netty.handler.ssl.SslProvider.OPENSSL; + } + }, + OPENSSL_REFCNT { + @Override + SslProvider create() { + return io.netty.handler.ssl.SslProvider.OPENSSL_REFCNT; + } + }; + + abstract SslProvider create(); + } } diff --git a/common/runtime-spi/pom.xml b/common/runtime-spi/pom.xml new file mode 100644 index 000000000..de79ced5b --- /dev/null +++ b/common/runtime-spi/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + + io.quarkiverse.amazonservices + quarkus-amazon-common-parent + 999-SNAPSHOT + + + quarkus-amazon-common-runtime-spi + Quarkus - Amazon Services - Common - Runtime Spi + + + + io.quarkus + quarkus-core + + + io.quarkus + quarkus-arc + + + software.amazon.awssdk + http-client-spi + + + software.amazon.awssdk + sdk-core + + + software.amazon.awssdk + aws-core + + + + \ No newline at end of file diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AbstractAmazonClientTransportRecorder.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AbstractAmazonClientTransportRecorder.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AbstractAmazonClientTransportRecorder.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AbstractAmazonClientTransportRecorder.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientConfig.java diff --git a/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java new file mode 100644 index 000000000..9cf92e604 --- /dev/null +++ b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java @@ -0,0 +1,39 @@ +package io.quarkiverse.amazon.common.runtime; + +import io.quarkus.runtime.RuntimeValue; +import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder; +import software.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder; +import software.amazon.awssdk.awscore.presigner.SdkPresigner; + +public abstract class AmazonClientRecorder { + + public abstract RuntimeValue getAmazonClientsConfig(); + + public abstract AsyncHttpClientConfig getAsyncClientConfig(); + + public abstract SyncHttpClientConfig getSyncClientConfig(); + + public abstract AwsSyncClientBuilder geSyncClientBuilder(); + + public abstract AwsAsyncClientBuilder getAsyncClientBuilder(); + + public RuntimeValue getSyncConfig() { + return new RuntimeValue<>(getSyncClientConfig()); + } + + public RuntimeValue getAsyncConfig() { + return new RuntimeValue<>(getAsyncClientConfig()); + } + + public RuntimeValue> getSyncBuilder() { + return new RuntimeValue<>(geSyncClientBuilder()); + } + + public RuntimeValue> getAsyncBuilder() { + return new RuntimeValue<>(getAsyncClientBuilder()); + } + + public RuntimeValue createPresignerBuilder() { + throw new UnsupportedOperationException(); + } +} diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientBuildTimeConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientBuildTimeConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientBuildTimeConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientBuildTimeConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java similarity index 92% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java index 514d2ac31..568a4e68e 100644 --- a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java +++ b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AsyncHttpClientConfig.java @@ -6,7 +6,7 @@ import java.util.Optional; import java.util.OptionalInt; -import io.netty.handler.ssl.SslProvider; +//import io.netty.handler.ssl.SslProvider; import io.quarkus.runtime.annotations.ConfigDocDefault; import io.quarkus.runtime.annotations.ConfigGroup; import io.quarkus.runtime.configuration.DurationConverter; @@ -256,26 +256,8 @@ public interface Advanced { * An enumeration of SSL/TLS protocol providers. */ public enum SslProviderType { - - JDK { - @Override - SslProvider create() { - return io.netty.handler.ssl.SslProvider.JDK; - } - }, - OPENSSL { - @Override - SslProvider create() { - return io.netty.handler.ssl.SslProvider.OPENSSL; - } - }, - OPENSSL_REFCNT { - @Override - SslProvider create() { - return io.netty.handler.ssl.SslProvider.OPENSSL_REFCNT; - } - }; - - abstract SslProvider create(); + JDK, + OPENSSL, + OPENSSL_REFCNT } } diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AwsConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AwsConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AwsConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AwsConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderType.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderType.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderType.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/AwsCredentialsProviderType.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/ClientUtil.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/ClientUtil.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/ClientUtil.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/ClientUtil.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/CrtHttpClientConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/CrtHttpClientConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/CrtHttpClientConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/CrtHttpClientConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsManagersProviderConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsManagersProviderConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsManagersProviderConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsManagersProviderConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsTrustManagersProvider.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsTrustManagersProvider.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsTrustManagersProvider.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/FileStoreTlsTrustManagersProvider.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/HasAmazonClientRuntimeConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasAmazonClientRuntimeConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/HasAmazonClientRuntimeConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasAmazonClientRuntimeConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/HasSdkBuildTimeConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasSdkBuildTimeConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/HasSdkBuildTimeConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasSdkBuildTimeConfig.java diff --git a/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasTransportBuildTimeConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasTransportBuildTimeConfig.java new file mode 100644 index 000000000..a810c767a --- /dev/null +++ b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/HasTransportBuildTimeConfig.java @@ -0,0 +1,13 @@ +package io.quarkiverse.amazon.common.runtime; + +public interface HasTransportBuildTimeConfig { + /** + * Sync HTTP transport configuration + */ + SyncHttpClientBuildTimeConfig syncClient(); + + /** + * Async HTTP transport configuration + */ + AsyncHttpClientBuildTimeConfig asyncClient(); +} diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/NoneTlsTrustManagersProvider.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/NoneTlsTrustManagersProvider.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/NoneTlsTrustManagersProvider.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/NoneTlsTrustManagersProvider.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/RuntimeConfigurationError.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/RuntimeConfigurationError.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/RuntimeConfigurationError.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/RuntimeConfigurationError.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SdkBuildTimeConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SdkBuildTimeConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SdkBuildTimeConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SdkBuildTimeConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SdkConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SdkConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SdkConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SdkConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientBuildTimeConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientBuildTimeConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientBuildTimeConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientBuildTimeConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/SyncHttpClientConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderType.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderType.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderType.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsKeyManagersProviderType.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderConfig.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderConfig.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderConfig.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderConfig.java diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderType.java b/common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderType.java similarity index 100% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderType.java rename to common/runtime-spi/src/main/java/io/quarkiverse/amazon/common/runtime/TlsTrustManagersProviderType.java diff --git a/common/runtime/pom.xml b/common/runtime/pom.xml index c484f71e8..256da02f4 100644 --- a/common/runtime/pom.xml +++ b/common/runtime/pom.xml @@ -52,20 +52,14 @@ http-client-spi - software.amazon.awssdk - netty-nio-client - true + io.quarkiverse.amazonservices + quarkus-amazon-common-runtime-spi io.quarkiverse.amazonservices quarkus-amazon-netty-client-internal true - - software.amazon.awssdk - aws-crt-client - true - io.quarkiverse.amazonservices quarkus-amazon-crt-client-internal @@ -81,17 +75,6 @@ http-auth-aws-crt true - - software.amazon.awssdk - apache-client - true - - - commons-logging - commons-logging - - - io.quarkiverse.amazonservices quarkus-amazon-apache-client-internal diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java b/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientBuilderRecorder.java similarity index 60% rename from common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java rename to common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientBuilderRecorder.java index ec38ab44c..1b61c565c 100644 --- a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientRecorder.java +++ b/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientBuilderRecorder.java @@ -4,57 +4,36 @@ import io.quarkus.runtime.LaunchMode; import io.quarkus.runtime.RuntimeValue; +import io.quarkus.runtime.annotations.Recorder; import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder; import software.amazon.awssdk.awscore.presigner.SdkPresigner; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; -import software.amazon.awssdk.http.SdkHttpClient.Builder; +import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.async.SdkAsyncHttpClient; -public abstract class AmazonClientRecorder { - - public abstract RuntimeValue getAmazonClientsConfig(); - - public abstract AsyncHttpClientConfig getAsyncClientConfig(); - - public abstract SyncHttpClientConfig getSyncClientConfig(); - - public abstract AwsSyncClientBuilder geSyncClientBuilder(); - - public abstract AwsAsyncClientBuilder getAsyncClientBuilder(); - - public RuntimeValue getSyncConfig() { - return new RuntimeValue<>(getSyncClientConfig()); - } - - public RuntimeValue getAsyncConfig() { - return new RuntimeValue<>(getAsyncClientConfig()); - } - - public RuntimeValue createSyncBuilder(RuntimeValue transport) { - AwsSyncClientBuilder builder = geSyncClientBuilder(); +@Recorder +public class AmazonClientBuilderRecorder { + public RuntimeValue createSyncBuilder(RuntimeValue> builder, + RuntimeValue transport) { if (transport != null) { - builder.httpClientBuilder(transport.getValue()); + builder.getValue().httpClientBuilder(transport.getValue()); } - - return new RuntimeValue<>((AwsClientBuilder) builder); + return new RuntimeValue<>((AwsClientBuilder) builder.getValue()); } - public RuntimeValue createAsyncBuilder(RuntimeValue transport, - LaunchMode launchMode, - Executor executor) { - AwsAsyncClientBuilder builder = getAsyncClientBuilder(); - AsyncHttpClientConfig config = getAsyncClientConfig(); - + public RuntimeValue createAsyncBuilder(RuntimeValue> builder, + RuntimeValue transport, + LaunchMode launchMode, Executor executor, RuntimeValue config) { if (transport != null) { - builder.httpClientBuilder(transport.getValue()); + builder.getValue().httpClientBuilder(transport.getValue()); } Executor configExecutor; - if (!config.advanced().useFutureCompletionThreadPool()) { + if (!config.getValue().advanced().useFutureCompletionThreadPool()) { configExecutor = Runnable::run; } else { configExecutor = executor; @@ -66,10 +45,10 @@ public RuntimeValue createAsyncBuilder(RuntimeValue asyncConfigBuilder + builder.getValue().asyncConfiguration(asyncConfigBuilder -> asyncConfigBuilder .advancedOption(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR, futureCompletionExecutor)); - return new RuntimeValue<>((AwsClientBuilder) builder); + return new RuntimeValue<>((AwsClientBuilder) builder.getValue()); } public RuntimeValue createPresignerBuilder() { diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientOpenTelemetryRecorder.java b/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientOpenTelemetryRecorder.java index deb3c6e60..b3f51e8bc 100644 --- a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientOpenTelemetryRecorder.java +++ b/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/AmazonClientOpenTelemetryRecorder.java @@ -10,8 +10,7 @@ @Recorder public class AmazonClientOpenTelemetryRecorder { - - public Function, AwsClientBuilder> configureSync( + public Function, AwsClientBuilder> configure( RuntimeValue clientBuilder) { return new Function, AwsClientBuilder>() { @Override @@ -24,36 +23,8 @@ public AwsClientBuilder apply(SyntheticCreationalContext conte .addExecutionInterceptor(awsSdkTelemetry.newExecutionInterceptor()) .build()); - return wrapSyncClientBuilder(builder, new RuntimeValue<>(awsSdkTelemetry)); + return builder; } }; } - - public Function, AwsClientBuilder> configureAsync( - RuntimeValue clientBuilder) { - return new Function, AwsClientBuilder>() { - @Override - public AwsClientBuilder apply(SyntheticCreationalContext context) { - AwsClientBuilder builder = clientBuilder.getValue(); - AwsSdkTelemetry awsSdkTelemetry = context.getInjectedReference(AwsSdkTelemetry.class); - - builder.overrideConfiguration( - builder.overrideConfiguration().toBuilder() - .addExecutionInterceptor(awsSdkTelemetry.newExecutionInterceptor()) - .build()); - - return wrapAsyncClientBuilder(builder, new RuntimeValue<>(awsSdkTelemetry)); - } - }; - } - - protected AwsClientBuilder wrapSyncClientBuilder(AwsClientBuilder clientBuilder, - RuntimeValue awsSdkTelemetry) { - return clientBuilder; - }; - - protected AwsClientBuilder wrapAsyncClientBuilder(AwsClientBuilder clientBuilder, - RuntimeValue awsSdkTelemetry) { - return clientBuilder; - }; } diff --git a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/CrtSubstitutions.java b/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/CrtSubstitutions.java index a92246fe6..e2c6728b4 100644 --- a/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/CrtSubstitutions.java +++ b/common/runtime/src/main/java/io/quarkiverse/amazon/common/runtime/CrtSubstitutions.java @@ -14,7 +14,6 @@ import software.amazon.awssdk.checksums.internal.CrcCloneOnMarkChecksum; import software.amazon.awssdk.checksums.internal.CrcCombineOnMarkChecksum; import software.amazon.awssdk.checksums.internal.SdkCrc32CChecksum; -import software.amazon.awssdk.crt.checksums.CRC64NVME; import software.amazon.awssdk.http.auth.aws.crt.internal.signer.DefaultAwsCrtV4aHttpSigner; import software.amazon.awssdk.http.auth.aws.signer.AwsV4aHttpSigner; diff --git a/dynamodb-enhanced/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/enhanced/deployment/DynamodbEnhancedProcessor.java b/dynamodb-enhanced/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/enhanced/deployment/DynamodbEnhancedProcessor.java index aae44dace..d54e45b58 100644 --- a/dynamodb-enhanced/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/enhanced/deployment/DynamodbEnhancedProcessor.java +++ b/dynamodb-enhanced/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/enhanced/deployment/DynamodbEnhancedProcessor.java @@ -86,7 +86,8 @@ void setup(CombinedIndexBuildItem combinedIndexBuildItem, for (var extension : extensions.get()) { if (!knownDynamodbEnhancedClientExtensionImpls.contains(extension)) { throw new ConfigurationException( - "quarkus.dynamodbenhanced.client-extensions - must list only existing implementations of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension"); + "quarkus.dynamodbenhanced.client-extensions - must list only existing implementations of software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension ('" + + extension + "')"); } } } diff --git a/dynamodb/deployment/pom.xml b/dynamodb/deployment/pom.xml index 5eb2f34ce..126bf1d87 100644 --- a/dynamodb/deployment/pom.xml +++ b/dynamodb/deployment/pom.xml @@ -61,6 +61,13 @@ aws-crt-client test + + + io.quarkiverse.amazonservices + quarkus-amazon-crt-client-internal-deployment + test + software.amazon.awssdk url-connection-client @@ -71,6 +78,13 @@ apache-client test + + + io.quarkiverse.amazonservices + quarkus-amazon-apache-client-internal-deployment + test + diff --git a/dynamodb/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/deployment/DynamodbProcessor.java b/dynamodb/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/deployment/DynamodbProcessor.java index 066def0b9..3232f01f8 100644 --- a/dynamodb/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/deployment/DynamodbProcessor.java +++ b/dynamodb/deployment/src/main/java/io/quarkiverse/amazon/dynamodb/deployment/DynamodbProcessor.java @@ -1,40 +1,17 @@ package io.quarkiverse.amazon.dynamodb.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.dynamodb.runtime.DynamodbBuildTimeConfig; import io.quarkiverse.amazon.dynamodb.runtime.DynamodbRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; -import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient; import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientBuilder; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; @@ -62,159 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(DynamoDbAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return DynamoDbClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/dynamodb/execution.interceptors"; - } - - @BuildStep - void runtimeInitialize(BuildProducer producer) { - // This class triggers initialization of FullJitterBackoffStragegy so needs to get runtime-initialized - // as well - producer.produce( - new RuntimeInitializedClassBuildItem("software.amazon.awssdk.services.dynamodb.DynamoDbRetryPolicy")); + protected DotName asyncClientName() { + return DotName.createSimple(DynamoDbAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return DynamoDbAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/dynamodb/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, DynamodbRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, DynamodbRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, + void setup( DynamodbRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, DynamodbRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } + BuildProducer amazonExtensions) { - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, DynamodbRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } - - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(DynamodbRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - DynamoDbClientBuilder.class, - DynamoDbAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/dynamodb/runtime/src/main/java/io/quarkiverse/amazon/dynamodb/runtime/DynamodbBuildTimeConfig.java b/dynamodb/runtime/src/main/java/io/quarkiverse/amazon/dynamodb/runtime/DynamodbBuildTimeConfig.java index 7d8a801cd..8ac96852a 100644 --- a/dynamodb/runtime/src/main/java/io/quarkiverse/amazon/dynamodb/runtime/DynamodbBuildTimeConfig.java +++ b/dynamodb/runtime/src/main/java/io/quarkiverse/amazon/dynamodb/runtime/DynamodbBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.dynamodb.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.dynamodb") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface DynamodbBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Dynamodb client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Dynamodb client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface DynamodbBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/ecr/deployment/src/main/java/io/quarkiverse/amazon/ecr/deployment/EcrProcessor.java b/ecr/deployment/src/main/java/io/quarkiverse/amazon/ecr/deployment/EcrProcessor.java index ee7fcb9a7..4018768cf 100644 --- a/ecr/deployment/src/main/java/io/quarkiverse/amazon/ecr/deployment/EcrProcessor.java +++ b/ecr/deployment/src/main/java/io/quarkiverse/amazon/ecr/deployment/EcrProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.ecr.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.ecr.runtime.EcrBuildTimeConfig; import io.quarkiverse.amazon.ecr.runtime.EcrRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.ecr.EcrAsyncClient; import software.amazon.awssdk.services.ecr.EcrAsyncClientBuilder; import software.amazon.awssdk.services.ecr.EcrClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(EcrAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return EcrClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/ecr/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(EcrAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return EcrAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/ecr/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, EcrRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, EcrRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, EcrRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, EcrRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, EcrRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + EcrRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(EcrRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - EcrClientBuilder.class, - EcrAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/ecr/runtime/src/main/java/io/quarkiverse/amazon/ecr/runtime/EcrBuildTimeConfig.java b/ecr/runtime/src/main/java/io/quarkiverse/amazon/ecr/runtime/EcrBuildTimeConfig.java index fa1200640..0c075e0de 100644 --- a/ecr/runtime/src/main/java/io/quarkiverse/amazon/ecr/runtime/EcrBuildTimeConfig.java +++ b/ecr/runtime/src/main/java/io/quarkiverse/amazon/ecr/runtime/EcrBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.ecr.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.ecr") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface EcrBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon ECR client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon ECR client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface EcrBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/elasticloadbalancing/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/deployment/ElasticLoadBalancingProcessor.java b/elasticloadbalancing/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/deployment/ElasticLoadBalancingProcessor.java index 26786c440..bd88fb4ea 100644 --- a/elasticloadbalancing/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/deployment/ElasticLoadBalancingProcessor.java +++ b/elasticloadbalancing/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/deployment/ElasticLoadBalancingProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.elasticloadbalancing.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.elasticloadbalancing.runtime.ElasticLoadBalancingBuildTimeConfig; import io.quarkiverse.amazon.elasticloadbalancing.runtime.ElasticLoadBalancingRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.elasticloadbalancing.ElasticLoadBalancingAsyncClient; import software.amazon.awssdk.services.elasticloadbalancing.ElasticLoadBalancingAsyncClientBuilder; import software.amazon.awssdk.services.elasticloadbalancing.ElasticLoadBalancingClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(ElasticLoadBalancingAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return ElasticLoadBalancingClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/elasticloadbalancing/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(ElasticLoadBalancingAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return ElasticLoadBalancingAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/elasticloadbalancing/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - ElasticLoadBalancingRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - ElasticLoadBalancingRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - ElasticLoadBalancingRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - ElasticLoadBalancingRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( ElasticLoadBalancingRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(ElasticLoadBalancingRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - ElasticLoadBalancingClientBuilder.class, - ElasticLoadBalancingAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/elasticloadbalancing/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/runtime/ElasticLoadBalancingBuildTimeConfig.java b/elasticloadbalancing/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/runtime/ElasticLoadBalancingBuildTimeConfig.java index 57f7ffdeb..d8292a995 100644 --- a/elasticloadbalancing/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/runtime/ElasticLoadBalancingBuildTimeConfig.java +++ b/elasticloadbalancing/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancing/runtime/ElasticLoadBalancingBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.elasticloadbalancing.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.elasticloadbalancing") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface ElasticLoadBalancingBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Elastic Load Balancer client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Elastic Load Balancer client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface ElasticLoadBalancingBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/elasticloadbalancingv2/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/deployment/ElasticLoadBalancingV2Processor.java b/elasticloadbalancingv2/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/deployment/ElasticLoadBalancingV2Processor.java index ef178344d..687dc5261 100644 --- a/elasticloadbalancingv2/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/deployment/ElasticLoadBalancingV2Processor.java +++ b/elasticloadbalancingv2/deployment/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/deployment/ElasticLoadBalancingV2Processor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.elasticloadbalancingv2.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.elasticloadbalancingv2.runtime.ElasticLoadBalancingV2BuildTimeConfig; import io.quarkiverse.amazon.elasticloadbalancingv2.runtime.ElasticLoadBalancingV2Recorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2AsyncClient; import software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2AsyncClientBuilder; import software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2Client; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(ElasticLoadBalancingV2AsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return ElasticLoadBalancingV2ClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/elasticloadbalancingv2/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(ElasticLoadBalancingV2AsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return ElasticLoadBalancingV2AsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/elasticloadbalancingv2/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - ElasticLoadBalancingV2Recorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - ElasticLoadBalancingV2Recorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - ElasticLoadBalancingV2Recorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - ElasticLoadBalancingV2Recorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( ElasticLoadBalancingV2Recorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(ElasticLoadBalancingV2Recorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - ElasticLoadBalancingV2ClientBuilder.class, - ElasticLoadBalancingV2AsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/elasticloadbalancingv2/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/runtime/ElasticLoadBalancingV2BuildTimeConfig.java b/elasticloadbalancingv2/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/runtime/ElasticLoadBalancingV2BuildTimeConfig.java index 68350ec82..d53d839db 100644 --- a/elasticloadbalancingv2/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/runtime/ElasticLoadBalancingV2BuildTimeConfig.java +++ b/elasticloadbalancingv2/runtime/src/main/java/io/quarkiverse/amazon/elasticloadbalancingv2/runtime/ElasticLoadBalancingV2BuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.elasticloadbalancingv2.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.elasticloadbalancingv2") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface ElasticLoadBalancingV2BuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Elastic Load Balancer v2 client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Elastic Load Balancer v2 client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface ElasticLoadBalancingV2BuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/eventbridge/deployment/src/main/java/io/quarkiverse/amazon/eventbridge/deployment/EventBridgeProcessor.java b/eventbridge/deployment/src/main/java/io/quarkiverse/amazon/eventbridge/deployment/EventBridgeProcessor.java index 83987d427..f3bb8b4b6 100644 --- a/eventbridge/deployment/src/main/java/io/quarkiverse/amazon/eventbridge/deployment/EventBridgeProcessor.java +++ b/eventbridge/deployment/src/main/java/io/quarkiverse/amazon/eventbridge/deployment/EventBridgeProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.eventbridge.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.eventbridge.runtime.EventBridgeBuildTimeConfig; import io.quarkiverse.amazon.eventbridge.runtime.EventBridgeRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.eventbridge.EventBridgeAsyncClient; import software.amazon.awssdk.services.eventbridge.EventBridgeAsyncClientBuilder; import software.amazon.awssdk.services.eventbridge.EventBridgeClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(EventBridgeAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return EventBridgeClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/eventbridge/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(EventBridgeAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return EventBridgeAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/eventbridge/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - EventBridgeRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - EventBridgeRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - EventBridgeRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - EventBridgeRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( EventBridgeRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(EventBridgeRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - EventBridgeClientBuilder.class, - EventBridgeAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/eventbridge/runtime/src/main/java/io/quarkiverse/amazon/eventbridge/runtime/EventBridgeBuildTimeConfig.java b/eventbridge/runtime/src/main/java/io/quarkiverse/amazon/eventbridge/runtime/EventBridgeBuildTimeConfig.java index fdbd2694c..514cb0f04 100644 --- a/eventbridge/runtime/src/main/java/io/quarkiverse/amazon/eventbridge/runtime/EventBridgeBuildTimeConfig.java +++ b/eventbridge/runtime/src/main/java/io/quarkiverse/amazon/eventbridge/runtime/EventBridgeBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.eventbridge.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.eventbridge") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface EventBridgeBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon EventBridge client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon EventBridge client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface EventBridgeBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/iam/deployment/src/main/java/io/quarkiverse/amazon/iam/deployment/IamProcessor.java b/iam/deployment/src/main/java/io/quarkiverse/amazon/iam/deployment/IamProcessor.java index f5def42e8..5e8447a46 100644 --- a/iam/deployment/src/main/java/io/quarkiverse/amazon/iam/deployment/IamProcessor.java +++ b/iam/deployment/src/main/java/io/quarkiverse/amazon/iam/deployment/IamProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.iam.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.iam.runtime.IamBuildTimeConfig; import io.quarkiverse.amazon.iam.runtime.IamRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.iam.IamAsyncClient; import software.amazon.awssdk.services.iam.IamAsyncClientBuilder; import software.amazon.awssdk.services.iam.IamClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(IamAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return IamClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/iam/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(IamAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return IamAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/iam/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, IamRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, IamRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, IamRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, IamRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, IamRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + IamRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(IamRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - IamClientBuilder.class, - IamAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/iam/runtime/src/main/java/io/quarkiverse/amazon/iam/runtime/IamBuildTimeConfig.java b/iam/runtime/src/main/java/io/quarkiverse/amazon/iam/runtime/IamBuildTimeConfig.java index 3b774aa2b..6b4e98a56 100644 --- a/iam/runtime/src/main/java/io/quarkiverse/amazon/iam/runtime/IamBuildTimeConfig.java +++ b/iam/runtime/src/main/java/io/quarkiverse/amazon/iam/runtime/IamBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.iam.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.iam") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface IamBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon IAM client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon IAM client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface IamBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/inspector/deployment/src/main/java/io/quarkiverse/amazon/inspector/deployment/InspectorProcessor.java b/inspector/deployment/src/main/java/io/quarkiverse/amazon/inspector/deployment/InspectorProcessor.java index 115c395ce..e95994ab4 100644 --- a/inspector/deployment/src/main/java/io/quarkiverse/amazon/inspector/deployment/InspectorProcessor.java +++ b/inspector/deployment/src/main/java/io/quarkiverse/amazon/inspector/deployment/InspectorProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.inspector.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.inspector.runtime.InspectorBuildTimeConfig; import io.quarkiverse.amazon.inspector.runtime.InspectorRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.inspector.InspectorAsyncClient; import software.amazon.awssdk.services.inspector.InspectorAsyncClientBuilder; import software.amazon.awssdk.services.inspector.InspectorClient; @@ -61,151 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(InspectorAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return InspectorClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/inspector/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(InspectorAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return InspectorAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/inspector/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, InspectorRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, InspectorRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, + void setup( InspectorRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, InspectorRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } + BuildProducer amazonExtensions) { - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, InspectorRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } - - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(InspectorRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - InspectorClientBuilder.class, - InspectorAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/inspector/runtime/src/main/java/io/quarkiverse/amazon/inspector/runtime/InspectorBuildTimeConfig.java b/inspector/runtime/src/main/java/io/quarkiverse/amazon/inspector/runtime/InspectorBuildTimeConfig.java index 0260d0c46..9bc72d811 100644 --- a/inspector/runtime/src/main/java/io/quarkiverse/amazon/inspector/runtime/InspectorBuildTimeConfig.java +++ b/inspector/runtime/src/main/java/io/quarkiverse/amazon/inspector/runtime/InspectorBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.inspector.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.inspector") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface InspectorBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Inspector client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Inspector client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface InspectorBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/inspector2/deployment/src/main/java/io/quarkiverse/amazon/inspector2/deployment/Inspector2Processor.java b/inspector2/deployment/src/main/java/io/quarkiverse/amazon/inspector2/deployment/Inspector2Processor.java index 0a7cb6efc..dcb8f13aa 100644 --- a/inspector2/deployment/src/main/java/io/quarkiverse/amazon/inspector2/deployment/Inspector2Processor.java +++ b/inspector2/deployment/src/main/java/io/quarkiverse/amazon/inspector2/deployment/Inspector2Processor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.inspector2.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.inspector2.runtime.Inspector2BuildTimeConfig; import io.quarkiverse.amazon.inspector2.runtime.Inspector2Recorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.inspector2.Inspector2AsyncClient; import software.amazon.awssdk.services.inspector2.Inspector2AsyncClientBuilder; import software.amazon.awssdk.services.inspector2.Inspector2Client; @@ -61,152 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(Inspector2AsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return Inspector2ClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/inspector2/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(Inspector2AsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return Inspector2AsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/inspector2/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, Inspector2Recorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, Inspector2Recorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - Inspector2Recorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, Inspector2Recorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( Inspector2Recorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(Inspector2Recorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - Inspector2ClientBuilder.class, - Inspector2AsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/inspector2/runtime/src/main/java/io/quarkiverse/amazon/inspector2/runtime/Inspector2BuildTimeConfig.java b/inspector2/runtime/src/main/java/io/quarkiverse/amazon/inspector2/runtime/Inspector2BuildTimeConfig.java index a928db3d8..bc129e56e 100644 --- a/inspector2/runtime/src/main/java/io/quarkiverse/amazon/inspector2/runtime/Inspector2BuildTimeConfig.java +++ b/inspector2/runtime/src/main/java/io/quarkiverse/amazon/inspector2/runtime/Inspector2BuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.inspector2.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.inspector2") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface Inspector2BuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Inspector2 client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Inspector2 client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface Inspector2BuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/integration-tests/src/main/resources/application.properties b/integration-tests/src/main/resources/application.properties index e0e34f6fa..70fe2c94d 100644 --- a/integration-tests/src/main/resources/application.properties +++ b/integration-tests/src/main/resources/application.properties @@ -48,6 +48,7 @@ quarkus.ssm.async-client.type=${async-client.type} quarkus.sts.async-client.type=${async-client.type} quarkus.s3.telemetry.enabled=true +quarkus.sqs.telemetry.enabled=true quarkus.iam.custom.aws.credentials.type=static quarkus.iam.custom.aws.credentials.static-provider.access-key-id=112233445566 diff --git a/kinesis/deployment/src/main/java/io/quarkiverse/amazon/kinesis/deployment/KinesisProcessor.java b/kinesis/deployment/src/main/java/io/quarkiverse/amazon/kinesis/deployment/KinesisProcessor.java index 578fb36c9..95c437442 100644 --- a/kinesis/deployment/src/main/java/io/quarkiverse/amazon/kinesis/deployment/KinesisProcessor.java +++ b/kinesis/deployment/src/main/java/io/quarkiverse/amazon/kinesis/deployment/KinesisProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.kinesis.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.kinesis.runtime.KinesisBuildTimeConfig; import io.quarkiverse.amazon.kinesis.runtime.KinesisRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.kinesis.KinesisAsyncClient; import software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder; import software.amazon.awssdk.services.kinesis.KinesisClient; @@ -61,151 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(KinesisAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return KinesisClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/kinesis/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(KinesisAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return KinesisAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/kinesis/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, KinesisRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, KinesisRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, + void setup( KinesisRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, KinesisRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } + BuildProducer amazonExtensions) { - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, KinesisRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } - - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(KinesisRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - KinesisClientBuilder.class, - KinesisAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/kinesis/runtime/src/main/java/io/quarkiverse/amazon/kinesis/runtime/KinesisBuildTimeConfig.java b/kinesis/runtime/src/main/java/io/quarkiverse/amazon/kinesis/runtime/KinesisBuildTimeConfig.java index 3e219c01f..197c821c4 100644 --- a/kinesis/runtime/src/main/java/io/quarkiverse/amazon/kinesis/runtime/KinesisBuildTimeConfig.java +++ b/kinesis/runtime/src/main/java/io/quarkiverse/amazon/kinesis/runtime/KinesisBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.kinesis.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.kinesis") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface KinesisBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Kinesis client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Kinesis client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface KinesisBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/kms/deployment/src/main/java/io/quarkiverse/amazon/kms/deployment/KmsProcessor.java b/kms/deployment/src/main/java/io/quarkiverse/amazon/kms/deployment/KmsProcessor.java index 78e8e1a57..3cd06fbc6 100644 --- a/kms/deployment/src/main/java/io/quarkiverse/amazon/kms/deployment/KmsProcessor.java +++ b/kms/deployment/src/main/java/io/quarkiverse/amazon/kms/deployment/KmsProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.kms.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.kms.runtime.KmsBuildTimeConfig; import io.quarkiverse.amazon.kms.runtime.KmsRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.kms.KmsAsyncClient; import software.amazon.awssdk.services.kms.KmsAsyncClientBuilder; import software.amazon.awssdk.services.kms.KmsClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(KmsAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return KmsClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/kms/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(KmsAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return KmsAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/kms/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, KmsRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, KmsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, KmsRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, KmsRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, KmsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + KmsRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(KmsRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - KmsClientBuilder.class, - KmsAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/kms/runtime/src/main/java/io/quarkiverse/amazon/kms/runtime/KmsBuildTimeConfig.java b/kms/runtime/src/main/java/io/quarkiverse/amazon/kms/runtime/KmsBuildTimeConfig.java index fa9454b2f..4a231c639 100644 --- a/kms/runtime/src/main/java/io/quarkiverse/amazon/kms/runtime/KmsBuildTimeConfig.java +++ b/kms/runtime/src/main/java/io/quarkiverse/amazon/kms/runtime/KmsBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.kms.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.kms") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface KmsBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon KMS client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon KMS client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface KmsBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/lambda/deployment/src/main/java/io/quarkiverse/amazon/lambda/deployment/LambdaProcessor.java b/lambda/deployment/src/main/java/io/quarkiverse/amazon/lambda/deployment/LambdaProcessor.java index e18ef4bf5..661e39f57 100644 --- a/lambda/deployment/src/main/java/io/quarkiverse/amazon/lambda/deployment/LambdaProcessor.java +++ b/lambda/deployment/src/main/java/io/quarkiverse/amazon/lambda/deployment/LambdaProcessor.java @@ -1,40 +1,17 @@ package io.quarkiverse.amazon.lambda.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.lambda.runtime.LambdaBuildTimeConfig; -import io.quarkiverse.amazon.lambda.runtime.LambdaConfig; import io.quarkiverse.amazon.lambda.runtime.LambdaRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.lambda.LambdaAsyncClient; import software.amazon.awssdk.services.lambda.LambdaAsyncClientBuilder; import software.amazon.awssdk.services.lambda.LambdaClient; @@ -61,167 +38,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(LambdaAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return LambdaClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/lambda/execution.interceptors"; - } - - @BuildStep - void setup( - final BuildProducer extensionSslNativeSupport, - final BuildProducer feature, - final BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); - } - - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); - } - - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); - } - - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); - } - - @BuildStep - void setupClient( - final List clientRequirements, - final BuildProducer clientProducer) { - - setupClient( - clientRequirements, - clientProducer, - buildTimeConfig.sdk(), - buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport( - final List amazonClients, - final LambdaRecorder recorder, - final AmazonClientApacheTransportRecorder transportRecorder, - final BuildProducer syncTransports) { - - createApacheSyncTransportBuilder( - amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); + protected DotName asyncClientName() { + return DotName.createSimple(LambdaAsyncClient.class.getName()); } - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, LambdaRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); + @Override + protected Class asyncClientBuilderClass() { + return LambdaAsyncClientBuilder.class; } - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport( - final List amazonClients, - final LambdaRecorder recorder, - final AmazonClientUrlConnectionTransportRecorder transportRecorder, - final BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder( - amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/lambda/execution.interceptors"; } - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport( - final List amazonClients, - final LambdaRecorder recorder, - final AmazonClientNettyTransportRecorder transportRecorder, - final LambdaConfig runtimeConfig, - final BuildProducer asyncTransports, - final EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder( - amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, - eventLoopSupplier.getMainEventLoopGroup()); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(final List amazonClients, - final LambdaRecorder recorder, - final AmazonClientAwsCrtTransportRecorder transportRecorder, - final BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(LambdaRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { + void setup( + LambdaRecorder recorder, + BuildProducer amazonExtensions) { - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - LambdaClientBuilder.class, - LambdaAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/lambda/runtime/src/main/java/io/quarkiverse/amazon/lambda/runtime/LambdaBuildTimeConfig.java b/lambda/runtime/src/main/java/io/quarkiverse/amazon/lambda/runtime/LambdaBuildTimeConfig.java index 1df41d56a..603263e7f 100644 --- a/lambda/runtime/src/main/java/io/quarkiverse/amazon/lambda/runtime/LambdaBuildTimeConfig.java +++ b/lambda/runtime/src/main/java/io/quarkiverse/amazon/lambda/runtime/LambdaBuildTimeConfig.java @@ -1,22 +1,17 @@ package io.quarkiverse.amazon.lambda.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; -/** Amazon LAMBDA build time configuration */ +/** + * Amazon LAMBDA build time configuration + */ @ConfigMapping(prefix = "quarkus.lambda") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface LambdaBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** Sync HTTP transport configuration for Amazon LAMBDA client */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** Async HTTP transport configuration for Amazon LAMBDA client */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface LambdaBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/neptune/deployment/src/main/java/io/quarkiverse/amazon/neptune/deployment/NeptuneProcessor.java b/neptune/deployment/src/main/java/io/quarkiverse/amazon/neptune/deployment/NeptuneProcessor.java index 47703a8fe..caf156531 100644 --- a/neptune/deployment/src/main/java/io/quarkiverse/amazon/neptune/deployment/NeptuneProcessor.java +++ b/neptune/deployment/src/main/java/io/quarkiverse/amazon/neptune/deployment/NeptuneProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.neptune.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.neptune.runtime.NeptuneBuildTimeConfig; import io.quarkiverse.amazon.neptune.runtime.NeptuneRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.neptune.NeptuneAsyncClient; import software.amazon.awssdk.services.neptune.NeptuneAsyncClientBuilder; import software.amazon.awssdk.services.neptune.NeptuneClient; @@ -61,151 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(NeptuneAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return NeptuneClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/neptune/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(NeptuneAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return NeptuneAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/neptune/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, NeptuneRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, NeptuneRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, + void setup( NeptuneRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, NeptuneRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } + BuildProducer amazonExtensions) { - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, NeptuneRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } - - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(NeptuneRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - NeptuneClientBuilder.class, - NeptuneAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/neptune/runtime/src/main/java/io/quarkiverse/amazon/neptune/runtime/NeptuneBuildTimeConfig.java b/neptune/runtime/src/main/java/io/quarkiverse/amazon/neptune/runtime/NeptuneBuildTimeConfig.java index ad67cb4e3..29bcaeb11 100644 --- a/neptune/runtime/src/main/java/io/quarkiverse/amazon/neptune/runtime/NeptuneBuildTimeConfig.java +++ b/neptune/runtime/src/main/java/io/quarkiverse/amazon/neptune/runtime/NeptuneBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.neptune.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.neptune") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface NeptuneBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Neptune client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Neptune client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface NeptuneBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/paymentcryptography/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptography/deployment/PaymentCryptographyProcessor.java b/paymentcryptography/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptography/deployment/PaymentCryptographyProcessor.java index 99b5029b1..b7e12f488 100644 --- a/paymentcryptography/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptography/deployment/PaymentCryptographyProcessor.java +++ b/paymentcryptography/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptography/deployment/PaymentCryptographyProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.paymentcryptography.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.paymentcryptography.runtime.PaymentCryptographyBuildTimeConfig; import io.quarkiverse.amazon.paymentcryptography.runtime.PaymentCryptographyRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.paymentcryptography.PaymentCryptographyAsyncClient; import software.amazon.awssdk.services.paymentcryptography.PaymentCryptographyAsyncClientBuilder; import software.amazon.awssdk.services.paymentcryptography.PaymentCryptographyClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(PaymentCryptographyAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return PaymentCryptographyClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/paymentcryptography/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(PaymentCryptographyAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return PaymentCryptographyAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/paymentcryptography/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - PaymentCryptographyRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - PaymentCryptographyRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - PaymentCryptographyRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - PaymentCryptographyRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( PaymentCryptographyRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(PaymentCryptographyRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - PaymentCryptographyClientBuilder.class, - PaymentCryptographyAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/paymentcryptography/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptography/runtime/PaymentCryptographyBuildTimeConfig.java b/paymentcryptography/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptography/runtime/PaymentCryptographyBuildTimeConfig.java index 58a9f2d4c..fc180bdfe 100644 --- a/paymentcryptography/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptography/runtime/PaymentCryptographyBuildTimeConfig.java +++ b/paymentcryptography/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptography/runtime/PaymentCryptographyBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.paymentcryptography.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.paymentcryptography") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface PaymentCryptographyBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Payment Cryptography client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Payment Cryptography client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface PaymentCryptographyBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/paymentcryptographydata/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/deployment/PaymentCryptographyDataProcessor.java b/paymentcryptographydata/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/deployment/PaymentCryptographyDataProcessor.java index 687fe6ba3..a2cc64966 100644 --- a/paymentcryptographydata/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/deployment/PaymentCryptographyDataProcessor.java +++ b/paymentcryptographydata/deployment/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/deployment/PaymentCryptographyDataProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.paymentcryptographydata.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.paymentcryptographydata.runtime.PaymentCryptographyDataBuildTimeConfig; import io.quarkiverse.amazon.paymentcryptographydata.runtime.PaymentCryptographyDataRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.paymentcryptographydata.PaymentCryptographyDataAsyncClient; import software.amazon.awssdk.services.paymentcryptographydata.PaymentCryptographyDataAsyncClientBuilder; import software.amazon.awssdk.services.paymentcryptographydata.PaymentCryptographyDataClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(PaymentCryptographyDataAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return PaymentCryptographyDataClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/paymentcryptographydata/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(PaymentCryptographyDataAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return PaymentCryptographyDataAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/paymentcryptographydata/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - PaymentCryptographyDataRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - PaymentCryptographyDataRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - PaymentCryptographyDataRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - PaymentCryptographyDataRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( PaymentCryptographyDataRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(PaymentCryptographyDataRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - PaymentCryptographyDataClientBuilder.class, - PaymentCryptographyDataAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/paymentcryptographydata/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/runtime/PaymentCryptographyDataBuildTimeConfig.java b/paymentcryptographydata/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/runtime/PaymentCryptographyDataBuildTimeConfig.java index 16106893c..3737a3f3f 100644 --- a/paymentcryptographydata/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/runtime/PaymentCryptographyDataBuildTimeConfig.java +++ b/paymentcryptographydata/runtime/src/main/java/io/quarkiverse/amazon/paymentcryptographydata/runtime/PaymentCryptographyDataBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.paymentcryptographydata.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.paymentcryptographydata") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface PaymentCryptographyDataBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Payment Cryptography Data client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Payment Cryptography Data client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface PaymentCryptographyDataBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3CrtProcessor.java b/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3CrtProcessor.java index c01270e71..f6a4d5ac8 100644 --- a/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3CrtProcessor.java +++ b/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3CrtProcessor.java @@ -24,6 +24,7 @@ import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.arc.processor.DotNames; import io.quarkus.arc.processor.InjectionPointInfo; +import io.quarkus.bootstrap.classloading.QuarkusClassLoader; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; @@ -164,12 +165,7 @@ private Type getInjectedType(InjectionPointInfo injectionPoint) { public static class IsAmazonCrtS3ClientPresent implements BooleanSupplier { @Override public boolean getAsBoolean() { - try { - Class.forName(AWS_S3_CRT); - return true; - } catch (Exception e) { - return false; - } + return QuarkusClassLoader.isClassPresentAtRuntime(AWS_S3_CRT); } } } diff --git a/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3Processor.java b/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3Processor.java index acb4a032b..9374e96ca 100644 --- a/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3Processor.java +++ b/s3/deployment/src/main/java/io/quarkiverse/amazon/s3/deployment/S3Processor.java @@ -1,40 +1,17 @@ package io.quarkiverse.amazon.s3.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.s3.runtime.S3BuildTimeConfig; -import io.quarkiverse.amazon.s3.runtime.S3Config; import io.quarkiverse.amazon.s3.runtime.S3Recorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.s3.S3AsyncClient; import software.amazon.awssdk.services.s3.S3AsyncClientBuilder; import software.amazon.awssdk.services.s3.S3Client; @@ -62,156 +39,52 @@ protected DotName syncClientName() { return DotName.createSimple(S3Client.class.getName()); } + @Override + protected Class syncClientBuilderClass() { + return S3ClientBuilder.class; + } + @Override protected DotName asyncClientName() { return DotName.createSimple(S3AsyncClient.class.getName()); } @Override - protected DotName presignerClientName() { - return DotName.createSimple(S3Presigner.class.getName()); + protected Class asyncClientBuilderClass() { + return S3AsyncClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/s3/execution.interceptors"; + protected DotName presignerClientName() { + return DotName.createSimple(S3Presigner.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class presignerBuilderClass() { + return S3Presigner.Builder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/s3/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, S3Recorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, S3Recorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, S3Recorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, S3Recorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - S3Config runtimeConfig, BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, S3Recorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + S3Recorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(S3Recorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - S3ClientBuilder.class, - S3AsyncClientBuilder.class, - S3Presigner.Builder.class, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/s3/deployment/src/test/java/io/quarkiverse/amazon/s3/deployment/S3AsyncClientFullConfigTest.java b/s3/deployment/src/test/java/io/quarkiverse/amazon/s3/deployment/S3AsyncClientFullConfigTest.java new file mode 100644 index 000000000..1e10450f2 --- /dev/null +++ b/s3/deployment/src/test/java/io/quarkiverse/amazon/s3/deployment/S3AsyncClientFullConfigTest.java @@ -0,0 +1,45 @@ +package io.quarkiverse.amazon.s3.deployment; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import jakarta.enterprise.inject.Any; +import jakarta.enterprise.inject.Instance; +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkiverse.amazon.common.AmazonClient; +import io.quarkus.test.QuarkusUnitTest; +import software.amazon.awssdk.services.s3.S3AsyncClient; +import software.amazon.awssdk.services.s3.S3AsyncClientBuilder; + +public class S3AsyncClientFullConfigTest { + + @Inject + Instance client; + + @Inject + @AmazonClient("custom") + Instance clientCustom; + + @Inject + @Any + Instance builder; + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addAsResource("async-netty-full-config.properties", "application.properties")); + + @Test + public void test() { + //assertNotNull(client.get()); + assertNotNull(clientCustom.get()); + + // should finish with success + client.get().close(); + clientCustom.get().close(); + + } +} diff --git a/s3/deployment/src/test/resources/async-netty-full-config.properties b/s3/deployment/src/test/resources/async-netty-full-config.properties new file mode 100644 index 000000000..0fe12f4c0 --- /dev/null +++ b/s3/deployment/src/test/resources/async-netty-full-config.properties @@ -0,0 +1,16 @@ +quarkus.s3.accelerate-mode=false +quarkus.s3.checksum-validation=true +quarkus.s3.chunked-encoding=true +quarkus.s3.dualstack=false +quarkus.s3.path-style-access=false +quarkus.s3.use-arn-region-enabled=true +#quarkus.s3.profile-name=foo + +quarkus.s3.endpoint-override=http://localhost:9090 + +quarkus.s3.aws.region=us-east-2 +quarkus.s3.aws.credentials.type=static +quarkus.s3.aws.credentials.static-provider.access-key-id=test-key +quarkus.s3.aws.credentials.static-provider.secret-access-key=test-secret + +quarkus.s3.async-client.type = netty diff --git a/s3/runtime/src/main/java/io/quarkiverse/amazon/s3/runtime/S3BuildTimeConfig.java b/s3/runtime/src/main/java/io/quarkiverse/amazon/s3/runtime/S3BuildTimeConfig.java index 0773c67a4..9642cd39b 100644 --- a/s3/runtime/src/main/java/io/quarkiverse/amazon/s3/runtime/S3BuildTimeConfig.java +++ b/s3/runtime/src/main/java/io/quarkiverse/amazon/s3/runtime/S3BuildTimeConfig.java @@ -1,8 +1,7 @@ package io.quarkiverse.amazon.s3.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -12,17 +11,7 @@ */ @ConfigMapping(prefix = "quarkus.s3") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface S3BuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon S3 client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon S3 client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface S3BuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/secretsmanager/deployment/src/main/java/io/quarkiverse/amazon/secretsmanager/deployment/SecretsManagerProcessor.java b/secretsmanager/deployment/src/main/java/io/quarkiverse/amazon/secretsmanager/deployment/SecretsManagerProcessor.java index 4cc4b9d47..299a5d6b4 100644 --- a/secretsmanager/deployment/src/main/java/io/quarkiverse/amazon/secretsmanager/deployment/SecretsManagerProcessor.java +++ b/secretsmanager/deployment/src/main/java/io/quarkiverse/amazon/secretsmanager/deployment/SecretsManagerProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.secretsmanager.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.secretsmanager.runtime.SecretsManagerBuildTimeConfig; import io.quarkiverse.amazon.secretsmanager.runtime.SecretsManagerRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.secretsmanager.SecretsManagerAsyncClient; import software.amazon.awssdk.services.secretsmanager.SecretsManagerAsyncClientBuilder; import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient; @@ -61,155 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(SecretsManagerAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return SecretsManagerClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/secretsmanager/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(SecretsManagerAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return SecretsManagerAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/secretsmanager/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, - SecretsManagerRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, - SecretsManagerRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, - SecretsManagerRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, - SecretsManagerRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, + void setup( SecretsManagerRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(SecretsManagerRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - SecretsManagerClientBuilder.class, - SecretsManagerAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/secretsmanager/runtime/src/main/java/io/quarkiverse/amazon/secretsmanager/runtime/SecretsManagerBuildTimeConfig.java b/secretsmanager/runtime/src/main/java/io/quarkiverse/amazon/secretsmanager/runtime/SecretsManagerBuildTimeConfig.java index 57e5172d4..db141d6b0 100644 --- a/secretsmanager/runtime/src/main/java/io/quarkiverse/amazon/secretsmanager/runtime/SecretsManagerBuildTimeConfig.java +++ b/secretsmanager/runtime/src/main/java/io/quarkiverse/amazon/secretsmanager/runtime/SecretsManagerBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.secretsmanager.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.secretsmanager") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface SecretsManagerBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon Secrets Manager client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon Secrets Manager client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface SecretsManagerBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/ses/deployment/src/main/java/io/quarkiverse/amazon/ses/deployment/SesProcessor.java b/ses/deployment/src/main/java/io/quarkiverse/amazon/ses/deployment/SesProcessor.java index 39f873151..77f315c00 100644 --- a/ses/deployment/src/main/java/io/quarkiverse/amazon/ses/deployment/SesProcessor.java +++ b/ses/deployment/src/main/java/io/quarkiverse/amazon/ses/deployment/SesProcessor.java @@ -1,40 +1,17 @@ package io.quarkiverse.amazon.ses.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.ses.runtime.SesBuildTimeConfig; -import io.quarkiverse.amazon.ses.runtime.SesConfig; import io.quarkiverse.amazon.ses.runtime.SesRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.ses.SesAsyncClient; import software.amazon.awssdk.services.ses.SesAsyncClientBuilder; import software.amazon.awssdk.services.ses.SesClient; @@ -62,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(SesAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return SesClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/ses/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(SesAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return SesAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/ses/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, SesRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - SesConfig runtimeConfig, BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, SesRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, SesRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - SesConfig runtimeConfig, BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, SesRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - SesConfig runtimeConfig, BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, SesRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + SesRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(SesRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - SesClientBuilder.class, - SesAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/ses/runtime/src/main/java/io/quarkiverse/amazon/ses/runtime/SesBuildTimeConfig.java b/ses/runtime/src/main/java/io/quarkiverse/amazon/ses/runtime/SesBuildTimeConfig.java index 8ca47c88b..94549e5d3 100644 --- a/ses/runtime/src/main/java/io/quarkiverse/amazon/ses/runtime/SesBuildTimeConfig.java +++ b/ses/runtime/src/main/java/io/quarkiverse/amazon/ses/runtime/SesBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.ses.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.ses") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface SesBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon SES client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon SES client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface SesBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/sfn/deployment/src/main/java/io/quarkiverse/amazon/sfn/deployment/SfnProcessor.java b/sfn/deployment/src/main/java/io/quarkiverse/amazon/sfn/deployment/SfnProcessor.java index 8b0e61f61..f22fe109a 100644 --- a/sfn/deployment/src/main/java/io/quarkiverse/amazon/sfn/deployment/SfnProcessor.java +++ b/sfn/deployment/src/main/java/io/quarkiverse/amazon/sfn/deployment/SfnProcessor.java @@ -1,40 +1,17 @@ package io.quarkiverse.amazon.sfn.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.sfn.runtime.SfnBuildTimeConfig; -import io.quarkiverse.amazon.sfn.runtime.SfnConfig; import io.quarkiverse.amazon.sfn.runtime.SfnRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.sfn.SfnAsyncClient; import software.amazon.awssdk.services.sfn.SfnAsyncClientBuilder; import software.amazon.awssdk.services.sfn.SfnClient; @@ -62,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(SfnAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return SfnClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/sfn/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(SfnAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return SfnAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/sfn/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, SfnRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - SfnConfig runtimeConfig, BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, SfnRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, SfnRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - SfnConfig runtimeConfig, BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, SfnRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - SfnConfig runtimeConfig, BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, SfnRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + SfnRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(SfnRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - SfnClientBuilder.class, - SfnAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/sfn/runtime/src/main/java/io/quarkiverse/amazon/sfn/runtime/SfnBuildTimeConfig.java b/sfn/runtime/src/main/java/io/quarkiverse/amazon/sfn/runtime/SfnBuildTimeConfig.java index 7e6f0a026..f0f953926 100644 --- a/sfn/runtime/src/main/java/io/quarkiverse/amazon/sfn/runtime/SfnBuildTimeConfig.java +++ b/sfn/runtime/src/main/java/io/quarkiverse/amazon/sfn/runtime/SfnBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.sfn.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.sfn") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface SfnBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon SQS client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon SQS client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface SfnBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/sns/deployment/src/main/java/io/quarkiverse/amazon/sns/deployment/SnsProcessor.java b/sns/deployment/src/main/java/io/quarkiverse/amazon/sns/deployment/SnsProcessor.java index 5b44bebac..c7d8e8ca2 100644 --- a/sns/deployment/src/main/java/io/quarkiverse/amazon/sns/deployment/SnsProcessor.java +++ b/sns/deployment/src/main/java/io/quarkiverse/amazon/sns/deployment/SnsProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.sns.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.sns.runtime.SnsBuildTimeConfig; import io.quarkiverse.amazon.sns.runtime.SnsRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.sns.SnsAsyncClient; import software.amazon.awssdk.services.sns.SnsAsyncClientBuilder; import software.amazon.awssdk.services.sns.SnsClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(SnsAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return SnsClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/sns/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(SnsAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return SnsAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/sns/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, SnsRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, SnsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, SnsRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, SnsRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, SnsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + SnsRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(SnsRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - SnsClientBuilder.class, - SnsAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/sns/runtime/src/main/java/io/quarkiverse/amazon/sns/runtime/SnsBuildTimeConfig.java b/sns/runtime/src/main/java/io/quarkiverse/amazon/sns/runtime/SnsBuildTimeConfig.java index 42ba350ae..6119657cd 100644 --- a/sns/runtime/src/main/java/io/quarkiverse/amazon/sns/runtime/SnsBuildTimeConfig.java +++ b/sns/runtime/src/main/java/io/quarkiverse/amazon/sns/runtime/SnsBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.sns.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.sns") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface SnsBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon SNS client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon SNS client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface SnsBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/sqs/deployment/pom.xml b/sqs/deployment/pom.xml index ea02ddac8..97ec129a3 100644 --- a/sqs/deployment/pom.xml +++ b/sqs/deployment/pom.xml @@ -32,6 +32,10 @@ io.quarkiverse.amazonservices quarkus-amazon-devservices-sqs + + io.opentelemetry.instrumentation + opentelemetry-aws-sdk-2.2 + diff --git a/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsOtelProcessor.java b/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsOtelProcessor.java new file mode 100644 index 000000000..c17037710 --- /dev/null +++ b/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsOtelProcessor.java @@ -0,0 +1,72 @@ +package io.quarkiverse.amazon.sqs.deployment; + +import static io.quarkiverse.amazon.common.deployment.ClientDeploymentUtil.namedBuilder; + +import java.util.List; + +import jakarta.enterprise.context.ApplicationScoped; + +import org.jboss.jandex.ClassType; + +import io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkTelemetry; +import io.quarkiverse.amazon.common.deployment.AmazonClientBuilderBuildItem; +import io.quarkiverse.amazon.common.deployment.AmazonClientBuilderOverrideBuildItem; +import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; +import io.quarkiverse.amazon.sqs.runtime.SqsOpenTelemetryRecorder; +import io.quarkus.arc.deployment.SyntheticBeanBuildItem; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import software.amazon.awssdk.services.sqs.SqsAsyncClientBuilder; +import software.amazon.awssdk.services.sqs.SqsClientBuilder; + +public class SqsOtelProcessor { + @BuildStep + @Record(ExecutionTime.RUNTIME_INIT) + void wrapClientBuilders(List clientBuilders, + List amazonRequireTelemtryClients, + SqsOpenTelemetryRecorder otelRecorder, + BuildProducer syntheticBeans, + BuildProducer overrides) { + + boolean addOpenTelemetry = amazonRequireTelemtryClients + .stream() + .anyMatch(c -> "sqs".equals(c.getConfigName())); + + if (!addOpenTelemetry) { + return; + } + + for (AmazonClientBuilderBuildItem clientBuilder : clientBuilders) { + if (clientBuilder.getBuilderClass().equals(SqsClientBuilder.class)) { + + syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(clientBuilder.getBuilderClass()), + clientBuilder.getClientName()) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .createWith(otelRecorder.configureSync(clientBuilder.getClientBuilder())) + .addInjectionPoint(ClassType.create(AwsSdkTelemetry.class)).done()); + + overrides.produce(new AmazonClientBuilderOverrideBuildItem( + clientBuilder.getBuilderClass(), + clientBuilder.getClientName())); + } else if (clientBuilder.getBuilderClass().equals(SqsAsyncClientBuilder.class)) { + + syntheticBeans.produce(namedBuilder(SyntheticBeanBuildItem.configure(clientBuilder.getBuilderClass()), + clientBuilder.getClientName()) + .unremovable() + .defaultBean() + .setRuntimeInit() + .scope(ApplicationScoped.class) + .createWith(otelRecorder.configureAsync(clientBuilder.getClientBuilder())) + .addInjectionPoint(ClassType.create(AwsSdkTelemetry.class)).done()); + overrides.produce(new AmazonClientBuilderOverrideBuildItem( + clientBuilder.getBuilderClass(), + clientBuilder.getClientName())); + } + } + } +} diff --git a/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsProcessor.java b/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsProcessor.java index ec09f715c..e9df4e6e6 100644 --- a/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsProcessor.java +++ b/sqs/deployment/src/main/java/io/quarkiverse/amazon/sqs/deployment/SqsProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.sqs.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.sqs.runtime.SqsBuildTimeConfig; -import io.quarkiverse.amazon.sqs.runtime.SqsOpenTelemetryRecorder; import io.quarkiverse.amazon.sqs.runtime.SqsRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.sqs.SqsAsyncClient; import software.amazon.awssdk.services.sqs.SqsAsyncClientBuilder; import software.amazon.awssdk.services.sqs.SqsClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(SqsAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return SqsClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/sqs/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(SqsAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return SqsAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/sqs/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, SqsRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, SqsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, SqsRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, SqsRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, SqsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + SqsRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(SqsRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - SqsOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - SqsClientBuilder.class, - SqsAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsBuildTimeConfig.java b/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsBuildTimeConfig.java index df060823f..5e93dda1e 100644 --- a/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsBuildTimeConfig.java +++ b/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsBuildTimeConfig.java @@ -1,8 +1,7 @@ package io.quarkiverse.amazon.sqs.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -12,17 +11,7 @@ */ @ConfigMapping(prefix = "quarkus.sqs") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface SqsBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon SQS client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon SQS client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface SqsBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsOpenTelemetryRecorder.java b/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsOpenTelemetryRecorder.java index f16071e55..73b4c5655 100644 --- a/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsOpenTelemetryRecorder.java +++ b/sqs/runtime/src/main/java/io/quarkiverse/amazon/sqs/runtime/SqsOpenTelemetryRecorder.java @@ -1,9 +1,10 @@ package io.quarkiverse.amazon.sqs.runtime; import java.net.URI; +import java.util.function.Function; import io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkTelemetry; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; +import io.quarkus.arc.SyntheticCreationalContext; import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.annotations.Recorder; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; @@ -19,7 +20,7 @@ import software.amazon.awssdk.services.sqs.SqsClientBuilder; @Recorder -public class SqsOpenTelemetryRecorder extends AmazonClientOpenTelemetryRecorder { +public class SqsOpenTelemetryRecorder { private final class TelemetryEnabledSqsSyncClientBuilder implements SqsClientBuilder { @@ -152,22 +153,53 @@ public SqsAsyncClient build() { } } - public SqsOpenTelemetryRecorder() { + public Function, AwsClientBuilder> configureSync( + RuntimeValue clientBuilder) { + return new Function, AwsClientBuilder>() { + @Override + public AwsClientBuilder apply(SyntheticCreationalContext context) { + AwsClientBuilder builder = clientBuilder.getValue(); + AwsSdkTelemetry awsSdkTelemetry = context.getInjectedReference(AwsSdkTelemetry.class); + + builder.overrideConfiguration( + builder.overrideConfiguration().toBuilder() + .addExecutionInterceptor(awsSdkTelemetry.newExecutionInterceptor()) + .build()); + + return wrapSyncClientBuilder(builder, awsSdkTelemetry); + } + }; + } + + public Function, AwsClientBuilder> configureAsync( + RuntimeValue clientBuilder) { + return new Function, AwsClientBuilder>() { + @Override + public AwsClientBuilder apply(SyntheticCreationalContext context) { + AwsClientBuilder builder = clientBuilder.getValue(); + AwsSdkTelemetry awsSdkTelemetry = context.getInjectedReference(AwsSdkTelemetry.class); + + builder.overrideConfiguration( + builder.overrideConfiguration().toBuilder() + .addExecutionInterceptor(awsSdkTelemetry.newExecutionInterceptor()) + .build()); + + return wrapAsyncClientBuilder(builder, awsSdkTelemetry); + } + }; } - @Override protected AwsClientBuilder wrapSyncClientBuilder(AwsClientBuilder clientBuilder, - RuntimeValue awsSdkTelemetry) { + AwsSdkTelemetry awsSdkTelemetry) { return (AwsClientBuilder) new TelemetryEnabledSqsSyncClientBuilder((SqsClientBuilder) clientBuilder, - awsSdkTelemetry.getValue()); + awsSdkTelemetry); } - @Override protected AwsClientBuilder wrapAsyncClientBuilder(AwsClientBuilder clientBuilder, - RuntimeValue awsSdkTelemetry) { + AwsSdkTelemetry awsSdkTelemetry) { return (AwsClientBuilder) new TelemetryEnabledSqsAsyncClientBuilder((SqsAsyncClientBuilder) clientBuilder, - awsSdkTelemetry.getValue()); + awsSdkTelemetry); } } diff --git a/ssm/deployment/src/main/java/io/quarkiverse/amazon/ssm/deployment/SsmProcessor.java b/ssm/deployment/src/main/java/io/quarkiverse/amazon/ssm/deployment/SsmProcessor.java index 9b7bbc808..65d15be86 100644 --- a/ssm/deployment/src/main/java/io/quarkiverse/amazon/ssm/deployment/SsmProcessor.java +++ b/ssm/deployment/src/main/java/io/quarkiverse/amazon/ssm/deployment/SsmProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.ssm.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.ssm.runtime.SsmBuildTimeConfig; import io.quarkiverse.amazon.ssm.runtime.SsmRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.ssm.SsmAsyncClient; import software.amazon.awssdk.services.ssm.SsmAsyncClientBuilder; import software.amazon.awssdk.services.ssm.SsmClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(SsmAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return SsmClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/ssm/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(SsmAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return SsmAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/ssm/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, SsmRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, SsmRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, SsmRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, SsmRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, SsmRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + SsmRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(SsmRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - SsmClientBuilder.class, - SsmAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/ssm/runtime/src/main/java/io/quarkiverse/amazon/ssm/runtime/SsmBuildTimeConfig.java b/ssm/runtime/src/main/java/io/quarkiverse/amazon/ssm/runtime/SsmBuildTimeConfig.java index e8cc7de02..c394e1a63 100644 --- a/ssm/runtime/src/main/java/io/quarkiverse/amazon/ssm/runtime/SsmBuildTimeConfig.java +++ b/ssm/runtime/src/main/java/io/quarkiverse/amazon/ssm/runtime/SsmBuildTimeConfig.java @@ -1,9 +1,8 @@ package io.quarkiverse.amazon.ssm.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; @@ -13,17 +12,7 @@ */ @ConfigMapping(prefix = "quarkus.ssm") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface SsmBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon SSM client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon SSM client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface SsmBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services diff --git a/sts/deployment/src/main/java/io/quarkiverse/amazon/sts/deployment/StsProcessor.java b/sts/deployment/src/main/java/io/quarkiverse/amazon/sts/deployment/StsProcessor.java index f9e0d8ad2..ece59ffb2 100644 --- a/sts/deployment/src/main/java/io/quarkiverse/amazon/sts/deployment/StsProcessor.java +++ b/sts/deployment/src/main/java/io/quarkiverse/amazon/sts/deployment/StsProcessor.java @@ -1,39 +1,17 @@ package io.quarkiverse.amazon.sts.deployment; -import java.util.List; - import org.jboss.jandex.DotName; import io.quarkiverse.amazon.common.deployment.AbstractAmazonServiceProcessor; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientAsyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientInterceptorsPathBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncResultBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonClientSyncTransportBuildItem; -import io.quarkiverse.amazon.common.deployment.AmazonHttpClients; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientInjectionBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonClientTransportBuilderBuildItem; -import io.quarkiverse.amazon.common.deployment.RequireAmazonTelemetryBuildItem; -import io.quarkiverse.amazon.common.deployment.spi.EventLoopGroupBuildItem; -import io.quarkiverse.amazon.common.runtime.AmazonClientApacheTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientAwsCrtTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientCommonRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientNettyTransportRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientOpenTelemetryRecorder; -import io.quarkiverse.amazon.common.runtime.AmazonClientUrlConnectionTransportRecorder; +import io.quarkiverse.amazon.common.deployment.AmazonClientExtensionBuildItem; +import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkiverse.amazon.sts.runtime.StsBuildTimeConfig; import io.quarkiverse.amazon.sts.runtime.StsRecorder; -import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem; -import io.quarkus.arc.deployment.SyntheticBeanBuildItem; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.ExecutorBuildItem; -import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.builditem.LaunchModeBuildItem; import software.amazon.awssdk.services.sts.StsAsyncClient; import software.amazon.awssdk.services.sts.StsAsyncClientBuilder; import software.amazon.awssdk.services.sts.StsClient; @@ -61,150 +39,41 @@ protected DotName syncClientName() { } @Override - protected DotName asyncClientName() { - return DotName.createSimple(StsAsyncClient.class.getName()); + protected Class syncClientBuilderClass() { + return StsClientBuilder.class; } @Override - protected String builtinInterceptorsPath() { - return "software/amazon/awssdk/services/sts/execution.interceptors"; + protected DotName asyncClientName() { + return DotName.createSimple(StsAsyncClient.class.getName()); } - @BuildStep - void setup( - BuildProducer extensionSslNativeSupport, - BuildProducer feature, - BuildProducer interceptors) { - - setupExtension(extensionSslNativeSupport, feature, interceptors); + @Override + protected Class asyncClientBuilderClass() { + return StsAsyncClientBuilder.class; } - @BuildStep - void discoverClientInjectionPoints(BeanRegistrationPhaseBuildItem beanRegistrationPhase, - BuildProducer requireClientInjectionProducer) { - - discoverClientInjectionPointsInternal(beanRegistrationPhase, requireClientInjectionProducer); + @Override + protected String builtinInterceptorsPath() { + return "software/amazon/awssdk/services/sts/execution.interceptors"; } - @BuildStep - void discover( - List amazonClientInjectionPoints, - BuildProducer requireClientProducer) { - - discoverClient(amazonClientInjectionPoints, requireClientProducer); + @Override + protected HasTransportBuildTimeConfig transportBuildTimeConfig() { + return buildTimeConfig; } - @BuildStep - void discoverTelemetry(BuildProducer telemetryProducer) { - - discoverTelemetry(telemetryProducer, buildTimeConfig.sdk()); + @Override + protected HasSdkBuildTimeConfig sdkBuildTimeConfig() { + return buildTimeConfig; } @BuildStep - void setupClient(List clientRequirements, - BuildProducer clientProducer) { - - setupClient(clientRequirements, clientProducer, buildTimeConfig.sdk(), buildTimeConfig.syncClient(), - buildTimeConfig.asyncClient()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonApacheHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupApacheSyncTransport(List amazonClients, StsRecorder recorder, - AmazonClientApacheTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createApacheSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtSyncTransport(List amazonClients, StsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createAwsCrtSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonUrlConnectionHttpServicePresent.class) @Record(ExecutionTime.RUNTIME_INIT) - void setupUrlConnectionSyncTransport(List amazonClients, StsRecorder recorder, - AmazonClientUrlConnectionTransportRecorder transportRecorder, - BuildProducer syncTransports) { - - createUrlConnectionSyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.syncClient(), - recorder.getSyncConfig(), - syncTransports); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonNettyHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupNettyAsyncTransport(List amazonClients, StsRecorder recorder, - AmazonClientNettyTransportRecorder transportRecorder, - BuildProducer asyncTransports, - EventLoopGroupBuildItem eventLoopSupplier) { - - createNettyAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports, eventLoopSupplier.getMainEventLoopGroup()); - } - - @BuildStep(onlyIf = AmazonHttpClients.IsAmazonAwsCrtHttpServicePresent.class) - @Record(ExecutionTime.RUNTIME_INIT) - void setupAwsCrtAsyncTransport(List amazonClients, StsRecorder recorder, - AmazonClientAwsCrtTransportRecorder transportRecorder, - BuildProducer asyncTransports) { - - createAwsCrtAsyncTransportBuilder(amazonClients, - transportRecorder, - buildTimeConfig.asyncClient(), - recorder.getAsyncConfig(), - asyncTransports); - } + void setup( + StsRecorder recorder, + BuildProducer amazonExtensions) { - @BuildStep - @Record(ExecutionTime.RUNTIME_INIT) - void createClientBuilders(StsRecorder recorder, - AmazonClientCommonRecorder commonRecorder, - AmazonClientOpenTelemetryRecorder otelRecorder, - List amazonClientInjections, - List amazonRequireTelemtryClients, - List syncTransports, - List asyncTransports, - BuildProducer syntheticBeans, - BuildProducer clientSync, - BuildProducer clientAsync, - LaunchModeBuildItem launchModeBuildItem, - ExecutorBuildItem executorBuildItem) { - - createClientBuilders( - recorder, - commonRecorder, - otelRecorder, - buildTimeConfig, - amazonClientInjections, - amazonRequireTelemtryClients, - syncTransports, - asyncTransports, - StsClientBuilder.class, - StsAsyncClientBuilder.class, - null, - syntheticBeans, - clientSync, - clientAsync, - launchModeBuildItem, - executorBuildItem); + setupExtension(recorder, amazonExtensions); } } diff --git a/sts/runtime/src/main/java/io/quarkiverse/amazon/sts/runtime/StsBuildTimeConfig.java b/sts/runtime/src/main/java/io/quarkiverse/amazon/sts/runtime/StsBuildTimeConfig.java index 4a67619b4..a2bbfcf33 100644 --- a/sts/runtime/src/main/java/io/quarkiverse/amazon/sts/runtime/StsBuildTimeConfig.java +++ b/sts/runtime/src/main/java/io/quarkiverse/amazon/sts/runtime/StsBuildTimeConfig.java @@ -1,26 +1,18 @@ package io.quarkiverse.amazon.sts.runtime; -import io.quarkiverse.amazon.common.runtime.AsyncHttpClientBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.DevServicesBuildTimeConfig; import io.quarkiverse.amazon.common.runtime.HasSdkBuildTimeConfig; -import io.quarkiverse.amazon.common.runtime.SyncHttpClientBuildTimeConfig; +import io.quarkiverse.amazon.common.runtime.HasTransportBuildTimeConfig; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; import io.smallrye.config.ConfigMapping; +/** + * Amazon STS build time configuration + */ @ConfigMapping(prefix = "quarkus.sts") @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) -public interface StsBuildTimeConfig extends HasSdkBuildTimeConfig { - - /** - * Sync HTTP transport configuration for Amazon STS client - */ - SyncHttpClientBuildTimeConfig syncClient(); - - /** - * Async HTTP transport configuration for Amazon IAM client - */ - AsyncHttpClientBuildTimeConfig asyncClient(); +public interface StsBuildTimeConfig extends HasSdkBuildTimeConfig, HasTransportBuildTimeConfig { /** * Config for dev services