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 9a138c7172e73c11ac87b0d77109a030698462e3
Author: lburgazzoli <lburgazz...@gmail.com>
AuthorDate: Mon Jun 22 16:40:20 2020 +0200

    Observe Camel's events #1353 (cleanup main)
---
 .../main/deployment/CamelMainObserversTest.java    | 93 ++++++++++++++++++++++
 ...ntDispatcher.java => CamelMainEventBridge.java} | 45 +++++++----
 .../apache/camel/quarkus/main/CamelMainEvents.java | 65 ---------------
 .../camel/quarkus/main/CamelMainRecorder.java      |  2 +-
 .../camel/quarkus/main/events/AfterConfigure.java  | 29 +++++++
 .../camel/quarkus/main/events/AfterStart.java      | 29 +++++++
 .../camel/quarkus/main/events/AfterStop.java       | 29 +++++++
 .../camel/quarkus/main/events/BeforeConfigure.java | 29 +++++++
 .../quarkus/main/events/BeforeInitialize.java      | 29 +++++++
 .../camel/quarkus/main/events/BeforeStart.java     | 29 +++++++
 .../camel/quarkus/main/events/BeforeStop.java      | 29 +++++++
 .../camel/quarkus/main/events/MainEvent.java       | 56 +++++++++++++
 .../apache/camel/quarkus/main/CoreMainTest.java    |  2 +-
 13 files changed, 382 insertions(+), 84 deletions(-)

diff --git 
a/extensions-core/main/deployment/src/test/java/org/apache/camel/quarkus/main/deployment/CamelMainObserversTest.java
 
b/extensions-core/main/deployment/src/test/java/org/apache/camel/quarkus/main/deployment/CamelMainObserversTest.java
new file mode 100644
index 0000000..214b286
--- /dev/null
+++ 
b/extensions-core/main/deployment/src/test/java/org/apache/camel/quarkus/main/deployment/CamelMainObserversTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.quarkus.main.deployment;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.TimeUnit;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.quarkus.main.events.AfterConfigure;
+import org.apache.camel.quarkus.main.events.AfterStart;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+public class CamelMainObserversTest {
+    @RegisterExtension
+    static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+            .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+
+    @Inject
+    EventHandler handler;
+
+    @Test
+    public void testObservers() {
+        await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+            assertThat(handler.builders())
+                    .contains(MyRoutes.class.getName());
+            assertThat(handler.routes())
+                    .contains(MyRoutes.ROUTE_ID);
+        });
+    }
+
+    @ApplicationScoped
+    public static class EventHandler {
+        private final Set<String> builders = new CopyOnWriteArraySet<>();
+        private final Set<String> routes = new CopyOnWriteArraySet<>();
+
+        public void afterConfigure(@Observes AfterConfigure event) {
+            event.getMain().configure().getRoutesBuilders().forEach(
+                    builder -> builders.add(builder.getClass().getName()));
+        }
+
+        public void afterStart(@Observes AfterStart event) {
+            event.getCamelContext(ModelCamelContext.class).getRoutes().forEach(
+                    route -> routes.add(route.getRouteId()));
+        }
+
+        public Set<String> builders() {
+            return builders;
+        }
+
+        public Set<String> routes() {
+            return routes;
+        }
+    }
+
+    public static class MyRoutes extends RouteBuilder {
+        public static String ROUTE_ID = "myRoute";
+        public static String FROM_ENDPOINT = "direct://start";
+
+        @Override
+        public void configure() throws Exception {
+            from(FROM_ENDPOINT)
+                    .routeId(ROUTE_ID)
+                    .log("${body}");
+        }
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEventDispatcher.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEventBridge.java
similarity index 58%
rename from 
extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEventDispatcher.java
rename to 
extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEventBridge.java
index a63ac03..2128008 100644
--- 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEventDispatcher.java
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEventBridge.java
@@ -16,31 +16,48 @@
  */
 package org.apache.camel.quarkus.main;
 
+import java.util.function.Supplier;
+
 import javax.enterprise.inject.spi.BeanManager;
 
 import io.quarkus.arc.Arc;
-import io.quarkus.arc.ArcContainer;
 import org.apache.camel.CamelContext;
 import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.main.MainListener;
 import org.apache.camel.main.MainSupport;
+import org.apache.camel.quarkus.main.events.AfterConfigure;
+import org.apache.camel.quarkus.main.events.AfterStart;
+import org.apache.camel.quarkus.main.events.AfterStop;
+import org.apache.camel.quarkus.main.events.BeforeConfigure;
+import org.apache.camel.quarkus.main.events.BeforeInitialize;
+import org.apache.camel.quarkus.main.events.BeforeStart;
+import org.apache.camel.quarkus.main.events.BeforeStop;
+import org.apache.camel.quarkus.main.events.MainEvent;
+import org.apache.camel.util.function.Suppliers;
 
 /**
  * Bridges {@link MainSupport} events to CDI.
  */
-public class CamelMainEventDispatcher implements 
org.apache.camel.main.MainListener {
+public class CamelMainEventBridge implements MainListener {
+    private final Supplier<BeanManager> beanManager;
+
+    public CamelMainEventBridge() {
+        this.beanManager = Suppliers.memorize(Arc.container()::beanManager);
+    }
+
     @Override
     public void beforeInitialize(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.BeforeInitialize.class, new 
CamelMainEvents.BeforeInitialize());
+        fireEvent(new BeforeInitialize(main));
     }
 
     @Override
     public void beforeConfigure(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.BeforeConfigure.class, new 
CamelMainEvents.BeforeConfigure());
+        fireEvent(new BeforeConfigure(main));
     }
 
     @Override
     public void afterConfigure(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.AfterConfigure.class, new 
CamelMainEvents.AfterConfigure());
+        fireEvent(new AfterConfigure(main));
     }
 
     @Override
