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 2019/10/28 11:06:48 UTC

[camel-quarkus] 01/02: main: fire start event before context post processor is fired

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-quarkus.git

commit 1a4c361eff4b6b8a18cd2c3b10ffd152638d347c
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sun Oct 27 19:43:11 2019 +0100

    main: fire start event before context post processor is fired
---
 .../java/org/apache/camel/quarkus/core/CamelMain.java    |  6 +-----
 .../quarkus/core/runtime/support/SupportListener.java    | 16 +++++++++++++---
 .../java/org/apache/camel/quarkus/core/CamelTest.java    |  4 ++--
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java
index 7e5c7f9..147dc6e 100644
--- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java
+++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelMain.java
@@ -38,16 +38,12 @@ public class CamelMain extends BaseMainSupport implements CamelContextAware {
     }
 
     @Override
-    protected void doInit() throws Exception {
-        postProcessCamelContext(getCamelContext());
-    }
-
-    @Override
     protected void doStart() throws Exception {
         for (MainListener listener : listeners) {
             listener.beforeStart(this);
         }
 
+        postProcessCamelContext(getCamelContext());
         getCamelContext().start();
 
         for (MainListener listener : listeners) {
diff --git a/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java b/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java
index 81f3c41..975834e 100644
--- a/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java
+++ b/integration-tests/core-main/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/support/SupportListener.java
@@ -28,9 +28,9 @@ public class SupportListener implements MainListener {
             context.addRoutes(new RouteBuilder() {
                 @Override
                 public void configure() throws Exception {
-                    from("timer:listener")
-                        .id("listener")
-                        .to("log:listener");
+                    from("timer:configure")
+                        .id("configure")
+                        .to("log:configure");
                 }
             });
         } catch (Exception e) {
@@ -40,6 +40,7 @@ public class SupportListener implements MainListener {
 
     @Override
     public void beforeStart(BaseMainSupport main) {
+        main.addRoutesBuilder(new MyBuilder());
     }
 
     @Override
@@ -53,4 +54,13 @@ public class SupportListener implements MainListener {
     @Override
     public void afterStop(BaseMainSupport main) {
     }
+
+    public static class MyBuilder extends RouteBuilder {
+        @Override
+        public void configure() throws Exception {
+            from("timer:beforeStart")
+                .id("beforeStart")
+                .to("log:beforeStart");
+        }
+    }
 }
diff --git a/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java b/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
index 3d2a458..934b44c 100644
--- a/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
+++ b/integration-tests/core-main/test/src/test/java/org/apache/camel/quarkus/core/CamelTest.java
@@ -73,9 +73,9 @@ public class CamelTest {
         assertThat(p.getList("listeners", String.class))
             .containsOnly(CamelMainEventDispatcher.class.getName(), SupportListener.class.getName());
         assertThat(p.getList("routeBuilders", String.class))
-            .containsOnly(CamelRoute.class.getName());
+            .containsOnly(CamelRoute.class.getName(), SupportListener.MyBuilder.class.getName());
         assertThat(p.getList("routes", String.class))
-            .containsOnly("keep-alive", "listener", "my-xml-route");
+            .containsOnly("keep-alive", "configure", "beforeStart", "my-xml-route");
 
         assertThat(p.getBoolean("autoConfigurationLogSummary")).isFalse();