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 2023/07/14 09:53:35 UTC

[camel] branch camel-3.21.x updated (5535e7056ff -> 3fdfe272580)

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

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


    from 5535e7056ff Fix docs for antora build
     new 787e771982c CAMEL-19603: camel-core - configureVault should be done general so its also done for Spring Boot and Quarkus and not only camel-main/camel-jbang.
     new 3fdfe272580 CAMEL-19603: camel-core - configureVault should be done general so its also done for Spring Boot and Quarkus and not only camel-main/camel-jbang.

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:
 .../org/apache/camel/main/BaseMainSupport.java     | 72 +-------------------
 .../camel/main/DefaultConfigurationConfigurer.java | 77 +++++++++++++++++++++-
 2 files changed, 77 insertions(+), 72 deletions(-)


[camel] 01/02: CAMEL-19603: camel-core - configureVault should be done general so its also done for Spring Boot and Quarkus and not only camel-main/camel-jbang.

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.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 787e771982cc0e2f9157cec767ae0ab096c9ee42
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 14 11:11:44 2023 +0200

    CAMEL-19603: camel-core - configureVault should be done general so its also done for Spring Boot and Quarkus and not only camel-main/camel-jbang.
---
 .../org/apache/camel/main/BaseMainSupport.java     | 69 ---------------------
 .../camel/main/DefaultConfigurationConfigurer.java | 72 ++++++++++++++++++++++
 2 files changed, 72 insertions(+), 69 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index ce1b2aaa190..aefdfcfe8d2 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -388,73 +388,6 @@ public abstract class BaseMainSupport extends BaseService {
     protected void configureLifecycle(CamelContext camelContext) throws Exception {
     }
 
-    /**
-     * Configures security vaults such as AWS, Azure, Google and Hashicorp.
-     */
-    protected void configureVault(CamelContext camelContext) throws Exception {
-        VaultConfiguration vc = camelContext.getVaultConfiguration();
-        if (vc == null) {
-            return;
-        }
-
-        if (vc.aws().isRefreshEnabled()) {
-            Optional<Runnable> task = camelContext.adapt(ExtendedCamelContext.class)
-                    .getPeriodTaskResolver().newInstance("aws-secret-refresh", Runnable.class);
-            if (task.isPresent()) {
-                long period = vc.aws().getRefreshPeriod();
-                Runnable r = task.get();
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Scheduling: {} (period: {})", r, TimeUtils.printDuration(period, false));
-                }
-                if (camelContext.hasService(ContextReloadStrategy.class) == null) {
-                    // refresh is enabled then we need to automatically enable context-reload as well
-                    ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
-                    camelContext.addService(reloader);
-                }
-                PeriodTaskScheduler scheduler = getCamelContext().adapt(ExtendedCamelContext.class).getPeriodTaskScheduler();
-                scheduler.schedulePeriodTask(r, period);
-            }
-        }
-
-        if (vc.gcp().isRefreshEnabled()) {
-            Optional<Runnable> task = camelContext.adapt(ExtendedCamelContext.class)
-                    .getPeriodTaskResolver().newInstance("gcp-secret-refresh", Runnable.class);
-            if (task.isPresent()) {
-                long period = vc.gcp().getRefreshPeriod();
-                Runnable r = task.get();
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Scheduling: {} (period: {})", r, TimeUtils.printDuration(period, false));
-                }
-                if (camelContext.hasService(ContextReloadStrategy.class) == null) {
-                    // refresh is enabled then we need to automatically enable context-reload as well
-                    ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
-                    camelContext.addService(reloader);
-                }
-                PeriodTaskScheduler scheduler = getCamelContext().adapt(ExtendedCamelContext.class).getPeriodTaskScheduler();
-                scheduler.schedulePeriodTask(r, period);
-            }
-        }
-
-        if (vc.azure().isRefreshEnabled()) {
-            Optional<Runnable> task = camelContext.adapt(ExtendedCamelContext.class)
-                    .getPeriodTaskResolver().newInstance("azure-secret-refresh", Runnable.class);
-            if (task.isPresent()) {
-                long period = vc.azure().getRefreshPeriod();
-                Runnable r = task.get();
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Scheduling: {} (period: {})", r, TimeUtils.printDuration(period, false));
-                }
-                if (camelContext.hasService(ContextReloadStrategy.class) == null) {
-                    // refresh is enabled then we need to automatically enable context-reload as well
-                    ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
-                    camelContext.addService(reloader);
-                }
-                PeriodTaskScheduler scheduler = getCamelContext().adapt(ExtendedCamelContext.class).getPeriodTaskScheduler();
-                scheduler.schedulePeriodTask(r, period);
-            }
-        }
-    }
-
     protected void autoconfigure(CamelContext camelContext) throws Exception {
         // gathers the properties (key=value) that was auto-configured
         final OrderedLocationProperties autoConfiguredProperties = new OrderedLocationProperties();
@@ -691,8 +624,6 @@ public abstract class BaseMainSupport extends BaseService {
 
         configureLifecycle(camelContext);
 
-        configureVault(camelContext);
-
         if (standalone) {
             step = recorder.beginStep(BaseMainSupport.class, "configureRoutes", "Collect Routes");
             configureRoutes(camelContext);
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
index eff98206d8d..eaa8215b10c 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
@@ -19,6 +19,7 @@ package org.apache.camel.main;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.function.Consumer;
 import java.util.function.Predicate;
@@ -61,6 +62,7 @@ import org.apache.camel.spi.ManagementStrategy;
 import org.apache.camel.spi.MessageHistoryFactory;
 import org.apache.camel.spi.ModelJAXBContextFactory;
 import org.apache.camel.spi.NodeIdFactory;
+import org.apache.camel.spi.PeriodTaskScheduler;
 import org.apache.camel.spi.ProcessorFactory;
 import org.apache.camel.spi.PropertiesComponent;
 import org.apache.camel.spi.ReactiveExecutor;
@@ -86,6 +88,7 @@ import org.apache.camel.support.SimpleUuidGenerator;
 import org.apache.camel.support.jsse.GlobalSSLContextParametersSupplier;
 import org.apache.camel.support.startup.LoggingStartupStepRecorder;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.TimeUtils;
 import org.apache.camel.vault.AwsVaultConfiguration;
 import org.apache.camel.vault.AzureVaultConfiguration;
 import org.apache.camel.vault.GcpVaultConfiguration;
@@ -595,10 +598,79 @@ public final class DefaultConfigurationConfigurer {
             VaultConfiguration vault = camelContext.getVaultConfiguration();
             vault.setHashicorpVaultConfiguration(hashicorp);
         }
+        configureVault(camelContext);
+
         // set the default thread pool profile if defined
         initThreadPoolProfiles(registry, camelContext);
     }
 
+    /**
+     * Configures security vaults such as AWS, Azure, Google and Hashicorp.
+     */
+    protected static void configureVault(CamelContext camelContext) throws Exception {
+        VaultConfiguration vc = camelContext.getVaultConfiguration();
+        if (vc == null) {
+            return;
+        }
+
+        if (vc.aws().isRefreshEnabled()) {
+            Optional<Runnable> task = camelContext.adapt(ExtendedCamelContext.class)
+                    .getPeriodTaskResolver().newInstance("aws-secret-refresh", Runnable.class);
+            if (task.isPresent()) {
+                long period = vc.aws().getRefreshPeriod();
+                Runnable r = task.get();
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Scheduling: {} (period: {})", r, TimeUtils.printDuration(period, false));
+                }
+                if (camelContext.hasService(ContextReloadStrategy.class) == null) {
+                    // refresh is enabled then we need to automatically enable context-reload as well
+                    ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
+                    camelContext.addService(reloader);
+                }
+                PeriodTaskScheduler scheduler = camelContext.adapt(ExtendedCamelContext.class).getPeriodTaskScheduler();
+                scheduler.schedulePeriodTask(r, period);
+            }
+        }
+
+        if (vc.gcp().isRefreshEnabled()) {
+            Optional<Runnable> task = camelContext.adapt(ExtendedCamelContext.class)
+                    .getPeriodTaskResolver().newInstance("gcp-secret-refresh", Runnable.class);
+            if (task.isPresent()) {
+                long period = vc.gcp().getRefreshPeriod();
+                Runnable r = task.get();
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Scheduling: {} (period: {})", r, TimeUtils.printDuration(period, false));
+                }
+                if (camelContext.hasService(ContextReloadStrategy.class) == null) {
+                    // refresh is enabled then we need to automatically enable context-reload as well
+                    ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
+                    camelContext.addService(reloader);
+                }
+                PeriodTaskScheduler scheduler = camelContext.adapt(ExtendedCamelContext.class).getPeriodTaskScheduler();
+                scheduler.schedulePeriodTask(r, period);
+            }
+        }
+
+        if (vc.azure().isRefreshEnabled()) {
+            Optional<Runnable> task = camelContext.adapt(ExtendedCamelContext.class)
+                    .getPeriodTaskResolver().newInstance("azure-secret-refresh", Runnable.class);
+            if (task.isPresent()) {
+                long period = vc.azure().getRefreshPeriod();
+                Runnable r = task.get();
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Scheduling: {} (period: {})", r, TimeUtils.printDuration(period, false));
+                }
+                if (camelContext.hasService(ContextReloadStrategy.class) == null) {
+                    // refresh is enabled then we need to automatically enable context-reload as well
+                    ContextReloadStrategy reloader = new DefaultContextReloadStrategy();
+                    camelContext.addService(reloader);
+                }
+                PeriodTaskScheduler scheduler = camelContext.adapt(ExtendedCamelContext.class).getPeriodTaskScheduler();
+                scheduler.schedulePeriodTask(r, period);
+            }
+        }
+    }
+
     public static void afterPropertiesSet(final CamelContext camelContext) throws Exception {
         // additional configuration
     }