@@ -50,31 +67,25 @@ public class CamelMainEventDispatcher implements 
org.apache.camel.main.MainListe
 
     @Override
     public void beforeStart(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.BeforeStart.class, new 
CamelMainEvents.BeforeStart());
+        fireEvent(new BeforeStart(main));
     }
 
     @Override
     public void afterStart(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.AfterStart.class, new 
CamelMainEvents.AfterStart());
+        fireEvent(new AfterStart(main));
     }
 
     @Override
     public void beforeStop(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.BeforeStop.class, new 
CamelMainEvents.BeforeStop());
+        fireEvent(new BeforeStop(main));
     }
 
     @Override
     public void afterStop(BaseMainSupport main) {
-        fireEvent(CamelMainEvents.AfterStop.class, new 
CamelMainEvents.AfterStop());
+        fireEvent(new AfterStop(main));
     }
 
-    private static <T> void fireEvent(Class<T> clazz, T event) {
-        ArcContainer container = Arc.container();
-        if (container != null) {
-            BeanManager beanManager = container.beanManager();
-            if (beanManager != null) {
-                beanManager.getEvent().select(clazz).fire(event);
-            }
-        }
+    private <T extends MainEvent> void fireEvent(T event) {
+        beanManager.get().getEvent().select(MainEvent.class).fire(event);
     }
 }
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEvents.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEvents.java
deleted file mode 100644
index 424206a..0000000
--- 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainEvents.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.quarkus.main;
-
-public final class CamelMainEvents {
-    private CamelMainEvents() {
-    }
-
-    /**
-     * Event fired by {@link CamelMain} before the CamelContext is configured.
-     */
-    public static class BeforeConfigure {
-    }
-
-    /**
-     * Event fired after the the CamelContext has been created and before the
-     * auto-configured step starts.
-     */
-    public static class BeforeInitialize {
-    }
-
-    /**
-     * Event fired by {@link CamelMain} before the CamelContext is being 
created and started.
-     */
-    public static class BeforeStart {
-    }
-
-    /**
-     * Event fired by {@link CamelMain} to configure the created CamelContext.
-     */
-    public static class AfterConfigure {
-    }
-
-    /**
-     * Event fired by {@link CamelMain} after the CamelContext has been 
started.
-     */
-    public static class AfterStart {
-    }
-
-    /**
-     * Event fired by {@link CamelMain} before the CamelContext is being 
stopped.
-     */
-    public static class BeforeStop {
-    }
-
-    /**
-     * Event fired by {@link CamelMain} after the CamelContext has been 
stopped.
-     */
-    public static class AfterStop {
-    }
-}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java
index 4f95759..a2be10c 100644
--- 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/CamelMainRecorder.java
@@ -41,7 +41,7 @@ public class CamelMainRecorder {
             BeanContainer container) {
         CamelMain main = new CamelMain(runtime.getValue());
         main.setRoutesCollector(routesCollector.getValue());
-        main.addMainListener(new CamelMainEventDispatcher());
+        main.addMainListener(new CamelMainEventBridge());
 
         // autowire only non null values as components may have configured
         // through CDI or from a Build Item thus those values should not be
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterConfigure.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterConfigure.java
new file mode 100644
index 0000000..86cb65c
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterConfigure.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.quarkus.main.CamelMain;
+
+/**
+ * Event fired by {@link CamelMain} to configure the created CamelContext.
+ */
+public class AfterConfigure extends MainEvent {
+    public AfterConfigure(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterStart.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterStart.java
new file mode 100644
index 0000000..a7fb30e
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterStart.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.quarkus.main.CamelMain;
+
+/**
+ * Event fired by {@link CamelMain} after the CamelContext has been started.
+ */
+public class AfterStart extends MainEvent {
+    public AfterStart(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterStop.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterStop.java
new file mode 100644
index 0000000..7684fb1
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/AfterStop.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.quarkus.main.CamelMain;
+
+/**
+ * Event fired by {@link CamelMain} after the CamelContext has been stopped.
+ */
+public class AfterStop extends MainEvent {
+    public AfterStop(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeConfigure.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeConfigure.java
new file mode 100644
index 0000000..5e2bf7b
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeConfigure.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.quarkus.main.CamelMain;
+
+/**
+ * Event fired by {@link CamelMain} before the CamelContext is configured.
+ */
+public class BeforeConfigure extends MainEvent {
+    public BeforeConfigure(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeInitialize.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeInitialize.java
new file mode 100644
index 0000000..2ffc05d
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeInitialize.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+
+/**
+ * Event fired after the the CamelContext has been created and before the
+ * auto-configured step starts.
+ */
+public class BeforeInitialize extends MainEvent {
+    public BeforeInitialize(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeStart.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeStart.java
new file mode 100644
index 0000000..fbfc3a2
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeStart.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.quarkus.main.CamelMain;
+
+/**
+ * Event fired by {@link CamelMain} before the CamelContext is being created 
and started.
+ */
+public class BeforeStart extends MainEvent {
+    public BeforeStart(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeStop.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeStop.java
new file mode 100644
index 0000000..fba7384
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/BeforeStop.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.quarkus.main.CamelMain;
+
+/**
+ * Event fired by {@link CamelMain} before the CamelContext is being stopped.
+ */
+public class BeforeStop extends MainEvent {
+    public BeforeStop(BaseMainSupport main) {
+        super(main);
+    }
+}
diff --git 
a/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/MainEvent.java
 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/MainEvent.java
new file mode 100644
index 0000000..82f1e83
--- /dev/null
+++ 
b/extensions-core/main/runtime/src/main/java/org/apache/camel/quarkus/main/events/MainEvent.java
@@ -0,0 +1,56 @@
+/*
+ * 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.quarkus.main.events;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.main.BaseMainSupport;
+import org.apache.camel.spi.CamelEvent;
+import org.apache.camel.spi.HasCamelContext;
+
+/**
+ * A base {@link CamelEvent} for {@link BaseMainSupport} events.
+ */
+public class MainEvent implements CamelEvent, HasCamelContext {
+    private final BaseMainSupport main;
+
+    public MainEvent(BaseMainSupport main) {
+        this.main = main;
+    }
+
+    public BaseMainSupport getMain() {
+        return this.main;
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        return getMain().getCamelContext();
+    }
+
+    public <T extends CamelContext> T getCamelContext(Class<T> type) {
+        return type.cast(getMain().getCamelContext());
+    }
+
+    @Override
+    public Type getType() {
+        return Type.Custom;
+    }
+
+    @Override
+    public Object getSource() {
+        return getMain();
+    }
+}
diff --git 
a/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
 
b/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
index 1cbc5af..448b22e 100644
--- 
a/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
+++ 
b/integration-tests/main/src/test/java/org/apache/camel/quarkus/main/CoreMainTest.java
@@ -91,7 +91,7 @@ public class CoreMainTest {
         
assertThat(p.getString("routes-collector.type-xml")).isEqualTo(DisabledXMLRoutesDefinitionLoader.class.getName());
 
         assertThat(p.getList("listeners", String.class))
-                .containsAnyOf(CamelMainEventDispatcher.class.getName(), 
CustomMainListener.class.getName());
+                .containsAnyOf(CamelMainEventBridge.class.getName(), 
CustomMainListener.class.getName());
         assertThat(p.getList("routeBuilders", String.class))
                 .contains(CamelRoute.class.getName())
                 .doesNotContain(CamelRouteFiltered.class.getName());

Reply via email to