This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new e455aef7d0e CAMEL-21359: camel-spring-boot - Add support for
MainListener
e455aef7d0e is described below
commit e455aef7d0e39e546c6dd0cd47115c6795e7ae12
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jan 31 09:50:36 2025 +0100
CAMEL-21359: camel-spring-boot - Add support for MainListener
---
.../org/apache/camel/spring/boot/CamelAutoConfiguration.java | 1 +
.../spring/boot/CamelSpringBootApplicationController.java | 10 ++++++----
.../camel/spring/boot/CamelSpringBootApplicationListener.java | 1 +
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index 63c342932ee..cd773bdd630 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -109,6 +109,7 @@ public class CamelAutoConfiguration {
CamelContext camelContext = new
SpringBootCamelContext(applicationContext,
config.getSpringboot().isWarnOnEarlyShutdown(), controller);
camelContext.getClock().add(ContextEvents.BOOT, clock);
+ controller.setCamelContext(camelContext);
// bean post processor is created before CamelContext
beanPostProcessor.setCamelContext(camelContext);
camelContext.getCamelContextExtension().addContextPlugin(CamelBeanPostProcessor.class,
beanPostProcessor);
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
index 4164cdbdeea..859f332fb61 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
@@ -33,11 +33,11 @@ import java.util.Map;
public class CamelSpringBootApplicationController implements CamelContextAware
{
private static final Logger LOG =
LoggerFactory.getLogger(CamelSpringBootApplicationController.class);
- private final Main main;
+ private final CamelSpringMain main;
private CamelContext camelContext;
public CamelSpringBootApplicationController(final ApplicationContext
applicationContext) {
- this.main = new CamelSpringMain(applicationContext);
+ this.main = new CamelSpringMain(applicationContext, this);
// inject main listeners
final Map<String, MainListener> listeners =
applicationContext.getBeansOfType(MainListener.class);
for (MainListener listener : listeners.values()) {
@@ -100,9 +100,11 @@ public class CamelSpringBootApplicationController
implements CamelContextAware {
private static class CamelSpringMain extends Main {
final ApplicationContext applicationContext;
+ final CamelSpringBootApplicationController controller;
- public CamelSpringMain(ApplicationContext applicationContext) {
+ public CamelSpringMain(ApplicationContext applicationContext,
CamelSpringBootApplicationController controller) {
this.applicationContext = applicationContext;
+ this.controller = controller;
// use a simple shutdown strategy that does not install any
shutdown hook as spring-boot
// as spring-boot has its own hook we use
@@ -120,7 +122,7 @@ public class CamelSpringBootApplicationController
implements CamelContextAware {
@Override
protected CamelContext createCamelContext() {
- return camelContext;
+ return controller.camelContext;
}
@Override
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
index 90d05f59776..d7e01d5de73 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationListener.java
@@ -25,6 +25,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
import org.apache.camel.ExtendedCamelContext;
import org.apache.camel.StartupListener;
import org.apache.camel.main.MainDurationEventNotifier;