You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/09/09 05:33:15 UTC

[camel-quarkus] 01/01: AWS2-Lambda Extension: Adding interceptors and align to the other extensions

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch aws2-lambda-align
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit d5e4a386d9ce742520f3cd57920e5041e62ac25f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Sep 9 07:32:33 2020 +0200

    AWS2-Lambda Extension: Adding interceptors and align to the other extensions
---
 .../lambda/deployment/Aws2LambdaProcessor.java     | 39 ++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/extensions/aws2-lambda/deployment/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/deployment/Aws2LambdaProcessor.java b/extensions/aws2-lambda/deployment/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/deployment/Aws2LambdaProcessor.java
index ebc7197..474545e 100644
--- a/extensions/aws2-lambda/deployment/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/deployment/Aws2LambdaProcessor.java
+++ b/extensions/aws2-lambda/deployment/src/main/java/org/apache/camel/quarkus/component/aws2/lambda/deployment/Aws2LambdaProcessor.java
@@ -16,17 +16,52 @@
  */
 package org.apache.camel.quarkus.component.aws2.lambda.deployment;
 
+import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
-import org.jboss.logging.Logger;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.jboss.jandex.DotName;
 
 class Aws2LambdaProcessor {
 
-    private static final Logger LOG = Logger.getLogger(Aws2LambdaProcessor.class);
     private static final String FEATURE = "camel-aws2-lambda";
 
+    public static final String AWS_SDK_APPLICATION_ARCHIVE_MARKERS = "software/amazon/awssdk";
+
+    private static final List<String> INTERCEPTOR_PATHS = Arrays.asList(
+            "software/amazon/awssdk/global/handlers/execution.interceptors");
+
+    private static final DotName EXECUTION_INTERCEPTOR_NAME = DotName.createSimple(ExecutionInterceptor.class.getName());
+
     @BuildStep
     FeatureBuildItem feature() {
         return new FeatureBuildItem(FEATURE);
     }
+
+    @BuildStep(applicationArchiveMarkers = { AWS_SDK_APPLICATION_ARCHIVE_MARKERS })
+    void process(CombinedIndexBuildItem combinedIndexBuildItem,
+            BuildProducer<ReflectiveClassBuildItem> reflectiveClasses,
+            BuildProducer<NativeImageResourceBuildItem> resource) {
+
+        INTERCEPTOR_PATHS.forEach(path -> resource.produce(new NativeImageResourceBuildItem(path)));
+
+        List<String> knownInterceptorImpls = combinedIndexBuildItem.getIndex()
+                .getAllKnownImplementors(EXECUTION_INTERCEPTOR_NAME)
+                .stream()
+                .map(c -> c.name().toString()).collect(Collectors.toList());
+
+        reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false,
+                knownInterceptorImpls.toArray(new String[knownInterceptorImpls.size()])));
+
+        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, false,
+                String.class.getCanonicalName()));
+    }
 }