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/04/03 12:13:22 UTC

[camel-quarkus] 01/01: AWS-SWF: Make the extension native

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

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

commit 7d43c6f0e3d1b5e8d3202cf1b4eb4475982af751
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Apr 3 14:07:43 2020 +0200

    AWS-SWF: Make the extension native
---
 .../pages/list-of-camel-quarkus-extensions.adoc    |  4 +-
 .../aws/swf/deployment/AwsSwfProcessor.java        | 46 ------------
 extensions-jvm/aws-swf/integration-test/pom.xml    | 82 ----------------------
 .../component/aws/swf/it/AwsSwfResource.java       | 51 --------------
 .../quarkus/component/aws/swf/it/AwsSwfTest.java   | 34 ---------
 extensions-jvm/pom.xml                             |  1 -
 .../aws-swf/deployment/pom.xml                     |  0
 .../aws/swf/deployment/AwsSwfProcessor.java        | 65 +++++++++++++++++
 {extensions-jvm => extensions}/aws-swf/pom.xml     |  1 -
 .../aws-swf/runtime/pom.xml                        |  0
 .../main/resources/META-INF/quarkus-extension.yaml |  4 +-
 extensions/pom.xml                                 |  1 +
 integration-tests/aws/pom.xml                      |  4 ++
 .../camel/quarkus/component/aws/CamelRoute.java    |  4 ++
 .../aws/src/main/resources/application.properties  |  9 ++-
 15 files changed, 86 insertions(+), 220 deletions(-)

diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index 4dd34d5..52ef746 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -146,8 +146,8 @@ Level | Since | Description
  Stable | 0.2.0 | The aws-sqs component is used for sending and receiving messages to Amazon's SQS service.
 
 | link:https://camel.apache.org/components/latest/aws-swf-component.html[AWS Simple Workflow] (camel-quarkus-aws-swf) +
-`aws-swf:type` | JVM +
- Preview | 1.0.0-M6 | The aws-swf component is used for managing workflows from Amazon Simple Workflow.
+`aws-swf:type` | Native +
+ Stable | 1.0.0-M6 | The aws-swf component is used for managing workflows from Amazon Simple Workflow.
 
 | link:https://camel.apache.org/components/latest/aws-sdb-component.html[AWS SimpleDB] (camel-quarkus-aws-sdb) +
 `aws-sdb:domainName` | Native +
