You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/11/06 08:27:42 UTC

[camel] branch camel-3.18.x updated (422688d15e2 -> 1507c476a53)

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

davsclaus pushed a change to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 422688d15e2 CAMEL-18676: camel-jbang: does not add camel-openapi-java component when required
     new f9065dbceea CAMEL-18669: camel-jbang - Using resilience4j as CB should include include dependency
     new 1507c476a53 Fix CS

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:
 .../java/org/apache/camel/main/KameletMain.java    |  4 ++
 .../main/download/CircuitBreakerDownloader.java    | 69 ++++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java


[camel] 01/02: CAMEL-18669: camel-jbang - Using resilience4j as CB should include include dependency

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

davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f9065dbceea44088069bce1161796c003205e2dc
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Oct 31 13:28:24 2022 +0100

    CAMEL-18669: camel-jbang - Using resilience4j as CB should include include dependency
---
 .../java/org/apache/camel/main/KameletMain.java    |  4 ++
 .../main/download/CircuitBreakerDownloader.java    | 75 ++++++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index 31149f976a6..f7e1b813d71 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -27,6 +27,7 @@ import org.apache.camel.ProducerTemplate;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.main.download.AutoConfigureDownloadListener;
+import org.apache.camel.main.download.CircuitBreakerDownloader;
 import org.apache.camel.main.download.CommandLineDependencyDownloader;
 import org.apache.camel.main.download.DependencyDownloaderClassLoader;
 import org.apache.camel.main.download.DependencyDownloaderClassResolver;
@@ -289,6 +290,9 @@ public class KameletMain extends MainCommandLineSupport {
             } catch (Exception e) {
                 throw RuntimeCamelException.wrapRuntimeException(e);
             }
+
+            // in case we use circuit breakers
+            CircuitBreakerDownloader.registerDownloadReifiers();
         }
         if (stub) {
             // turn off auto-wiring when running in stub mode
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
new file mode 100644
index 00000000000..0b4f367864f
--- /dev/null
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
@@ -0,0 +1,75 @@
+/*
+ * 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.main.download;
+
+import java.util.function.BiFunction;
+
+import org.apache.camel.Route;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.reifier.ProcessReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+
+/**
+ * When using circuit breakers then we need to download the runtime implementation
+ */
+public class CircuitBreakerDownloader {
+
+    public static void registerDownloadReifiers() {
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class,
+                new BiFunction<Route, ProcessorDefinition<?>, ProcessorReifier<? extends ProcessorDefinition<?>>>() {
+                    @Override
+                    public ProcessorReifier<? extends ProcessorDefinition<?>> apply(
+                            Route route, ProcessorDefinition<?> processorDefinition) {
+                        if (processorDefinition instanceof CircuitBreakerDefinition) {
+                            CircuitBreakerDefinition cb = (CircuitBreakerDefinition) processorDefinition;
+                            DependencyDownloader downloader = route.getCamelContext().hasService(DependencyDownloader.class);
+                            if (downloader != null) {
+                                String artifactId = null;
+                                if (cb.getResilience4jConfiguration() != null) {
+                                    downloader.downloadDependency("org.apache.camel", "camel-resilience4j",
+                                            route.getCamelContext().getVersion());
+                                }
+                                if (cb.getFaultToleranceConfiguration() != null) {
+                                    downloader.downloadDependency("org.apache.camel", "camel-microprofile-fault-tolerance",
+                                            route.getCamelContext().getVersion());
+                                }
+                                if (cb.getConfiguration() != null) {
+                                    String id = cb.getConfiguration();
+                                    Object cfg = route.getCamelContext().adapt(ModelCamelContext.class)
+                                            .getResilience4jConfiguration(id);
+                                    if (cfg != null) {
+                                        downloader.downloadDependency("org.apache.camel", "camel-resilience4j",
+                                                route.getCamelContext().getVersion());
+                                    }
+                                    cfg = route.getCamelContext().adapt(ModelCamelContext.class)
+                                            .getFaultToleranceConfiguration(id);
+                                    if (cfg != null) {
+                                        downloader.downloadDependency("org.apache.camel", "camel-microprofile-fault-tolerance",
+                                                route.getCamelContext().getVersion());
+                                    }
+                                }
+                            }
+                        }
+                        // use core reifier now we have downloaded JARs if needed
+                        return ProcessReifier.coreReifier(route, processorDefinition);
+                    }
+                });
+    }
+
+}


[camel] 02/02: Fix CS

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

davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1507c476a53e467d7738a6bb048740952f1b2959
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Nov 6 09:24:55 2022 +0100

    Fix CS
---
 .../main/download/CircuitBreakerDownloader.java    | 60 ++++++++++------------
 1 file changed, 27 insertions(+), 33 deletions(-)

diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
index 0b4f367864f..3e2cca7c6d9 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
@@ -16,59 +16,53 @@
  */
 package org.apache.camel.main.download;
 
-import java.util.function.BiFunction;
-
-import org.apache.camel.Route;
 import org.apache.camel.model.CircuitBreakerDefinition;
 import org.apache.camel.model.ModelCamelContext;
-import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.reifier.ProcessReifier;
 import org.apache.camel.reifier.ProcessorReifier;
 
 /**
  * When using circuit breakers then we need to download the runtime implementation
  */
-public class CircuitBreakerDownloader {
+public final class CircuitBreakerDownloader {
+
+    private CircuitBreakerDownloader() {
+    }
 
     public static void registerDownloadReifiers() {
         ProcessorReifier.registerReifier(CircuitBreakerDefinition.class,
-                new BiFunction<Route, ProcessorDefinition<?>, ProcessorReifier<? extends ProcessorDefinition<?>>>() {
-                    @Override
-                    public ProcessorReifier<? extends ProcessorDefinition<?>> apply(
-                            Route route, ProcessorDefinition<?> processorDefinition) {
-                        if (processorDefinition instanceof CircuitBreakerDefinition) {
-                            CircuitBreakerDefinition cb = (CircuitBreakerDefinition) processorDefinition;
-                            DependencyDownloader downloader = route.getCamelContext().hasService(DependencyDownloader.class);
-                            if (downloader != null) {
-                                String artifactId = null;
-                                if (cb.getResilience4jConfiguration() != null) {
+                (route, processorDefinition) -> {
+                    if (processorDefinition instanceof CircuitBreakerDefinition) {
+                        CircuitBreakerDefinition cb = (CircuitBreakerDefinition) processorDefinition;
+                        DependencyDownloader downloader = route.getCamelContext().hasService(DependencyDownloader.class);
+                        if (downloader != null) {
+                            if (cb.getResilience4jConfiguration() != null) {
+                                downloader.downloadDependency("org.apache.camel", "camel-resilience4j",
+                                        route.getCamelContext().getVersion());
+                            }
+                            if (cb.getFaultToleranceConfiguration() != null) {
+                                downloader.downloadDependency("org.apache.camel", "camel-microprofile-fault-tolerance",
+                                        route.getCamelContext().getVersion());
+                            }
+                            if (cb.getConfiguration() != null) {
+                                String id = cb.getConfiguration();
+                                Object cfg = route.getCamelContext().adapt(ModelCamelContext.class)
+                                        .getResilience4jConfiguration(id);
+                                if (cfg != null) {
                                     downloader.downloadDependency("org.apache.camel", "camel-resilience4j",
                                             route.getCamelContext().getVersion());
                                 }
-                                if (cb.getFaultToleranceConfiguration() != null) {
+                                cfg = route.getCamelContext().adapt(ModelCamelContext.class)
+                                        .getFaultToleranceConfiguration(id);
+                                if (cfg != null) {
                                     downloader.downloadDependency("org.apache.camel", "camel-microprofile-fault-tolerance",
                                             route.getCamelContext().getVersion());
                                 }
-                                if (cb.getConfiguration() != null) {
-                                    String id = cb.getConfiguration();
-                                    Object cfg = route.getCamelContext().adapt(ModelCamelContext.class)
-                                            .getResilience4jConfiguration(id);
-                                    if (cfg != null) {
-                                        downloader.downloadDependency("org.apache.camel", "camel-resilience4j",
-                                                route.getCamelContext().getVersion());
-                                    }
-                                    cfg = route.getCamelContext().adapt(ModelCamelContext.class)
-                                            .getFaultToleranceConfiguration(id);
-                                    if (cfg != null) {
-                                        downloader.downloadDependency("org.apache.camel", "camel-microprofile-fault-tolerance",
-                                                route.getCamelContext().getVersion());
-                                    }
-                                }
                             }
                         }
-                        // use core reifier now we have downloaded JARs if needed
-                        return ProcessReifier.coreReifier(route, processorDefinition);
                     }
+                    // use core reifier now we have downloaded JARs if needed
+                    return ProcessReifier.coreReifier(route, processorDefinition);
                 });
     }