From f2e3577c39952ed202aaa2e862b716a2fdb43ecc Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Fri, 29 Sep 2023 15:51:35 +0200 Subject: [PATCH] CAMEL-19933: camel-jbang - Register bean model when loading XML osgi beans, also when ignore loading error. --- .../src/main/java/org/apache/camel/main/KameletMain.java | 1 + .../camel/main/xml/blueprint/BlueprintXmlBeansHandler.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java index 5417b7c4f6107..231d7cdd769d2 100644 --- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java +++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java @@ -639,6 +639,7 @@ protected void configureRoutesLoader(CamelContext camelContext) { } else { routesLoader = new DependencyDownloaderRoutesLoader(camelContext); } + routesLoader.setIgnoreLoadingError(this.mainConfigurationProperties.isRoutesCollectorIgnoreLoadingError()); // use resolvers that can auto downloaded camelContext.getCamelContextExtension() diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java index c018de3addc2a..f7e298da9a413 100644 --- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java +++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/xml/blueprint/BlueprintXmlBeansHandler.java @@ -37,6 +37,7 @@ import org.apache.camel.spi.Resource; import org.apache.camel.spi.ResourceLoader; import org.apache.camel.support.ObjectHelper; +import org.apache.camel.support.PluginHelper; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.util.KeyValueHolder; import org.apache.camel.util.StringHelper; @@ -258,6 +259,11 @@ private void registerBeanDefinition(CamelContext camelContext, RegistryBeanDefin if (delayIfFailed) { delayedRegistrations.add(def); } else { + boolean ignore = PluginHelper.getRoutesLoader(camelContext).isIgnoreLoadingError(); + if (ignore) { + // still add bean if we are ignore loading as we want to know about all beans if possible + addBeanToCamelModel(camelContext, name, def); + } LOG.warn("Error creating bean: {} due to: {}. This exception is ignored.", type, e.getMessage(), e); } }