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

[camel-k-runtime] branch master updated (1c3b390 -> d531934)

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

lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git.


    from 1c3b390  Updated CHANGELOG.md
     new f636261  quarkus: remove the need for a shutdown task bean as it was introduced only for testing
     new d531934  quarkus(catalog): fix the generated list of dependencies for the master capability

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../k/quarkus/cron/deployment/Application.java     |  23 ++---
 .../org/apache/camel/k/quarkus/it/Application.java |  20 +---
 .../org/apache/camel/k/quarkus/it/RuntimeTest.java |   2 -
 .../org/apache/camel/k/quarkus/Application.java    |  12 +--
 .../camel/k/quarkus/ApplicationProducers.java      |  17 ----
 .../apache/camel/k/support/DelegatingRuntime.java  | 109 +++++++++++++++++++++
 .../src/it/generate-catalog-quarkus/verify.groovy  |   4 +-
 .../camel/k/tooling/maven/GenerateCatalogMojo.java |   2 +-
 8 files changed, 124 insertions(+), 65 deletions(-)
 create mode 100644 camel-k-runtime-core/src/main/java/org/apache/camel/k/support/DelegatingRuntime.java


[camel-k-runtime] 01/02: quarkus: remove the need for a shutdown task bean as it was introduced only for testing

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit f6362613470a3518f04b67a8249d46bd53066966
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Fri Sep 18 10:52:58 2020 +0200

    quarkus: remove the need for a shutdown task bean as it was introduced only for testing
---
 .../k/quarkus/cron/deployment/Application.java     |  23 ++---
 .../org/apache/camel/k/quarkus/it/Application.java |  20 +---
 .../org/apache/camel/k/quarkus/it/RuntimeTest.java |   2 -
 .../org/apache/camel/k/quarkus/Application.java    |  12 +--
 .../camel/k/quarkus/ApplicationProducers.java      |  17 ----
 .../apache/camel/k/support/DelegatingRuntime.java  | 109 +++++++++++++++++++++
 6 files changed, 121 insertions(+), 62 deletions(-)

diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java
index a70fd02..27927c6 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-cron/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java
@@ -22,13 +22,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Inject;
-import javax.inject.Singleton;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
-import io.quarkus.arc.Unremovable;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ExtendedCamelContext;
 import org.apache.camel.k.Constants;
@@ -38,6 +36,7 @@ import org.apache.camel.k.SourceLoader;
 import org.apache.camel.k.Sources;
 import org.apache.camel.k.cron.CronSourceLoaderInterceptor;
 import org.apache.camel.k.loader.yaml.YamlSourceLoader;
+import org.apache.camel.k.support.DelegatingRuntime;
 
 @Path("/test")
 @ApplicationScoped