[camel] 02/02: CAMEL-19603: camel-core - configureVault should be done general so its also done for Spring Boot and Quarkus and not only camel-main/camel-jbang.

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.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3fdfe272580113dc493cfeb45bd3f19a93be9c2b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 14 11:48:10 2023 +0200

    CAMEL-19603: camel-core - configureVault should be done general so its also done for Spring Boot and Quarkus and not only camel-main/camel-jbang.
---
 .../src/main/java/org/apache/camel/main/BaseMainSupport.java       | 3 ++-
 .../java/org/apache/camel/main/DefaultConfigurationConfigurer.java | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index aefdfcfe8d2..9235db716ea 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -53,7 +53,6 @@ import org.apache.camel.saga.CamelSagaService;
 import org.apache.camel.spi.AutowiredLifecycleStrategy;
 import org.apache.camel.spi.CamelBeanPostProcessor;
 import org.apache.camel.spi.CamelEvent;
-import org.apache.camel.spi.ContextReloadStrategy;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.Language;
 import org.apache.camel.spi.PackageScanClassResolver;
@@ -1103,6 +1102,8 @@ public abstract class BaseMainSupport extends BaseService {
 
         // and call after all properties are set
         DefaultConfigurationConfigurer.afterPropertiesSet(camelContext);
+        // and configure vault
+        DefaultConfigurationConfigurer.configureVault(camelContext);
     }
 
     private void setRouteTemplateProperties(
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
index eaa8215b10c..6f00bfed03d 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
@@ -577,6 +577,10 @@ public final class DefaultConfigurationConfigurer {
                 devConsoleRegistry.register(console);
             }
         }
+
+        // set the default thread pool profile if defined
+        initThreadPoolProfiles(registry, camelContext);
+
         // vaults
         AwsVaultConfiguration aws = getSingleBeanOfType(registry, AwsVaultConfiguration.class);
         if (aws != null) {
@@ -599,9 +603,6 @@ public final class DefaultConfigurationConfigurer {
             vault.setHashicorpVaultConfiguration(hashicorp);
         }
         configureVault(camelContext);
-
-        // set the default thread pool profile if defined
-        initThreadPoolProfiles(registry, camelContext);
     }
 
     /**