diff --git a/extensions-jvm/aws-swf/deployment/src/main/java/org/apache/camel/quarkus/component/aws/swf/deployment/AwsSwfProcessor.java b/extensions-jvm/aws-swf/deployment/src/main/java/org/apache/camel/quarkus/component/aws/swf/deployment/AwsSwfProcessor.java
deleted file mode 100644
index 97e938a..0000000
--- a/extensions-jvm/aws-swf/deployment/src/main/java/org/apache/camel/quarkus/component/aws/swf/deployment/AwsSwfProcessor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.aws.swf.deployment;
-
-import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
-import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
-import org.jboss.logging.Logger;
-
-class AwsSwfProcessor {
-
-    private static final Logger LOG = Logger.getLogger(AwsSwfProcessor.class);
-    private static final String FEATURE = "camel-aws-swf";
-
-    @BuildStep
-    FeatureBuildItem feature() {
-        return new FeatureBuildItem(FEATURE);
-    }
-
-    /**
-     * Remove this once this extension starts supporting the native mode.
-     */
-    @BuildStep(onlyIf = NativeBuild.class)
-    @Record(value = ExecutionTime.RUNTIME_INIT)
-    void warnJvmInNative(JvmOnlyRecorder recorder) {
-        JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
-        recorder.warnJvmInNative(FEATURE); // warn at runtime
-    }
-}
diff --git a/extensions-jvm/aws-swf/integration-test/pom.xml b/extensions-jvm/aws-swf/integration-test/pom.xml
deleted file mode 100644
index eb9af3b..0000000
--- a/extensions-jvm/aws-swf/integration-test/pom.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.camel.quarkus</groupId>
-        <artifactId>camel-quarkus-aws-swf-parent</artifactId>
-        <version>1.1.0-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>camel-quarkus-aws-swf-integration-test</artifactId>
-    <name>Camel Quarkus :: AWS Simple Workflow :: Integration Test</name>
-    <description>Integration tests for Camel Quarkus AWS Simple Workflow extension</description>
-
-    <properties>
-        <!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd -->
-        <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
-        <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
-        <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
-        <!-- Please update rule whenever you change the dependencies of this module by running -->
-        <!--     mvn process-resources -Pformat    from the root directory -->
-        <mvnd.builder.rule>camel-quarkus-aws-swf-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
-    </properties>
-
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.camel.quarkus</groupId>
-            <artifactId>camel-quarkus-aws-swf</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-resteasy</artifactId>
-        </dependency>
-
-        <!-- test dependencies -->
-        <dependency>
-            <groupId>io.quarkus</groupId>
-            <artifactId>quarkus-junit5</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>io.rest-assured</groupId>
-            <artifactId>rest-assured</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>io.quarkus</groupId>
-                <artifactId>quarkus-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>build</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-</project>
diff --git a/extensions-jvm/aws-swf/integration-test/src/main/java/org/apache/camel/quarkus/component/aws/swf/it/AwsSwfResource.java b/extensions-jvm/aws-swf/integration-test/src/main/java/org/apache/camel/quarkus/component/aws/swf/it/AwsSwfResource.java
deleted file mode 100644
index aa3ca33..0000000
--- a/extensions-jvm/aws-swf/integration-test/src/main/java/org/apache/camel/quarkus/component/aws/swf/it/AwsSwfResource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.aws.swf.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/aws-swf")
-@ApplicationScoped
-public class AwsSwfResource {
-
-    private static final Logger LOG = Logger.getLogger(AwsSwfResource.class);
-
-    private static final String COMPONENT_AWS_SWF = "aws-swf";
-    @Inject
-    CamelContext context;
-
-    @Path("/load/component/aws-swf")
-    @GET
-    @Produces(MediaType.TEXT_PLAIN)
-    public Response loadComponentAwsSwf() throws Exception {
-        /* This is an autogenerated test */
-        if (context.getComponent(COMPONENT_AWS_SWF) != null) {
-            return Response.ok().build();
-        }
-        LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_AWS_SWF);
-        return Response.status(500, COMPONENT_AWS_SWF + " could not be loaded from the Camel context").build();
-    }
-}
diff --git a/extensions-jvm/aws-swf/integration-test/src/test/java/org/apache/camel/quarkus/component/aws/swf/it/AwsSwfTest.java b/extensions-jvm/aws-swf/integration-test/src/test/java/org/apache/camel/quarkus/component/aws/swf/it/AwsSwfTest.java
deleted file mode 100644
index 0b8b14f..0000000
--- a/extensions-jvm/aws-swf/integration-test/src/test/java/org/apache/camel/quarkus/component/aws/swf/it/AwsSwfTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.aws.swf.it;
-
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
-
-@QuarkusTest
-class AwsSwfTest {
-
-    @Test
-    public void loadComponentAwsSwf() {
-        /* A simple autogenerated test */
-        RestAssured.get("/aws-swf/load/component/aws-swf")
-                .then()
-                .statusCode(200);
-    }
-
-}
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index 90f87ef..947c514 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -35,7 +35,6 @@
     <modules>
         <!-- extensions a..z; do not remove this comment, it is important when sorting via  mvn process-resources -Pformat -->
         <module>avro</module>
-        <module>aws-swf</module>
         <module>aws2-cw</module>
         <module>aws2-ddb</module>
         <module>aws2-ec2</module>
diff --git a/extensions-jvm/aws-swf/deployment/pom.xml b/extensions/aws-swf/deployment/pom.xml
similarity index 100%
rename from extensions-jvm/aws-swf/deployment/pom.xml
rename to extensions/aws-swf/deployment/pom.xml
diff --git a/extensions/aws-swf/deployment/src/main/java/org/apache/camel/quarkus/component/aws/swf/deployment/AwsSwfProcessor.java b/extensions/aws-swf/deployment/src/main/java/org/apache/camel/quarkus/component/aws/swf/deployment/AwsSwfProcessor.java
new file mode 100644
index 0000000..84a859e
--- /dev/null
+++ b/extensions/aws-swf/deployment/src/main/java/org/apache/camel/quarkus/component/aws/swf/deployment/AwsSwfProcessor.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.aws.swf.deployment;
+
+import com.amazonaws.auth.AWS4Signer;
+import com.amazonaws.partitions.model.CredentialScope;
+import com.amazonaws.partitions.model.Endpoint;
+import com.amazonaws.partitions.model.Partition;
+import com.amazonaws.partitions.model.Partitions;
+import com.amazonaws.partitions.model.Region;
+import com.amazonaws.partitions.model.Service;
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+
+class AwsSwfProcessor {
+
+    public static final String AWS_SWF_APPLICATION_ARCHIVE_MARKERS = "com/amazonaws";
+
+    private static final String FEATURE = "camel-aws-swf";
+
+    @BuildStep
+    FeatureBuildItem feature() {
+        return new FeatureBuildItem(FEATURE);
+    }
+
+    @BuildStep
+    ExtensionSslNativeSupportBuildItem activateSslNativeSupport() {
+        return new ExtensionSslNativeSupportBuildItem(FEATURE);
+    }
+
+    @BuildStep(applicationArchiveMarkers = { AWS_SWF_APPLICATION_ARCHIVE_MARKERS })
+    void process(CombinedIndexBuildItem combinedIndexBuildItem,
+            BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+            BuildProducer<NativeImageResourceBuildItem> resource) {
+
+        resource.produce(new NativeImageResourceBuildItem("com/amazonaws/partitions/endpoints.json"));
+        reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
+                Partitions.class.getCanonicalName(),
+                Partition.class.getCanonicalName(),
+                Endpoint.class.getCanonicalName(),
+                Region.class.getCanonicalName(),
+                Service.class.getCanonicalName(),
+                CredentialScope.class.getCanonicalName(),
+                AWS4Signer.class.getCanonicalName()));
+    }
+}
diff --git a/extensions-jvm/aws-swf/pom.xml b/extensions/aws-swf/pom.xml
similarity index 97%
rename from extensions-jvm/aws-swf/pom.xml
rename to extensions/aws-swf/pom.xml
index 40dac53..3360eda 100644
--- a/extensions-jvm/aws-swf/pom.xml
+++ b/extensions/aws-swf/pom.xml
@@ -35,6 +35,5 @@
     <modules>
         <module>deployment</module>
         <module>runtime</module>