@@ -72,15 +71,21 @@ public class Application {
 
         final SourceLoader loader = new YamlSourceLoader();
         final Source source = Sources.fromBytes("my-cron", "yaml", null, List.of("cron"), code.getBytes(StandardCharsets.UTF_8));
+        final Runtime rt = new DelegatingRuntime(runtime) {
+            @Override
+            public void stop() throws Exception {
+                stopped.set(true);
+            }
+        };
 
         final CronSourceLoaderInterceptor interceptor = new CronSourceLoaderInterceptor();
-        interceptor.setRuntime(runtime);
+        interceptor.setRuntime(rt);
         interceptor.setOverridableComponents("timer");
 
         SourceLoader.Result result = interceptor.afterLoad(
             loader,
             source,
-            loader.load(runtime, source));
+            loader.load(rt, source));
 
         result.builder().ifPresent(b -> {
             try {
@@ -99,14 +104,4 @@ public class Application {
     public String stopped()  {
         return "" + stopped.get();
     }
-
-    /*
-     * Override the default ShutdownTask for testing purpose.
-     */
-    @Unremovable
-    @Singleton
-    @javax.enterprise.inject.Produces
-    org.apache.camel.k.quarkus.Application.ShutdownTask shutdownTask() {
-        return () -> stopped.set(true);
-    }
 }
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it/Application.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it/Application.java
index f3112a8..ce7f8a1 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it/Application.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/main/java/org/apache/camel/k/quarkus/it/Application.java
@@ -43,24 +43,8 @@ public class Application {
     @Produces(MediaType.APPLICATION_JSON)
     public JsonObject inspect() {
         return Json.createObjectBuilder()
-            .add(
-                "camel-context",
-                instance(CamelContext.class)
-                    .map(Object::getClass)
-                    .map(Class::getName)
-                    .orElse(""))
-            .add(
-                "camel-k-runtime",
-                instance(Runtime.class)
-                    .map(Object::getClass)
-                    .map(Class::getName)
-                    .orElse(""))
-            .add(
-                "shutdown-task",
-                instance(org.apache.camel.k.quarkus.Application.ShutdownTask.class)
-                    .map(Object::getClass)
-                    .map(Class::getName)
-                    .orElse(""))
+            .add("camel-context", instance(CamelContext.class).map(Object::getClass).map(Class::getName).orElse(""))
+            .add("camel-k-runtime", instance(Runtime.class).map(Object::getClass).map(Class::getName).orElse(""))
             .build();
     }
 
diff --git a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
index 5689b73..7216824 100644
--- a/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
+++ b/camel-k-quarkus/camel-k-quarkus-itests/camel-k-quarkus-itests-runtime/src/test/java/org/apache/camel/k/quarkus/it/RuntimeTest.java
@@ -22,7 +22,6 @@ import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.path.json.JsonPath;
 import org.apache.camel.k.quarkus.Application;
-import org.apache.camel.k.quarkus.ApplicationProducers;
 import org.apache.camel.quarkus.core.FastCamelContext;
 import org.junit.jupiter.api.Test;
 
@@ -43,7 +42,6 @@ public class RuntimeTest {
 
         assertThat(p.getString("camel-context")).isEqualTo(FastCamelContext.class.getName());
         assertThat(p.getString("camel-k-runtime")).isEqualTo(Application.Runtime.class.getName());
-        assertThat(p.getString("shutdown-task")).isEqualTo(ApplicationProducers.DefaultShutdownTask.class.getName());
     }
 
     @Test
diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/Application.java b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/Application.java
index fb0392a..320bd83 100644
--- a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/Application.java
+++ b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/Application.java
@@ -75,9 +75,7 @@ public final class Application {
         @Override
         public void stop() throws Exception {
             if (!this.stopped.compareAndExchange(false, true)) {
-                instance(ShutdownTask.class).ifPresentOrElse(
-                    ShutdownTask::run,
-                    Quarkus::asyncExit);
+                Quarkus.asyncExit();
             }
         }
     }
@@ -144,14 +142,6 @@ public final class Application {
         }
     }
 
-    /**
-     * Provide the task to be executed to shutdown the runtime
-     */
-    @FunctionalInterface
-    public interface ShutdownTask {
-        void run();
-    }
-
     // *********************************
     //
     // Helpers
diff --git a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationProducers.java b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationProducers.java
index f44f3c9..3e18fc3 100644
--- a/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationProducers.java
+++ b/camel-k-quarkus/camel-k-runtime-quarkus/runtime/src/main/java/org/apache/camel/k/quarkus/ApplicationProducers.java
@@ -20,9 +20,7 @@ import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.inject.Produces;
 import javax.inject.Singleton;
 
-import io.quarkus.arc.DefaultBean;
 import io.quarkus.arc.Unremovable;
-import io.quarkus.runtime.Quarkus;
 import org.apache.camel.k.Runtime;
 
 @ApplicationScoped
@@ -39,19 +37,4 @@ public class ApplicationProducers {
     Runtime runtime() {
         return this.runtime;
     }
-
-    @Unremovable
-    @DefaultBean
-    @Singleton
-    @Produces
-    Application.ShutdownTask shutdownTask() {
-        return new DefaultShutdownTask();
-    }
-
-    public static class DefaultShutdownTask implements Application.ShutdownTask {
-        @Override
-        public void run() {
-            Quarkus.asyncExit();
-        }
-    }
 }
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/DelegatingRuntime.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/DelegatingRuntime.java
new file mode 100644
index 0000000..960306b
--- /dev/null
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/DelegatingRuntime.java
@@ -0,0 +1,109 @@
+/*
+ * 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.k.support;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.k.Runtime;
+import org.apache.camel.spi.Registry;
+
+public class DelegatingRuntime implements Runtime {
+    private final Runtime runtime;
+
+    public DelegatingRuntime(Runtime runtime) {
+        this.runtime = runtime;
+    }
+
+    @Override
+    public <T extends CamelContext> T getCamelContext(Class<T> type) {
+        return runtime.getCamelContext(type);
+    }
+
+    @Override
+    public Registry getRegistry() {
+        return runtime.getRegistry();
+    }
+
+    @Override
+    public void setInitialProperties(Properties properties) {
+        runtime.setInitialProperties(properties);
+    }
+
+    @Override
+    public void setInitialProperties(Map<String, String> properties) {
+        runtime.setInitialProperties(properties);
+    }
+
+    @Override
+    public void setInitialProperties(String key, String value, String... keyVals) {
+        runtime.setInitialProperties(key, value, keyVals);
+    }
+
+    @Override
+    public void setProperties(Properties properties) {
+        runtime.setProperties(properties);
+    }
+
+    @Override
+    public void setProperties(Map<String, String> properties) {
+        runtime.setProperties(properties);
+    }
+
+    @Override
+    public void setProperties(String key, String value, String... keyVals) {
+        runtime.setProperties(key, value, keyVals);
+    }
+
+    @Override
+    public void addRoutes(RoutesBuilder builder) {
+        runtime.addRoutes(builder);
+    }
+
+    @Override
+    public void addConfiguration(Object configuration) {
+        runtime.addConfiguration(configuration);
+    }
+
+    @Override
+    public void setPropertiesLocations(Collection<String> locations) {
+        runtime.setPropertiesLocations(locations);
+    }
+
+    @Override
+    public void setPropertiesLocations(String... locations) {
+        runtime.setPropertiesLocations(locations);
+    }
+
+    @Override
+    public void stop() throws Exception {
+        runtime.stop();
+    }
+
+    @Override
+    public void close() throws Exception {
+        runtime.close();
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return runtime.getCamelContext();
+    }
+}


[camel-k-runtime] 02/02: quarkus(catalog): fix the generated list of dependencies for the master capability

Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git

commit d531934c13202a1366f50b2b21e78489d33482d1
Author: Luca Burgazzoli <lb...@gmail.com>
AuthorDate: Fri Sep 18 10:55:43 2020 +0200

    quarkus(catalog): fix the generated list of dependencies for the master capability
---
 .../src/it/generate-catalog-quarkus/verify.groovy                     | 4 ++--
 .../java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
index 5212f45..76814f6 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
@@ -37,8 +37,8 @@ new File(basedir, "catalog.yaml").withReader {
     assert catalog.spec.runtime.capabilities['circuit-breaker'].dependencies[0].artifactId == 'camel-quarkus-microprofile-fault-tolerance'
     assert catalog.spec.runtime.capabilities['tracing'].dependencies[0].groupId == 'org.apache.camel.quarkus'
     assert catalog.spec.runtime.capabilities['tracing'].dependencies[0].artifactId == 'camel-quarkus-opentracing'
-    assert catalog.spec.runtime.capabilities['master'].dependencies[0].groupId == 'org.apache.camel.quarkus'
-    assert catalog.spec.runtime.capabilities['master'].dependencies[0].artifactId == 'camel-quarkus-master'
+    assert catalog.spec.runtime.capabilities['master'].dependencies[0].groupId == 'org.apache.camel.k'
+    assert catalog.spec.runtime.capabilities['master'].dependencies[0].artifactId == 'camel-k-quarkus-master'
 
     assert catalog.metadata.labels['camel.apache.org/runtime.version'] == runtimeVersion
 
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index dec5ecb..ef428d4 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -183,7 +183,7 @@ public class GenerateCatalogMojo extends AbstractMojo {
                     runtimeSpec.putCapability(
                         "master",
                         CamelCapability.forArtifact(
-                            "org.apache.camel.quarkus", "camel-quarkus-master"));
+                            "org.apache.camel.k", "camel-k-quarkus-master"));
                     break;
                 default:
                     throw new IllegalArgumentException("catalog.runtime parameter value [" + runtime + "] is not supported!");