You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2022/01/20 15:54:11 UTC

[camel] branch camel-3.11.x updated: CAMEL-17519: Expose MainSupprt.internalBeforeStart so that it can be overridden

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

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


The following commit(s) were added to refs/heads/camel-3.11.x by this push:
     new e7a851a  CAMEL-17519: Expose MainSupprt.internalBeforeStart so that it can be overridden
e7a851a is described below

commit e7a851aeff3e3ecbaf9d2136377d75caff0e843e
Author: James Netherton <ja...@gmail.com>
AuthorDate: Thu Jan 20 10:02:55 2022 +0000

    CAMEL-17519: Expose MainSupprt.internalBeforeStart so that it can be overridden
---
 .../main/java/org/apache/camel/main/MainSupport.java | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index d49d760..216ecbf 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -102,7 +102,10 @@ public abstract class MainSupport extends BaseMainSupport {
         }
     }
 
-    private void internalBeforeStart() {
+    /**
+     * Tasks to run before start() is called.
+     */
+    protected void internalBeforeStart() {
         // used while waiting to be done
         durationMaxIdleSeconds = mainConfigurationProperties.getDurationMaxIdleSeconds();
         durationMaxMessages = mainConfigurationProperties.getDurationMaxMessages();
@@ -110,10 +113,7 @@ public abstract class MainSupport extends BaseMainSupport {
         durationHitExitCode = mainConfigurationProperties.getDurationHitExitCode();
 
         // register main as bootstrap
-        CamelContext context = getCamelContext();
-        if (context != null) {
-            context.adapt(ExtendedCamelContext.class).addBootstrap(new MainBootstrapCloseable(this));
-        }
+        registerMainBootstrap();
     }
 
     /**
@@ -164,6 +164,16 @@ public abstract class MainSupport extends BaseMainSupport {
         return this::completed;
     }
 
+    /**
+     * Registers {@link MainBootstrapCloseable} with the CamelContext.
+     */
+    protected void registerMainBootstrap() {
+        CamelContext context = getCamelContext();
+        if (context != null) {
+            context.adapt(ExtendedCamelContext.class).addBootstrap(new MainBootstrapCloseable(this));
+        }
+    }
+
     @Deprecated
     public int getDuration() {
         return mainConfigurationProperties.getDurationMaxSeconds();