-        <module>integration-test</module>
     </modules>
 </project>
diff --git a/extensions-jvm/aws-swf/runtime/pom.xml b/extensions/aws-swf/runtime/pom.xml
similarity index 100%
rename from extensions-jvm/aws-swf/runtime/pom.xml
rename to extensions/aws-swf/runtime/pom.xml
diff --git a/extensions-jvm/aws-swf/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/aws-swf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 91%
rename from extensions-jvm/aws-swf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/aws-swf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index 2f8b9e5..09a1a43 100644
--- a/extensions-jvm/aws-swf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/aws-swf/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -21,9 +21,9 @@ description: "The aws-swf component is used for managing workflows from Amazon S
 metadata:
   unlisted: true
   keywords:
+  - "camel"
   - "cloud"
   - "workflow"
-  guide: "https://camel.apache.org/components/latest/aws-swf-component.html"
+  guide: "https://quarkus.io/guides/camel"
   categories:
   - "integration"
-  status: "preview"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 60352a9..c527844 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -49,6 +49,7 @@
         <module>aws-sdb</module>
         <module>aws-sns</module>
         <module>aws-sqs</module>
+        <module>aws-swf</module>
         <module>aws-translate</module>
         <module>azure</module>
         <module>base64</module>
diff --git a/integration-tests/aws/pom.xml b/integration-tests/aws/pom.xml
index 5d1212e..8a936c7 100644
--- a/integration-tests/aws/pom.xml
+++ b/integration-tests/aws/pom.xml
@@ -102,6 +102,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-aws-swf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-log</artifactId>
         </dependency>
         <dependency>
diff --git a/integration-tests/aws/src/main/java/org/apache/camel/quarkus/component/aws/CamelRoute.java b/integration-tests/aws/src/main/java/org/apache/camel/quarkus/component/aws/CamelRoute.java
index 76e7728..03f5d1e 100644
--- a/integration-tests/aws/src/main/java/org/apache/camel/quarkus/component/aws/CamelRoute.java
+++ b/integration-tests/aws/src/main/java/org/apache/camel/quarkus/component/aws/CamelRoute.java
@@ -79,6 +79,10 @@ public class CamelRoute extends RouteBuilder {
                 .to("aws-sdb://TestDomain?operation=DomainMetadata&accessKey={{env:AWS_ACCESS_KEY}}&secretKey={{env:AWS_SECRET_KEY}}&region={{env:AWS_REGION}}")
                 .to("log:sf?showAll=true");
 
+        from("timer:quarkus-swf?repeatCount=1")
+                .to("aws-swf://workflow?domainName=testDomain&activityList=swf-alist&workflowList=swf-wlist&version=1.0&eventName=testEvent")
+                .to("log:sf?showAll=true");
+
         from("aws-kinesis://mykinesisstream")
                 .to("log:sf?showAll=true");
     }
diff --git a/integration-tests/aws/src/main/resources/application.properties b/integration-tests/aws/src/main/resources/application.properties
index ab29175..2f853c8 100644
--- a/integration-tests/aws/src/main/resources/application.properties
+++ b/integration-tests/aws/src/main/resources/application.properties
@@ -107,4 +107,11 @@ camel.component.aws-kinesis.region={{env:AWS_REGION}}
 #
 camel.component.aws-kinesis-firehose.access-key={{env:AWS_ACCESS_KEY}}
 camel.component.aws-kinesis-firehose.secret-key={{env:AWS_SECRET_KEY}}
-camel.component.aws-kinesis-firehose.region={{env:AWS_REGION}}
\ No newline at end of file
+camel.component.aws-kinesis-firehose.region={{env:AWS_REGION}}
+
+#
+# Camel :: AWS SWF
+#
+camel.component.aws-swf.access-key={{env:AWS_ACCESS_KEY}}
+camel.component.aws-swf.secret-key={{env:AWS_SECRET_KEY}}
+camel.component.aws-swf.region={{env:AWS_REGION}}
\ No newline at end of file