From 8aea1b864ab8056abdc818511bd73baeee4ff798 Mon Sep 17 00:00:00 2001 From: croway Date: Wed, 2 Sep 2026 15:08:32 +0200 Subject: [PATCH 1/3] CAMEL-24501: Report starter configuration options that cannot be bound The generated starter code discarded configuration in two places, in both cases without a log line, so an option that never took effect looked exactly like one that did. The generated *ComponentConverter, *DataFormatConverter and *LanguageConverter classes resolve the bean reference that an option of a complex (object) type is configured with. They returned null for any value that did not start with #, and for a value naming a bean that does not exist, so a typo in the bean id produced a component with the option unset. The generated convert() body now delegates to the new BeanReferenceHelper, which resolves #bean:id, #id, a plain bean id, #autowired and #type:fqn, and throws IllegalArgumentException naming the value, the target type and the configuration prefix when the value cannot be resolved. This also drops the per-type switch, which returned null for a target type it did not list. The generated customizers copied the whole configuration onto the target with CamelPropertiesHelper.copyProperties, which binds with failIfNotSet=false, so an option with no matching setter on the target was dropped. The same mojo emits failIfNotSet=true for camel.rest.*, so the two disagreed. The customizers now call the new CamelPropertiesHelper.copyConfigurationProperties, which: - removes the options owned by the auto configuration layer itself (enabled and customizer) before binding, as they are not options on the Camel target; - fails with IllegalArgumentException when an option the application configured itself cannot be set; - logs at DEBUG when an option that only carries its catalog default cannot be set, since the target keeps its own default and there is nothing the application can do about it. Telling the two apart uses the Spring ConfigurationPropertySources, so a catalog default that has never been bindable (camel.language.simple.trim, for example, which is an option of the expression model rather than of SimpleLanguage) does not turn into a startup failure for every application. Blanket strict binding needs the catalog defaults to stop being materialised as field initializers on the configuration classes first, which is left for a follow-up. camel.springboot.lenient-configuration-binding=true logs an explicitly configured option at WARN and continues, instead of failing. The language converter template also referenced an applicationContext field it did not declare; no starter currently generates a language converter, so this was latent. Co-Authored-By: Claude Opus 5 (cherry picked from commit b689587a76a1a09374deb0eab089301348513ed2) --- ...HttpComponentBeanReferenceBindingTest.java | 92 ++++++++++ .../spring/boot/util/BeanReferenceHelper.java | 122 +++++++++++++ .../boot/util/CamelPropertiesHelper.java | 158 +++++++++++++++++ .../boot/util/BeanReferenceHelperTest.java | 160 ++++++++++++++++++ ...melPropertiesHelperLenientBindingTest.java | 63 +++++++ .../boot/util/CamelPropertiesHelperTest.java | 110 +++++++++++- .../SpringBootAutoConfigurationMojo.java | 157 +++++++---------- .../SpringBootAutoConfigurationMojoTest.java | 81 +++++++++ 8 files changed, 843 insertions(+), 100 deletions(-) create mode 100644 components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java create mode 100644 core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java create mode 100644 core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java create mode 100644 core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperLenientBindingTest.java create mode 100644 tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java diff --git a/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java b/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java new file mode 100644 index 000000000000..cc2859adfddb --- /dev/null +++ b/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java @@ -0,0 +1,92 @@ +/* + * 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.component.http.springboot; + +import org.apache.camel.support.jsse.SSLContextParameters; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * A complex (object) typed option such as {@code sslContextParameters} is configured with a reference to a bean in the + * Spring application context. A value that cannot be resolved must be reported, not silently turned into null. + */ +class HttpComponentBeanReferenceBindingTest { + + private final ApplicationContextRunner runner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(TestConfiguration.class)) + .withUserConfiguration(HttpComponentConverter.class); + + @Test + void testBeanSyntaxIsResolved() { + runner.withPropertyValues("camel.component.http.ssl-context-parameters=#bean:mySslContextParameters") + .run(context -> { + assertThat(context).hasNotFailed(); + assertThat(context.getBean(HttpComponentConfiguration.class).getSslContextParameters()) + .isSameAs(context.getBean("mySslContextParameters")); + }); + } + + @Test + void testHashSyntaxIsResolved() { + runner.withPropertyValues("camel.component.http.ssl-context-parameters=#mySslContextParameters") + .run(context -> { + assertThat(context).hasNotFailed(); + assertThat(context.getBean(HttpComponentConfiguration.class).getSslContextParameters()) + .isSameAs(context.getBean("mySslContextParameters")); + }); + } + + @Test + void testPlainBeanIdIsResolved() { + // a plain bean id used to be silently converted to null + runner.withPropertyValues("camel.component.http.ssl-context-parameters=mySslContextParameters") + .run(context -> { + assertThat(context).hasNotFailed(); + assertThat(context.getBean(HttpComponentConfiguration.class).getSslContextParameters()) + .isSameAs(context.getBean("mySslContextParameters")); + }); + } + + @Test + void testUnresolvableValueIsReported() { + // a typo used to leave the option unset without any error + runner.withPropertyValues("camel.component.http.ssl-context-parameters=#bean:mySslContextParametrs") + .run(context -> { + assertThat(context).hasFailed(); + assertThat(context.getStartupFailure()) + .hasStackTraceContaining("mySslContextParametrs") + .hasStackTraceContaining("camel.component.http"); + }); + } + + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(HttpComponentConfiguration.class) + static class TestConfiguration { + + @Bean(name = "mySslContextParameters") + SSLContextParameters mySslContextParameters() { + return new SSLContextParameters(); + } + } + +} diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java new file mode 100644 index 000000000000..63de31c97e5c --- /dev/null +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java @@ -0,0 +1,122 @@ +/* + * 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.spring.boot.util; + +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.core.convert.TypeDescriptor; +import org.springframework.util.ClassUtils; + +/** + * Resolves the bean references that Camel configuration options of a complex (object) type are configured with in + * application.properties, such as + * camel.component.netty-http.ssl-context-parameters = #bean:mySslContextParameters. + *

+ * This is used by the generated *ComponentConverter, *DataFormatConverter and + * *LanguageConverter classes in the Camel Spring Boot starters. The following syntaxes are supported: + *

+ * A configured value that cannot be resolved is reported by throwing an {@link IllegalArgumentException}, so a typo in + * a configuration file is not silently turned into a null value. + */ +public final class BeanReferenceHelper { + + private static final String BEAN_PREFIX = "#bean:"; + private static final String TYPE_PREFIX = "#type:"; + private static final String CLASS_PREFIX = "#class:"; + private static final String AUTOWIRED = "#autowired"; + + private BeanReferenceHelper() { + } + + /** + * Resolves the given configured value as a bean from the Spring application context. + * + * @param applicationContext + * the Spring application context + * @param source + * the configured value, such as #bean:myBean + * @param targetType + * the type the option expects + * @param propertyPrefix + * the configuration prefix the option belongs to, such as + * camel.component.netty-http, used to make the error message actionable + * + * @return the resolved bean, or null if no value was configured + * + * @throws IllegalArgumentException + * if a value was configured but cannot be resolved to a bean of the target type + */ + public static Object resolveBeanReference(ApplicationContext applicationContext, Object source, + TypeDescriptor targetType, String propertyPrefix) { + if (source == null) { + return null; + } + String value = source.toString().trim(); + if (value.isEmpty()) { + return null; + } + Class type = targetType != null ? targetType.getObjectType() : Object.class; + if (applicationContext == null) { + throw new IllegalArgumentException( + message(value, type, propertyPrefix, "there is no Spring application context available")); + } + if (value.startsWith(CLASS_PREFIX)) { + throw new IllegalArgumentException(message(value, type, propertyPrefix, + "the #class: syntax is not supported here, declare the bean in the Spring application context instead")); + } + try { + if (AUTOWIRED.equalsIgnoreCase(value)) { + return applicationContext.getBean(type); + } + if (value.startsWith(TYPE_PREFIX)) { + String fqn = value.substring(TYPE_PREFIX.length()).trim(); + return applicationContext.getBean(ClassUtils.forName(fqn, applicationContext.getClassLoader())); + } + String id = value; + if (id.startsWith(BEAN_PREFIX)) { + id = id.substring(BEAN_PREFIX.length()).trim(); + } else if (id.startsWith("#")) { + id = id.substring(1).trim(); + } + if (id.isEmpty()) { + throw new IllegalArgumentException(message(value, type, propertyPrefix, "the bean id is empty")); + } + return applicationContext.getBean(id, type); + } catch (BeansException | ClassNotFoundException | LinkageError e) { + throw new IllegalArgumentException(message(value, type, propertyPrefix, e.getMessage()), e); + } + } + + private static String message(String value, Class type, String propertyPrefix, String reason) { + StringBuilder sb = new StringBuilder(256); + sb.append("Cannot resolve value [").append(value).append("] as a bean of type [").append(type.getName()) + .append("]"); + if (propertyPrefix != null && !propertyPrefix.isEmpty()) { + sb.append(" while configuring ").append(propertyPrefix).append(".*"); + } + sb.append(". Use #bean:myBeanId (or #myBeanId, or myBeanId) to refer to a bean in the Spring application" + + " context, or #autowired or #type:com.foo.MyType to refer to it by type. Reason: ").append(reason); + return sb.toString(); + } + +} diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java index 31d2b05cdaa5..66b1601fd29c 100644 --- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java @@ -16,27 +16,174 @@ */ package org.apache.camel.spring.boot.util; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Locale; import java.util.Map; +import java.util.Optional; +import java.util.Set; import org.apache.camel.CamelContext; import org.apache.camel.Component; import org.apache.camel.PropertyBindingException; import org.apache.camel.spi.BeanIntrospection; +import org.apache.camel.spi.PropertiesComponent; import org.apache.camel.spi.PropertyConfigurer; import org.apache.camel.support.PluginHelper; import org.apache.camel.support.PropertyBindingSupport; import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.util.ObjectHelper; +import org.apache.camel.util.StringHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.source.ConfigurationPropertyName; +import org.springframework.boot.context.properties.source.ConfigurationPropertySource; +import org.springframework.boot.context.properties.source.ConfigurationPropertySources; +import org.springframework.context.ApplicationContext; /** * To help configuring Camel properties that have been defined in Spring Boot configuration files. */ public final class CamelPropertiesHelper { + /** + * Property to turn off failing fast when an explicitly configured Spring Boot option cannot be set on the Camel + * component, data format or language it belongs to. When lenient, such an option is logged at WARN level and + * ignored, which is close to the behaviour before Camel 4.23, where it was dropped without any log line. + */ + public static final String LENIENT_CONFIGURATION_BINDING = "camel.springboot.lenient-configuration-binding"; + + private static final Logger LOG = LoggerFactory.getLogger(CamelPropertiesHelper.class); + + /** + * Options that belong to the Spring Boot auto configuration layer itself, and therefore are not options on the + * Camel component, data format or language being configured. + */ + private static final Set AUTO_CONFIGURATION_OPTIONS = Set.of("enabled", "customizer"); + private CamelPropertiesHelper() { } + /** + * Copies the options from a generated Spring Boot configuration class onto the Camel component, data format or + * language it configures. + *

+ * The options that belong to the auto configuration layer itself (enabled and customizer) are + * removed first, as they are not options on the target bean. + *

+ * An option that cannot be set on the target and that the application configured explicitly fails fast with an + * {@link IllegalArgumentException}, instead of being dropped without a trace. An option that cannot be set and + * that only carries its catalog default is logged at DEBUG, as there is nothing the application can do about it + * and the target keeps its own default. Set {@link #LENIENT_CONFIGURATION_BINDING} to true to log an + * explicitly configured option at WARN and continue, instead of failing. + * + * @param camelContext + * the CamelContext + * @param applicationContext + * the Spring application context, used to tell an explicitly configured option from a + * catalog default + * @param propertyPrefix + * the configuration prefix of the source, such as camel.component.http + * @param source + * the Spring Boot configuration class + * @param target + * the Camel component, data format or language to configure + */ + public static void copyConfigurationProperties(CamelContext camelContext, ApplicationContext applicationContext, + String propertyPrefix, Object source, Object target) { + ObjectHelper.notNull(camelContext, "camel context"); + ObjectHelper.notNull(source, "source"); + ObjectHelper.notNull(target, "target"); + + Map properties = getNonNullProperties(camelContext, source); + properties.keySet().removeIf(key -> AUTO_CONFIGURATION_OPTIONS.contains(key.toLowerCase(Locale.US))); + + // the options that could be set are removed from the map, so what is left could not be set + doSetCamelProperties(camelContext, target, properties, false, false); + if (properties.isEmpty()) { + return; + } + + boolean lenient = isLenientBinding(camelContext); + List failed = new ArrayList<>(); + for (Map.Entry entry : properties.entrySet()) { + String name = entry.getKey(); + Object value = entry.getValue(); + if (isExplicitlyConfigured(applicationContext, propertyPrefix, name)) { + if (lenient) { + LOG.warn("Cannot configure option [{}] with value [{}] on [{}]. This option is ignored.", + optionKey(propertyPrefix, name), value, ObjectHelper.classCanonicalName(target)); + } else { + failed.add(optionKey(propertyPrefix, name) + " = " + value); + } + } else { + // only the catalog default was carried, so the target keeps its own default + LOG.debug("Cannot configure option [{}] with default value [{}] on [{}]. This option is ignored.", + optionKey(propertyPrefix, name), value, ObjectHelper.classCanonicalName(target)); + } + } + if (!failed.isEmpty()) { + throw new IllegalArgumentException( + "Cannot configure " + failed + " as the bean class [" + ObjectHelper.classCanonicalName(target) + + "] has no suitable setter method, or it is not possible to lookup a bean with that id in the" + + " Spring Boot registry. Remove or correct the option, or set " + + LENIENT_CONFIGURATION_BINDING + "=true to ignore it."); + } + } + + private static String optionKey(String propertyPrefix, String name) { + String dashed = StringHelper.camelCaseToDash(name); + return propertyPrefix != null && !propertyPrefix.isEmpty() ? propertyPrefix + "." + dashed : dashed; + } + + /** + * Whether the application configured the given option itself, as opposed to the option only carrying the default + * value the generator took from the Camel catalog. + */ + private static boolean isExplicitlyConfigured(ApplicationContext applicationContext, String propertyPrefix, + String name) { + if (applicationContext == null || propertyPrefix == null || propertyPrefix.isEmpty()) { + return false; + } + try { + ConfigurationPropertyName key + = ConfigurationPropertyName.of(optionKey(propertyPrefix, name).toLowerCase(Locale.US)); + for (ConfigurationPropertySource source : ConfigurationPropertySources + .get(applicationContext.getEnvironment())) { + if (source.getConfigurationProperty(key) != null) { + return true; + } + } + } catch (Exception e) { + LOG.debug("Cannot determine whether {}.{} was configured due to: {}", propertyPrefix, name, + e.getMessage()); + } + return false; + } + + private static boolean isLenientBinding(CamelContext camelContext) { + try { + PropertiesComponent pc = camelContext.getPropertiesComponent(); + if (pc != null) { + Optional value = pc.resolveProperty(LENIENT_CONFIGURATION_BINDING); + if (value.isPresent()) { + return "true".equalsIgnoreCase(value.get().trim()); + } + } + } catch (Exception e) { + LOG.debug("Cannot resolve {} due to: {}. Using strict configuration binding.", + LENIENT_CONFIGURATION_BINDING, e.getMessage()); + } + return false; + } + + /** + * Copies all non-null options from the source onto the target, ignoring any option that cannot be set. + * + * @see #copyConfigurationProperties(CamelContext, ApplicationContext, String, Object, Object) for copying a + * generated Spring Boot configuration class onto the Camel bean it configures + */ @SuppressWarnings({ "unchecked" }) public static void copyProperties(CamelContext camelContext, Object source, Object target) { ObjectHelper.notNull(camelContext, "camel context"); @@ -94,6 +241,11 @@ public static void copyProperties(CamelContext camelContext, Object source, Obje */ public static boolean setCamelProperties(CamelContext context, Object target, Map properties, boolean failIfNotSet) { + return doSetCamelProperties(context, target, properties, failIfNotSet, true); + } + + private static boolean doSetCamelProperties(CamelContext context, Object target, Map properties, + boolean failIfNotSet, boolean warnIfNotSet) { ObjectHelper.notNull(context, "context"); ObjectHelper.notNull(target, "target"); ObjectHelper.notNull(properties, "properties"); @@ -139,6 +291,12 @@ public static boolean setCamelProperties(CamelContext context, Object target, Ma + "] as the bean class [" + ObjectHelper.classCanonicalName(target) + "] has no suitable setter method, or not possible to lookup a bean with the id [" + stringValue + "] in Spring Boot registry"); + } else if (warnIfNotSet) { + LOG.warn( + "Cannot configure option [{}] with value [{}] as the bean class [{}] has no suitable setter method," + + " or not possible to lookup a bean with the id [{}] in Spring Boot registry." + + " This option is ignored.", + name, stringValue, ObjectHelper.classCanonicalName(target), stringValue); } } diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java new file mode 100644 index 000000000000..ac8b807c82ad --- /dev/null +++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java @@ -0,0 +1,160 @@ +/* + * 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.spring.boot.util; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.TypeDescriptor; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class BeanReferenceHelperTest { + + private static final String PREFIX = "camel.component.myComponent"; + + private AnnotationConfigApplicationContext applicationContext; + + public static class MyOption { + } + + public static class MyOtherOption { + } + + @Configuration + static class TestConfiguration { + @Bean(name = "myOption") + MyOption myOption() { + return new MyOption(); + } + + @Bean(name = "myOtherOption") + MyOtherOption myOtherOption() { + return new MyOtherOption(); + } + } + + @BeforeEach + public void setUp() { + applicationContext = new AnnotationConfigApplicationContext(TestConfiguration.class); + } + + @AfterEach + public void tearDown() { + if (applicationContext != null) { + applicationContext.close(); + } + } + + private Object resolve(Object source) { + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, + TypeDescriptor.valueOf(MyOption.class), PREFIX); + } + + @Test + public void testNullAndEmptyAreNotConfigured() { + assertNull(resolve(null)); + assertNull(resolve("")); + assertNull(resolve(" ")); + } + + @Test + public void testBeanSyntax() { + assertSame(applicationContext.getBean("myOption"), resolve("#bean:myOption")); + } + + @Test + public void testHashSyntax() { + assertSame(applicationContext.getBean("myOption"), resolve("#myOption")); + } + + @Test + public void testPlainBeanId() { + // a plain bean id used to be silently converted to null + assertSame(applicationContext.getBean("myOption"), resolve("myOption")); + } + + @Test + public void testAutowired() { + assertSame(applicationContext.getBean("myOption"), resolve("#autowired")); + } + + @Test + public void testType() { + assertSame(applicationContext.getBean("myOption"), + resolve("#type:" + MyOption.class.getName())); + } + + @Test + public void testUnknownBeanFailsClosed() { + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> resolve("#bean:noSuchBean")); + assertTrue(e.getMessage().contains("#bean:noSuchBean"), e.getMessage()); + assertTrue(e.getMessage().contains(MyOption.class.getName()), e.getMessage()); + assertTrue(e.getMessage().contains(PREFIX), e.getMessage()); + assertTrue(e.getMessage().contains("#bean:myBeanId"), e.getMessage()); + } + + @Test + public void testTypoedPlainValueFailsClosed() { + // this is the case that used to end up as a null value on the component + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> resolve("myOptionn")); + assertTrue(e.getMessage().contains("myOptionn"), e.getMessage()); + } + + @Test + public void testWrongBeanTypeFailsClosed() { + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> resolve("#myOtherOption")); + assertTrue(e.getMessage().contains("myOtherOption"), e.getMessage()); + assertTrue(e.getMessage().contains(MyOption.class.getName()), e.getMessage()); + } + + @Test + public void testEmptyBeanIdFailsClosed() { + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> resolve("#bean:")); + assertTrue(e.getMessage().contains("the bean id is empty"), e.getMessage()); + } + + @Test + public void testClassSyntaxIsReported() { + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, + () -> resolve("#class:" + MyOption.class.getName())); + assertTrue(e.getMessage().contains("#class: syntax is not supported"), e.getMessage()); + } + + @Test + public void testUnknownTypeFailsClosed() { + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, + () -> resolve("#type:com.foo.DoesNotExist")); + assertTrue(e.getMessage().contains("com.foo.DoesNotExist"), e.getMessage()); + } + + @Test + public void testMessageMentionsTheTargetType() { + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, + () -> BeanReferenceHelper.resolveBeanReference(applicationContext, "nope", + TypeDescriptor.valueOf(MyOtherOption.class), PREFIX)); + assertEquals(true, e.getMessage().contains(MyOtherOption.class.getName())); + } + +} diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperLenientBindingTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperLenientBindingTest.java new file mode 100644 index 000000000000..eed5c3dcc5a6 --- /dev/null +++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperLenientBindingTest.java @@ -0,0 +1,63 @@ +/* + * 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.spring.boot.util; + +import org.apache.camel.CamelContext; +import org.apache.camel.test.spring.junit5.CamelSpringBootTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.test.annotation.DirtiesContext; + +/** + * Verifies that {@link CamelPropertiesHelper#LENIENT_CONFIGURATION_BINDING} restores the pre Camel 4.23 behaviour of + * ignoring options that cannot be set on the Camel bean being configured. + */ +@CamelSpringBootTest +@DirtiesContext +@SpringBootApplication +@SpringBootTest( + classes = { CamelPropertiesHelperLenientBindingTest.class }, + properties = { + "camel.springboot.lenient-configuration-binding = true", + "camel.test.my-config.no-such-option-on-the-target = bar" }) +public class CamelPropertiesHelperLenientBindingTest { + + @Autowired + ApplicationContext applicationContext; + + @Autowired + CamelContext camelContext; + + @Test + public void testConfiguredOptionThatCannotBeSetIsIgnoredWhenLenient() { + CamelPropertiesHelperTest.MyClass target = new CamelPropertiesHelperTest.MyClass(); + + CamelPropertiesHelperTest.MyDriftedConfiguration config = new CamelPropertiesHelperTest.MyDriftedConfiguration(); + config.setName("Donald Duck"); + config.setNoSuchOptionOnTheTarget("bar"); + + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + CamelPropertiesHelperTest.PREFIX, config, target); + + Assertions.assertEquals("Donald Duck", target.getName()); + } + +} diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java index 1bd72ae811e5..99000ced2dfe 100644 --- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java +++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java @@ -20,6 +20,7 @@ import java.util.LinkedHashMap; import java.util.Map; import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.camel.test.spring.junit5.CamelSpringBootTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -34,9 +35,13 @@ @CamelSpringBootTest @DirtiesContext @SpringBootApplication -@SpringBootTest(classes = { CamelPropertiesHelperTest.TestConfiguration.class }) +@SpringBootTest( + classes = { CamelPropertiesHelperTest.TestConfiguration.class }, + properties = { "camel.test.my-config.no-such-option-on-the-target = bar" }) public class CamelPropertiesHelperTest { + static final String PREFIX = "camel.test.my-config"; + @Autowired ApplicationContext context; @@ -54,6 +59,58 @@ MyOption myCoolBean() { public static class MyOption { } + /** + * Mimics a generated {@code *ComponentConfiguration} class: the auto configuration layer options + * (enabled/customizer) are inherited and are not options on the Camel target bean. + */ + public static class MyConfiguration extends ComponentConfigurationPropertiesCommon { + + private String name; + private MyOption option; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public MyOption getOption() { + return option; + } + + public void setOption(MyOption option) { + this.option = option; + } + } + + /** + * A configuration class holding an option that does not exist on the target bean, which is what generator or + * catalog drift looks like at runtime. + */ + public static class MyDriftedConfiguration extends MyConfiguration { + + private String noSuchOptionOnTheTarget; + private String anotherOptionOnlyCarryingItsDefault; + + public String getNoSuchOptionOnTheTarget() { + return noSuchOptionOnTheTarget; + } + + public void setNoSuchOptionOnTheTarget(String noSuchOptionOnTheTarget) { + this.noSuchOptionOnTheTarget = noSuchOptionOnTheTarget; + } + + public String getAnotherOptionOnlyCarryingItsDefault() { + return anotherOptionOnlyCarryingItsDefault; + } + + public void setAnotherOptionOnlyCarryingItsDefault(String anotherOptionOnlyCarryingItsDefault) { + this.anotherOptionOnlyCarryingItsDefault = anotherOptionOnlyCarryingItsDefault; + } + } + public static class MyClass { private int id; @@ -226,6 +283,57 @@ public void testSetCamelPropertiesUnknownOption() throws Exception { Assertions.assertSame(context.getBean("myCoolOption"), target.getOption()); } + @Test + public void testCopyConfigurationPropertiesIgnoresAutoConfigurationOptions() { + MyClass target = new MyClass(); + + MyConfiguration config = new MyConfiguration(); + config.setName("Donald Duck"); + config.setOption(context.getBean("myCoolOption", MyOption.class)); + + // enabled and customizer are always set on a generated configuration class, and must not be + // attempted on the target bean + Assertions.assertTrue(config.isEnabled()); + Assertions.assertNotNull(config.getCustomizer()); + + CamelPropertiesHelper.copyConfigurationProperties(camelContext, context, PREFIX, config, target); + + Assertions.assertEquals("Donald Duck", target.getName()); + Assertions.assertSame(context.getBean("myCoolOption"), target.getOption()); + } + + @Test + public void testCopyConfigurationPropertiesFailsOnConfiguredOptionThatCannotBeSet() { + MyClass target = new MyClass(); + + MyDriftedConfiguration config = new MyDriftedConfiguration(); + config.setName("Donald Duck"); + // camel.test.my-config.no-such-option-on-the-target is set on the test application + config.setNoSuchOptionOnTheTarget("bar"); + + IllegalArgumentException e = Assertions.assertThrows(IllegalArgumentException.class, + () -> CamelPropertiesHelper.copyConfigurationProperties(camelContext, context, PREFIX, config, + target)); + Assertions.assertTrue(e.getMessage().contains("camel.test.my-config.no-such-option-on-the-target"), + e.getMessage()); + Assertions.assertTrue(e.getMessage().contains(CamelPropertiesHelper.LENIENT_CONFIGURATION_BINDING), + e.getMessage()); + } + + @Test + public void testCopyConfigurationPropertiesIgnoresDefaultThatCannotBeSet() { + MyClass target = new MyClass(); + + MyDriftedConfiguration config = new MyDriftedConfiguration(); + config.setName("Donald Duck"); + // nothing configured this one, so it only carries a catalog default and must not break startup + config.setAnotherOptionOnlyCarryingItsDefault("false"); + + CamelPropertiesHelper.copyConfigurationProperties(camelContext, context, PREFIX, config, target); + + Assertions.assertEquals("Donald Duck", target.getName()); + } + @Test public void testSetCamelPropertiesUnknownOptionIgnore() throws Exception { MyClass target = new MyClass(); diff --git a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java index fc576b9d16b5..7bcbf36bc62a 100644 --- a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java +++ b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java @@ -540,7 +540,7 @@ private void executeComponents(JarFile componentJar, Map createLanguageConfigurationSource(pkg, model, overrideLanguageName); createLanguageAutoConfigurationSource(pkg, model, overrideLanguageName, complexOptions); if (complexOptions) { - createLanguageConverterSource(pkg, model); + createLanguageConverterSource(pkg, model, overrideLanguageName); } createLanguageSpringFactorySource(pkg, model); } @@ -692,10 +692,7 @@ private void createComponentConfigurationSource(String packageName, ComponentMod } javaClass.getJavaDoc().setText(doc); - String prefix = "camel.component." - + camelCaseToDash(overrideComponentName != null ? overrideComponentName : model.getScheme()); - // make sure prefix is in lower case - prefix = prefix.toLowerCase(Locale.US); + String prefix = componentPropertyPrefix(model, overrideComponentName); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties") .setStringValue("prefix", prefix); @@ -1115,10 +1112,7 @@ private void createDataFormatConfigurationSource(String packageName, DataFormatM } javaClass.getJavaDoc().setFullText(doc); - String prefix = "camel.dataformat." - + camelCaseToDash(overrideDataFormatName != null ? overrideDataFormatName : model.getName()); - // make sure prefix is in lower case - prefix = prefix.toLowerCase(Locale.US); + String prefix = dataFormatPropertyPrefix(model, overrideDataFormatName); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties") .setStringValue("prefix", prefix); @@ -1222,10 +1216,7 @@ private void createLanguageConfigurationSource(String packageName, LanguageModel } javaClass.getJavaDoc().setFullText(doc); - String prefix = "camel.language." - + (camelCaseToDash(overrideLanguageName != null ? overrideLanguageName : model.getName())); - // make sure prefix is in lower case - prefix = prefix.toLowerCase(Locale.US); + String prefix = languagePropertyPrefix(model, overrideLanguageName); javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties") .setStringValue("prefix", prefix); @@ -1399,10 +1390,12 @@ private void createComponentAutoConfigurationSource(String packageName, Componen writeSourceIfChanged(javaClass, fileName, false); } - private void createComponentConverterSource(String packageName, ComponentModel model) throws MojoFailureException { + private void createComponentConverterSource(String packageName, ComponentModel model, String overrideComponentName) + throws MojoFailureException { final String name = model.getJavaType().substring(model.getJavaType().lastIndexOf(".") + 1).replace("Component", "ComponentConverter"); + final String prefix = componentPropertyPrefix(model, overrideComponentName); // create converter class and write source JavaClass javaClass = new JavaClass(getProjectClassLoader()); @@ -1414,6 +1407,7 @@ private void createComponentConverterSource(String packageName, ComponentModel m javaClass.addAnnotation("org.springframework.stereotype.Component"); javaClass.addImport("java.util.LinkedHashSet"); javaClass.addImport("java.util.Set"); + javaClass.addImport("org.apache.camel.spring.boot.util.BeanReferenceHelper"); javaClass.addImport("org.springframework.core.convert.TypeDescriptor"); javaClass.addImport("org.springframework.core.convert.converter.GenericConverter"); @@ -1424,7 +1418,7 @@ private void createComponentConverterSource(String packageName, ComponentModel m String body = createConverterPairBody(model); javaClass.addMethod().setName("getConvertibleTypes").setPublic().setReturnType("Set") .setBody(body); - body = createConvertBody(model); + body = createConvertBody(prefix); javaClass.addMethod().setName("convert").setPublic().setReturnType("Object").addParameter("Object", "source") .addParameter("TypeDescriptor", "sourceType").addParameter("TypeDescriptor", "targetType") .setBody(body); @@ -1436,73 +1430,32 @@ private void createComponentConverterSource(String packageName, ComponentModel m writeComponentSpringFactorySource(packageName, name); } - private String createConvertBody(ComponentModel model) { - StringBuilder sb = new StringBuilder(); - sb.append("if (source == null) {\n"); - sb.append(" return null;\n"); - sb.append("}\n"); - sb.append("String ref = source.toString();\n"); - sb.append("if (!ref.startsWith(\"#\")) {\n"); - sb.append(" return null;\n"); - sb.append("}\n"); - sb.append("ref = ref.startsWith(\"#bean:\") ? ref.substring(6) : ref.substring(1);\n"); - sb.append("switch (targetType.getName()) {\n"); - // we need complex types only which unique types only - Stream s = model.getComponentOptions().stream().filter(this::isComplexType) - .map(SpringBootAutoConfigurationMojo::getJavaType).distinct(); - s.forEach(type -> { - sb.append(" case \"").append(type).append("\": return applicationContext.getBean(ref, ").append(type) - .append(".class);\n"); - }); - sb.append("}\n"); - sb.append("return null;\n"); - return sb.toString(); + private static String componentPropertyPrefix(ComponentModel model, String overrideComponentName) { + return ("camel.component." + + camelCaseToDash(overrideComponentName != null ? overrideComponentName : model.getScheme())) + .toLowerCase(Locale.US); } - private String createConvertBody(DataFormatModel model) { - StringBuilder sb = new StringBuilder(); - sb.append("if (source == null) {\n"); - sb.append(" return null;\n"); - sb.append("}\n"); - sb.append("String ref = source.toString();\n"); - sb.append("if (!ref.startsWith(\"#\")) {\n"); - sb.append(" return null;\n"); - sb.append("}\n"); - sb.append("ref = ref.startsWith(\"#bean:\") ? ref.substring(6) : ref.substring(1);\n"); - sb.append("switch (targetType.getName()) {\n"); - // we need complex types only which unique types only - Stream s = model.getOptions().stream().filter(this::isComplexType) - .map(SpringBootAutoConfigurationMojo::getJavaType).distinct(); - s.forEach(type -> { - sb.append(" case \"").append(type).append("\": return applicationContext.getBean(ref, ").append(type) - .append(".class);\n"); - }); - sb.append("}\n"); - sb.append("return null;\n"); - return sb.toString(); + private static String dataFormatPropertyPrefix(DataFormatModel model, String overrideDataFormatName) { + return ("camel.dataformat." + + camelCaseToDash(overrideDataFormatName != null ? overrideDataFormatName : model.getName())) + .toLowerCase(Locale.US); } - private String createConvertBody(LanguageModel model) { - StringBuilder sb = new StringBuilder(); - sb.append("if (source == null) {\n"); - sb.append(" return null;\n"); - sb.append("}\n"); - sb.append("String ref = source.toString();\n"); - sb.append("if (!ref.startsWith(\"#\")) {\n"); - sb.append(" return null;\n"); - sb.append("}\n"); - sb.append("ref = ref.startsWith(\"#bean:\") ? ref.substring(6) : ref.substring(1);\n"); - sb.append("switch (targetType.getName()) {\n"); - // we need complex types only which unique types only - Stream s = model.getOptions().stream().filter(this::isComplexType) - .map(SpringBootAutoConfigurationMojo::getJavaType).distinct(); - s.forEach(type -> { - sb.append(" case \"").append(type).append("\": return applicationContext.getBean(ref, ").append(type) - .append(".class);\n"); - }); - sb.append("}\n"); - sb.append("return null;\n"); - return sb.toString(); + private static String languagePropertyPrefix(LanguageModel model, String overrideLanguageName) { + return ("camel.language." + + camelCaseToDash(overrideLanguageName != null ? overrideLanguageName : model.getName())) + .toLowerCase(Locale.US); + } + + /** + * The body of the generated converters. The value is resolved by + * {@code org.apache.camel.spring.boot.util.BeanReferenceHelper} which fails with a meaningful error when a + * configured value cannot be resolved, instead of silently converting it to null. + */ + static String createConvertBody(String propertyPrefix) { + return "return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, \"" + + propertyPrefix + "\");\n"; } private String createConverterPairBody(ComponentModel model) { @@ -1612,11 +1565,12 @@ private void createDataFormatAutoConfigurationSource(String packageName, DataFor writeSourceIfChanged(javaClass, fileName, false); } - private void createDataFormatConverterSource(String packageName, DataFormatModel model) - throws MojoFailureException { + private void createDataFormatConverterSource(String packageName, DataFormatModel model, + String overrideDataFormatName) throws MojoFailureException { final String name = model.getJavaType().substring(model.getJavaType().lastIndexOf(".") + 1) .replace("DataFormat", "DataFormatConverter"); + final String prefix = dataFormatPropertyPrefix(model, overrideDataFormatName); // create converter class and write source JavaClass javaClass = new JavaClass(getProjectClassLoader()); @@ -1628,7 +1582,7 @@ private void createDataFormatConverterSource(String packageName, DataFormatModel javaClass.addAnnotation("org.springframework.stereotype.Component"); javaClass.addImport("java.util.LinkedHashSet"); javaClass.addImport("java.util.Set"); - javaClass.addImport("org.apache.camel.CamelContext"); + javaClass.addImport("org.apache.camel.spring.boot.util.BeanReferenceHelper"); javaClass.addImport("org.springframework.core.convert.TypeDescriptor"); javaClass.addImport("org.springframework.core.convert.converter.GenericConverter"); @@ -1639,7 +1593,7 @@ private void createDataFormatConverterSource(String packageName, DataFormatModel String body = createConverterPairBody(model); javaClass.addMethod().setName("getConvertibleTypes").setPublic().setReturnType("Set") .setBody(body); - body = createConvertBody(model); + body = createConvertBody(prefix); javaClass.addMethod().setName("convert").setPublic().setReturnType("Object").addParameter("Object", "source") .addParameter("TypeDescriptor", "sourceType").addParameter("TypeDescriptor", "targetType") .setBody(body); @@ -1717,33 +1671,35 @@ private void createComponentSpringFactorySource(String packageName, ComponentMod writeComponentSpringFactorySource(packageName, name); } - private void createLanguageConverterSource(String packageName, LanguageModel model) throws MojoFailureException { + private void createLanguageConverterSource(String packageName, LanguageModel model, String overrideLanguageName) + throws MojoFailureException { final String name = model.getJavaType().substring(model.getJavaType().lastIndexOf(".") + 1).replace("Language", "LanguageConverter"); + final String prefix = languagePropertyPrefix(model, overrideLanguageName); // create converter class and write source JavaClass javaClass = new JavaClass(getProjectClassLoader()); javaClass.setPackage(packageName); javaClass.setName(name); javaClass.getJavaDoc().setFullText("Generated by camel-package-maven-plugin - do not edit this file!"); + javaClass.addAnnotation(Configuration.class).setLiteralValue("proxyBeanMethods", "false"); + javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationPropertiesBinding"); + javaClass.addAnnotation("org.springframework.stereotype.Component"); javaClass.addImport("java.util.LinkedHashSet"); javaClass.addImport("java.util.Set"); - javaClass.addImport("org.apache.camel.CamelContext"); + javaClass.addImport("org.apache.camel.spring.boot.util.BeanReferenceHelper"); javaClass.addImport("org.springframework.core.convert.TypeDescriptor"); javaClass.addImport("org.springframework.core.convert.converter.GenericConverter"); - javaClass.implementInterface("org.springframework.core.convert.converter.GenericConverter"); - javaClass.addField().setPrivate().setFinal(true).setName("camelContext") - .setType(loadClass("org.apache.camel.CamelContext")); - javaClass.addMethod().setConstructor(true).setPublic().setName(name) - .addParameter("org.apache.camel.CamelContext", "camelContext") - .setBody("this.camelContext = camelContext;\n"); + javaClass.implementInterface("GenericConverter"); + javaClass.addField().setPrivate().setName("applicationContext") + .setType(loadClass("org.springframework.context.ApplicationContext")).addAnnotation(Autowired.class); String body = createConverterPairBody(model); javaClass.addMethod().setName("getConvertibleTypes").setPublic().setReturnType("Set") .setBody(body); - body = createConvertBody(model); + body = createConvertBody(prefix); javaClass.addMethod().setName("convert").setPublic().setReturnType("Object").addParameter("Object", "source") .addParameter("TypeDescriptor", "sourceType").addParameter("TypeDescriptor", "targetType") .setBody(body); @@ -1771,10 +1727,11 @@ private void createLanguageSpringFactorySource(String packageName, LanguageModel writeComponentSpringFactorySource(packageName, name); } - private static String createComponentBody(String shortJavaType, String name) { + static String createComponentBody(String shortJavaType, String name) { return new StringBuilder().append("return new ComponentCustomizer() {\n").append(" @Override\n") .append(" public void configure(String name, Component target) {\n") - .append(" CamelPropertiesHelper.copyProperties(camelContext, configuration, target);\n") + .append(" CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext,\n") + .append(" \"camel.component.").append(name).append("\", configuration, target);\n") .append(" }\n").append(" @Override\n") .append(" public boolean isEnabled(String name, Component target) {\n") .append(" return HierarchicalPropertiesEvaluator.evaluate(\n") @@ -1785,10 +1742,11 @@ private static String createComponentBody(String shortJavaType, String name) { .append("};\n").toString(); } - private static String createDataFormatBody(String shortJavaType, String name) { + static String createDataFormatBody(String shortJavaType, String name) { return new StringBuilder().append("return new DataFormatCustomizer() {\n").append(" @Override\n") .append(" public void configure(String name, DataFormat target) {\n") - .append(" CamelPropertiesHelper.copyProperties(camelContext, configuration, target);\n") + .append(" CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext,\n") + .append(" \"camel.dataformat.").append(name).append("\", configuration, target);\n") .append(" }\n").append(" @Override\n") .append(" public boolean isEnabled(String name, DataFormat target) {\n") .append(" return HierarchicalPropertiesEvaluator.evaluate(\n") @@ -1799,10 +1757,11 @@ private static String createDataFormatBody(String shortJavaType, String name) { .append("};\n").toString(); } - private static String createLanguageBody(String shortJavaType, String name) { + static String createLanguageBody(String shortJavaType, String name) { return new StringBuilder().append("return new LanguageCustomizer() {\n").append(" @Override\n") .append(" public void configure(String name, Language target) {\n") - .append(" CamelPropertiesHelper.copyProperties(camelContext, configuration, target);\n") + .append(" CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext,\n") + .append(" \"camel.language.").append(name).append("\", configuration, target);\n") .append(" }\n").append(" @Override\n") .append(" public boolean isEnabled(String name, Language target) {\n") .append(" return HierarchicalPropertiesEvaluator.evaluate(\n") diff --git a/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java b/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java new file mode 100644 index 000000000000..bfa5ed05506a --- /dev/null +++ b/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java @@ -0,0 +1,81 @@ +/* + * 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.springboot.maven; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for the code that {@link SpringBootAutoConfigurationMojo} generates into the starters. + */ +class SpringBootAutoConfigurationMojoTest { + + @Test + @DisplayName("Generated converters report unresolvable values instead of converting them to null") + void testConvertBodyFailsClosed() { + String body = SpringBootAutoConfigurationMojo.createConvertBody("camel.component.netty-http"); + + assertThat(body).isEqualTo( + "return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType," + + " \"camel.component.netty-http\");\n"); + // the old generated body silently returned null for anything that did not start with # + assertThat(body).doesNotContain("return null"); + assertThat(body).doesNotContain("startsWith(\"#\")"); + } + + @Test + @DisplayName("Generated component customizer does not silently drop options") + void testComponentBodyBindsStrictly() { + String body = SpringBootAutoConfigurationMojo.createComponentBody("NettyHttpComponent", "netty-http"); + + assertThat(body).contains("CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext()," + + " applicationContext,\n \"camel.component.netty-http\"," + + " configuration, target);"); + assertThat(body).doesNotContain("CamelPropertiesHelper.copyProperties("); + assertThat(body).contains("\"camel.component.netty-http.customizer\""); + } + + @Test + @DisplayName("Generated data format customizer does not silently drop options") + void testDataFormatBodyBindsStrictly() { + String body = SpringBootAutoConfigurationMojo.createDataFormatBody("JacksonDataFormat", "jackson"); + + // on this branch DataFormatAutoConfiguration still injects a plain CamelContext field rather than an + // ObjectProvider, so the generated customizer binds through that field directly + assertThat(body).contains("CamelPropertiesHelper.copyConfigurationProperties(camelContext," + + " applicationContext,\n \"camel.dataformat.jackson\"," + + " configuration, target);"); + assertThat(body).doesNotContain("CamelPropertiesHelper.copyProperties("); + } + + @Test + @DisplayName("Generated language customizer does not silently drop options") + void testLanguageBodyBindsStrictly() { + String body = SpringBootAutoConfigurationMojo.createLanguageBody("XPathLanguage", "xpath"); + + // on this branch LanguageAutoConfiguration still injects a plain CamelContext field, and the generated + // customizer never grew the CamelContextAware guard that main's template has, so it binds through that + // field directly + assertThat(body).contains("CamelPropertiesHelper.copyConfigurationProperties(camelContext," + + " applicationContext,\n \"camel.language.xpath\"," + + " configuration, target);"); + assertThat(body).doesNotContain("CamelPropertiesHelper.copyProperties("); + } + +} From 87d940e72aeb7bc48f7aa180bde28d2707f5c200 Mon Sep 17 00:00:00 2001 From: croway Date: Wed, 2 Sep 2026 15:10:58 +0200 Subject: [PATCH 2/3] CAMEL-24501: Regen Regenerated the starters with the updated generator plugin. Co-Authored-By: Claude Opus 5 (cherry picked from commit 2e48974f6bf74789397e0ed82768ed4cb13dd392) --- .../ActiveMQComponentAutoConfiguration.java | 14 ++-------- .../ActiveMQComponentConverter.java | 26 ++----------------- .../ActiveMQComponentAutoConfiguration.java | 14 ++-------- .../ActiveMQComponentConverter.java | 26 ++----------------- .../AMQPComponentAutoConfiguration.java | 14 ++-------- .../springboot/AMQPComponentConverter.java | 26 ++----------------- .../ArangoDbComponentAutoConfiguration.java | 14 ++-------- .../ArangoDbComponentConverter.java | 16 ++---------- .../AS2ComponentAutoConfiguration.java | 14 ++-------- .../as2/springboot/AS2ComponentConverter.java | 15 ++--------- .../ASN1DataFormatAutoConfiguration.java | 14 ++-------- .../AsteriskComponentAutoConfiguration.java | 14 ++-------- .../WebsocketComponentAutoConfiguration.java | 14 ++-------- .../WebsocketComponentConverter.java | 17 ++---------- .../AtomComponentAutoConfiguration.java | 14 ++-------- .../AvroComponentAutoConfiguration.java | 14 ++-------- .../springboot/AvroComponentConverter.java | 15 ++--------- .../AvroDataFormatAutoConfiguration.java | 14 ++-------- ...edrockAgentComponentAutoConfiguration.java | 14 ++-------- .../BedrockAgentComponentConverter.java | 15 ++--------- ...gentRuntimeComponentAutoConfiguration.java | 14 ++-------- ...BedrockAgentRuntimeComponentConverter.java | 16 ++---------- .../BedrockComponentAutoConfiguration.java | 14 ++-------- .../springboot/BedrockComponentConverter.java | 16 ++---------- .../CloudtrailComponentAutoConfiguration.java | 14 ++-------- .../CloudtrailComponentConverter.java | 15 ++--------- .../AWSConfigComponentAutoConfiguration.java | 14 ++-------- .../AWSConfigComponentConverter.java | 15 ++--------- ...ameterStoreComponentAutoConfiguration.java | 14 ++-------- .../ParameterStoreComponentConverter.java | 15 ++--------- ...retsManagerComponentAutoConfiguration.java | 14 ++-------- .../SecretsManagerComponentConverter.java | 15 ++--------- ...SecurityHubComponentAutoConfiguration.java | 14 ++-------- .../SecurityHubComponentConverter.java | 15 ++--------- .../Athena2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Athena2ComponentConverter.java | 15 ++--------- ...Comprehend2ComponentAutoConfiguration.java | 14 ++-------- .../Comprehend2ComponentConverter.java | 15 ++--------- .../Cw2ComponentAutoConfiguration.java | 14 ++-------- .../cw/springboot/Cw2ComponentConverter.java | 15 ++--------- .../Ddb2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Ddb2ComponentConverter.java | 15 ++--------- .../Ddb2StreamComponentAutoConfiguration.java | 14 ++-------- .../Ddb2StreamComponentConverter.java | 15 ++--------- .../AWS2EC2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/AWS2EC2ComponentConverter.java | 15 ++--------- .../ECS2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/ECS2ComponentConverter.java | 15 ++--------- .../EKS2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/EKS2ComponentConverter.java | 15 ++--------- ...EventbridgeComponentAutoConfiguration.java | 14 ++-------- .../EventbridgeComponentConverter.java | 15 ++--------- .../IAM2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/IAM2ComponentConverter.java | 15 ++--------- ...isFirehose2ComponentAutoConfiguration.java | 14 ++-------- .../KinesisFirehose2ComponentConverter.java | 15 ++--------- .../Kinesis2ComponentAutoConfiguration.java | 14 ++-------- .../Kinesis2ComponentConverter.java | 18 ++----------- .../KMS2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/KMS2ComponentConverter.java | 15 ++--------- .../Lambda2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Lambda2ComponentConverter.java | 15 ++--------- .../MQ2ComponentAutoConfiguration.java | 14 ++-------- .../mq/springboot/MQ2ComponentConverter.java | 15 ++--------- .../MSK2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/MSK2ComponentConverter.java | 15 ++--------- .../Polly2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Polly2ComponentConverter.java | 15 ++--------- ...dshiftData2ComponentAutoConfiguration.java | 14 ++-------- .../RedshiftData2ComponentConverter.java | 15 ++--------- ...ekognition2ComponentAutoConfiguration.java | 14 ++-------- .../Rekognition2ComponentConverter.java | 15 ++--------- .../AWS2S3ComponentAutoConfiguration.java | 14 ++-------- .../springboot/AWS2S3ComponentConverter.java | 16 ++---------- ...S2S3VectorsComponentAutoConfiguration.java | 14 ++-------- .../AWS2S3VectorsComponentConverter.java | 15 ++--------- .../Ses2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Ses2ComponentConverter.java | 15 ++--------- .../Sns2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Sns2ComponentConverter.java | 15 ++--------- .../Sqs2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Sqs2ComponentConverter.java | 15 ++--------- ...pFunctions2ComponentAutoConfiguration.java | 14 ++-------- .../StepFunctions2ComponentConverter.java | 15 ++--------- .../STS2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/STS2ComponentConverter.java | 15 ++--------- .../Textract2ComponentAutoConfiguration.java | 14 ++-------- .../Textract2ComponentConverter.java | 15 ++--------- ...Timestream2ComponentAutoConfiguration.java | 14 ++-------- .../Timestream2ComponentConverter.java | 16 ++---------- ...Transcribe2ComponentAutoConfiguration.java | 14 ++-------- .../Transcribe2ComponentConverter.java | 15 ++--------- .../Translate2ComponentAutoConfiguration.java | 14 ++-------- .../Translate2ComponentConverter.java | 15 ++--------- .../CosmosDbComponentAutoConfiguration.java | 14 ++-------- .../CosmosDbComponentConverter.java | 19 ++------------ .../EventGridComponentAutoConfiguration.java | 14 ++-------- .../EventGridComponentConverter.java | 17 ++---------- .../EventHubsComponentAutoConfiguration.java | 14 ++-------- .../EventHubsComponentConverter.java | 20 ++------------ .../FilesComponentAutoConfiguration.java | 14 ++-------- .../KeyVaultComponentAutoConfiguration.java | 14 ++-------- .../ServiceBusComponentAutoConfiguration.java | 14 ++-------- .../ServiceBusComponentConverter.java | 22 ++-------------- .../BlobComponentAutoConfiguration.java | 14 ++-------- .../springboot/BlobComponentConverter.java | 17 ++---------- .../DataLakeComponentAutoConfiguration.java | 14 ++-------- .../DataLakeComponentConverter.java | 18 ++----------- .../QueueComponentAutoConfiguration.java | 14 ++-------- .../springboot/QueueComponentConverter.java | 16 ++---------- .../BarcodeDataFormatAutoConfiguration.java | 14 ++-------- .../Base64DataFormatAutoConfiguration.java | 14 ++-------- .../BeanComponentAutoConfiguration.java | 14 ++-------- .../ClassComponentAutoConfiguration.java | 14 ++-------- .../BeanLanguageAutoConfiguration.java | 14 ++-------- ...anValidatorComponentAutoConfiguration.java | 14 ++-------- .../BeanValidatorComponentConverter.java | 18 ++----------- .../BeanIODataFormatAutoConfiguration.java | 14 ++-------- .../BindyCsvDataFormatAutoConfiguration.java | 14 ++-------- ...ixedLengthDataFormatAutoConfiguration.java | 14 ++-------- ...yValuePairDataFormatAutoConfiguration.java | 14 ++-------- .../BonitaComponentAutoConfiguration.java | 14 ++-------- .../BoxComponentAutoConfiguration.java | 14 ++-------- .../box/springboot/BoxComponentConverter.java | 16 ++---------- .../BraintreeComponentAutoConfiguration.java | 14 ++-------- .../BraintreeComponentConverter.java | 14 ++-------- .../BrowseComponentAutoConfiguration.java | 14 ++-------- ...ffeineCacheComponentAutoConfiguration.java | 14 ++-------- .../CaffeineCacheComponentConverter.java | 17 ++---------- ...neLoadCacheComponentAutoConfiguration.java | 14 ++-------- .../CaffeineLoadCacheComponentConverter.java | 17 ++---------- .../CassandraComponentAutoConfiguration.java | 14 ++-------- .../CBORDataFormatAutoConfiguration.java | 14 ++-------- .../ChatScriptComponentAutoConfiguration.java | 14 ++-------- .../ChunkComponentAutoConfiguration.java | 14 ++-------- .../ClickUpComponentAutoConfiguration.java | 14 ++-------- .../CMComponentAutoConfiguration.java | 14 ++-------- .../CoAPComponentAutoConfiguration.java | 14 ++-------- .../springboot/CoAPComponentConverter.java | 15 ++--------- .../CometdComponentAutoConfiguration.java | 14 ++-------- .../springboot/CometdComponentConverter.java | 15 ++--------- .../ConsulComponentAutoConfiguration.java | 14 ++-------- .../springboot/ConsulComponentConverter.java | 17 ++---------- .../ControlBusComponentAutoConfiguration.java | 14 ++-------- .../ConstantLanguageAutoConfiguration.java | 14 ++-------- .../HeaderLanguageAutoConfiguration.java | 14 ++-------- ...angePropertyLanguageAutoConfiguration.java | 14 ++-------- .../RefLanguageAutoConfiguration.java | 14 ++-------- .../FileLanguageAutoConfiguration.java | 14 ++-------- .../SimpleLanguageAutoConfiguration.java | 14 ++-------- .../TokenizeLanguageAutoConfiguration.java | 14 ++-------- .../VariableLanguageAutoConfiguration.java | 14 ++-------- .../CouchbaseComponentAutoConfiguration.java | 14 ++-------- .../CouchDbComponentAutoConfiguration.java | 14 ++-------- .../CronComponentAutoConfiguration.java | 14 ++-------- .../PGPDataFormatAutoConfiguration.java | 14 ++-------- ...alSignatureComponentAutoConfiguration.java | 14 ++-------- .../DigitalSignatureComponentConverter.java | 20 ++------------ .../CryptoDataFormatAutoConfiguration.java | 14 ++-------- .../springboot/CryptoDataFormatConverter.java | 16 ++---------- .../CsvDataFormatAutoConfiguration.java | 14 ++-------- .../CxfRsComponentAutoConfiguration.java | 14 ++-------- .../springboot/CxfRsComponentConverter.java | 14 ++-------- .../CxfComponentAutoConfiguration.java | 14 ++-------- .../springboot/CxfComponentConverter.java | 14 ++-------- ...berArkVaultComponentAutoConfiguration.java | 14 ++-------- .../CyberArkVaultComponentConverter.java | 15 ++--------- .../DaprComponentAutoConfiguration.java | 14 ++-------- .../springboot/DaprComponentConverter.java | 19 ++------------ .../DataFormatComponentAutoConfiguration.java | 14 ++-------- .../DataSetComponentAutoConfiguration.java | 14 ++-------- .../springboot/DataSetComponentConverter.java | 14 ++-------- ...DataSetTestComponentAutoConfiguration.java | 14 ++-------- .../DataSetTestComponentConverter.java | 14 ++-------- .../DatasonnetLanguageAutoConfiguration.java | 14 ++-------- ...DebeziumDb2ComponentAutoConfiguration.java | 14 ++-------- .../DebeziumDb2ComponentConverter.java | 14 ++-------- ...ziumMongodbComponentAutoConfiguration.java | 14 ++-------- .../DebeziumMongodbComponentConverter.java | 14 ++-------- ...beziumMySqlComponentAutoConfiguration.java | 14 ++-------- .../DebeziumMySqlComponentConverter.java | 14 ++-------- ...eziumOracleComponentAutoConfiguration.java | 14 ++-------- .../DebeziumOracleComponentConverter.java | 14 ++-------- ...iumPostgresComponentAutoConfiguration.java | 14 ++-------- .../DebeziumPostgresComponentConverter.java | 14 ++-------- ...umSqlserverComponentAutoConfiguration.java | 14 ++-------- .../DebeziumSqlserverComponentConverter.java | 14 ++-------- .../DfdlComponentAutoConfiguration.java | 14 ++-------- .../DfdlDataFormatAutoConfiguration.java | 14 ++-------- .../Dhis2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Dhis2ComponentConverter.java | 15 ++--------- .../DirectComponentAutoConfiguration.java | 14 ++-------- .../DisruptorComponentAutoConfiguration.java | 14 ++-------- ...DisruptorVmComponentAutoConfiguration.java | 14 ++-------- .../DJLComponentAutoConfiguration.java | 14 ++-------- .../DnsComponentAutoConfiguration.java | 14 ++-------- .../DockerComponentAutoConfiguration.java | 14 ++-------- .../springboot/DockerComponentConverter.java | 14 ++-------- .../DoclingComponentAutoConfiguration.java | 14 ++-------- .../springboot/DoclingComponentConverter.java | 14 ++-------- .../DrillComponentAutoConfiguration.java | 14 ++-------- .../DropboxComponentAutoConfiguration.java | 14 ++-------- ...uterControlComponentAutoConfiguration.java | 14 ++-------- ...namicRouterComponentAutoConfiguration.java | 14 ++-------- .../EhcacheComponentAutoConfiguration.java | 14 ++-------- .../springboot/EhcacheComponentConverter.java | 16 ++---------- ...hRestClientComponentAutoConfiguration.java | 14 ++-------- ...ticsearchRestClientComponentConverter.java | 15 ++--------- ...asticsearchComponentAutoConfiguration.java | 14 ++-------- .../ElasticsearchComponentConverter.java | 15 ++--------- .../ExecComponentAutoConfiguration.java | 14 ++-------- .../FastjsonDataFormatAutoConfiguration.java | 14 ++-------- .../FhirComponentAutoConfiguration.java | 14 ++-------- .../springboot/FhirComponentConverter.java | 17 ++---------- .../FhirJsonDataFormatAutoConfiguration.java | 14 ++-------- .../FhirXmlDataFormatAutoConfiguration.java | 14 ++-------- .../FileComponentAutoConfiguration.java | 14 ++-------- .../FileWatchComponentAutoConfiguration.java | 14 ++-------- .../FileWatchComponentConverter.java | 14 ++-------- .../FlatpackComponentAutoConfiguration.java | 14 ++-------- .../FlatpackDataFormatAutoConfiguration.java | 14 ++-------- .../FlatpackDataFormatConverter.java | 15 ++--------- .../FlinkComponentAutoConfiguration.java | 14 ++-------- .../springboot/FlinkComponentConverter.java | 16 ++---------- .../FlowableComponentAutoConfiguration.java | 14 ++-------- .../FopComponentAutoConfiguration.java | 14 ++-------- .../ForyDataFormatAutoConfiguration.java | 14 ++-------- .../FreemarkerComponentAutoConfiguration.java | 14 ++-------- .../FreemarkerComponentConverter.java | 14 ++-------- .../FtpComponentAutoConfiguration.java | 14 ++-------- .../FtpsComponentAutoConfiguration.java | 14 ++-------- .../SftpComponentAutoConfiguration.java | 14 ++-------- .../GeoCoderComponentAutoConfiguration.java | 14 ++-------- .../GeoCoderComponentConverter.java | 14 ++-------- .../GitComponentAutoConfiguration.java | 14 ++-------- .../GitHub2ComponentAutoConfiguration.java | 14 ++-------- ...gleBigQueryComponentAutoConfiguration.java | 14 ++-------- .../GoogleBigQueryComponentConverter.java | 14 ++-------- ...BigQuerySQLComponentAutoConfiguration.java | 14 ++-------- .../GoogleBigQuerySQLComponentConverter.java | 14 ++-------- ...gleCalendarComponentAutoConfiguration.java | 14 ++-------- .../GoogleCalendarComponentConverter.java | 15 ++--------- ...endarStreamComponentAutoConfiguration.java | 14 ++-------- ...oogleCalendarStreamComponentConverter.java | 15 ++--------- ...GoogleDriveComponentAutoConfiguration.java | 14 ++-------- .../GoogleDriveComponentConverter.java | 15 ++--------- ...udFunctionsComponentAutoConfiguration.java | 14 ++-------- .../GoogleMailComponentAutoConfiguration.java | 14 ++-------- .../GoogleMailComponentConverter.java | 15 ++--------- ...eMailStreamComponentAutoConfiguration.java | 14 ++-------- .../GoogleMailStreamComponentConverter.java | 15 ++--------- ...ooglePubsubComponentAutoConfiguration.java | 14 ++-------- .../GooglePubsubComponentConverter.java | 14 ++-------- ...cretManagerComponentAutoConfiguration.java | 14 ++-------- ...oogleSheetsComponentAutoConfiguration.java | 14 ++-------- .../GoogleSheetsComponentConverter.java | 15 ++--------- ...heetsStreamComponentAutoConfiguration.java | 14 ++-------- .../GoogleSheetsStreamComponentConverter.java | 15 ++--------- ...loudStorageComponentAutoConfiguration.java | 14 ++-------- .../GoogleCloudStorageComponentConverter.java | 16 ++---------- ...gleVertexAIComponentAutoConfiguration.java | 14 ++-------- .../GoogleVertexAIComponentConverter.java | 16 ++---------- .../GraphqlComponentAutoConfiguration.java | 14 ++-------- .../springboot/GraphqlComponentConverter.java | 15 ++--------- .../GrokDataFormatAutoConfiguration.java | 14 ++-------- .../GroovyLanguageAutoConfiguration.java | 14 ++-------- .../GrpcComponentAutoConfiguration.java | 14 ++-------- .../GsonDataFormatAutoConfiguration.java | 14 ++-------- ...hicorpVaultComponentAutoConfiguration.java | 14 ++-------- ...tomicnumberComponentAutoConfiguration.java | 14 ++-------- ...zelcastAtomicnumberComponentConverter.java | 14 ++-------- ...astInstanceComponentAutoConfiguration.java | 14 ++-------- .../HazelcastInstanceComponentConverter.java | 14 ++-------- ...zelcastListComponentAutoConfiguration.java | 14 ++-------- .../HazelcastListComponentConverter.java | 14 ++-------- ...azelcastMapComponentAutoConfiguration.java | 14 ++-------- .../HazelcastMapComponentConverter.java | 14 ++-------- ...astMultimapComponentAutoConfiguration.java | 14 ++-------- .../HazelcastMultimapComponentConverter.java | 14 ++-------- ...elcastQueueComponentAutoConfiguration.java | 14 ++-------- .../HazelcastQueueComponentConverter.java | 14 ++-------- ...plicatedmapComponentAutoConfiguration.java | 14 ++-------- ...elcastReplicatedmapComponentConverter.java | 14 ++-------- ...tRingbufferComponentAutoConfiguration.java | 14 ++-------- ...HazelcastRingbufferComponentConverter.java | 14 ++-------- ...zelcastSedaComponentAutoConfiguration.java | 14 ++-------- .../HazelcastSedaComponentConverter.java | 14 ++-------- ...azelcastSetComponentAutoConfiguration.java | 14 ++-------- .../HazelcastSetComponentConverter.java | 14 ++-------- ...elcastTopicComponentAutoConfiguration.java | 14 ++-------- .../HazelcastTopicComponentConverter.java | 14 ++-------- .../HL7DataFormatAutoConfiguration.java | 14 ++-------- .../springboot/HL7DataFormatConverter.java | 15 ++--------- .../Hl7TerserLanguageAutoConfiguration.java | 14 ++-------- .../HttpComponentAutoConfiguration.java | 14 ++-------- .../springboot/HttpComponentConverter.java | 23 ++-------------- .../DMSComponentAutoConfiguration.java | 14 ++-------- ...RecognitionComponentAutoConfiguration.java | 14 ++-------- ...nctionGraphComponentAutoConfiguration.java | 14 ++-------- .../IAMComponentAutoConfiguration.java | 14 ++-------- ...RecognitionComponentAutoConfiguration.java | 14 ++-------- .../OBSComponentAutoConfiguration.java | 14 ++-------- ...otificationComponentAutoConfiguration.java | 14 ++-------- .../IBMCOSComponentAutoConfiguration.java | 14 ++-------- .../springboot/IBMCOSComponentConverter.java | 15 ++--------- ...retsManagerComponentAutoConfiguration.java | 14 ++-------- ...onDiscoveryComponentAutoConfiguration.java | 14 ++-------- .../WatsonDiscoveryComponentConverter.java | 14 ++-------- ...sonLanguageComponentAutoConfiguration.java | 14 ++-------- .../WatsonLanguageComponentConverter.java | 14 ++-------- ...peechToTextComponentAutoConfiguration.java | 14 ++-------- .../WatsonSpeechToTextComponentConverter.java | 14 ++-------- ...extToSpeechComponentAutoConfiguration.java | 14 ++-------- .../WatsonTextToSpeechComponentConverter.java | 14 ++-------- .../WatsonxAiComponentAutoConfiguration.java | 14 ++-------- .../WatsonxAiComponentConverter.java | 14 ++-------- .../ICalDataFormatAutoConfiguration.java | 14 ++-------- .../IggyComponentAutoConfiguration.java | 14 ++-------- .../springboot/IggyComponentConverter.java | 16 ++---------- ...IgniteCacheComponentAutoConfiguration.java | 14 ++-------- .../IgniteCacheComponentConverter.java | 15 ++--------- ...niteComputeComponentAutoConfiguration.java | 14 ++-------- .../IgniteComputeComponentConverter.java | 15 ++--------- ...gniteEventsComponentAutoConfiguration.java | 14 ++-------- .../IgniteEventsComponentConverter.java | 15 ++--------- ...IgniteIdGenComponentAutoConfiguration.java | 14 ++-------- .../IgniteIdGenComponentConverter.java | 15 ++--------- ...teMessagingComponentAutoConfiguration.java | 14 ++-------- .../IgniteMessagingComponentConverter.java | 15 ++--------- ...IgniteQueueComponentAutoConfiguration.java | 14 ++-------- .../IgniteQueueComponentConverter.java | 15 ++--------- .../IgniteSetComponentAutoConfiguration.java | 14 ++-------- .../IgniteSetComponentConverter.java | 15 ++--------- ...panEmbeddedComponentAutoConfiguration.java | 14 ++-------- .../InfinispanEmbeddedComponentConverter.java | 19 ++------------ ...ispanRemoteComponentAutoConfiguration.java | 14 ++-------- .../InfinispanRemoteComponentConverter.java | 19 ++------------ .../InfluxDbComponentAutoConfiguration.java | 14 ++-------- .../InfluxDbComponentConverter.java | 14 ++-------- .../InfluxDb2ComponentAutoConfiguration.java | 14 ++-------- .../InfluxDb2ComponentConverter.java | 14 ++-------- .../Iso8583DataFormatAutoConfiguration.java | 14 ++-------- ...acksonAvroDataFormatAutoConfiguration.java | 14 ++-------- ...onProtobufDataFormatAutoConfiguration.java | 14 ++-------- .../JacksonDataFormatAutoConfiguration.java | 14 ++-------- .../JacksonDataFormatConverter.java | 15 ++--------- ...JacksonXMLDataFormatAutoConfiguration.java | 14 ++-------- .../JavaScriptLanguageAutoConfiguration.java | 14 ++-------- .../JaxbDataFormatAutoConfiguration.java | 14 ++-------- .../JCacheComponentAutoConfiguration.java | 14 ++-------- .../springboot/JCacheComponentConverter.java | 14 ++-------- .../JcrComponentAutoConfiguration.java | 14 ++-------- .../JdbcComponentAutoConfiguration.java | 14 ++-------- .../springboot/JdbcComponentConverter.java | 15 ++--------- ...JettyHttpComponentAutoConfiguration12.java | 14 ++-------- .../JettyHttpComponentConverter12.java | 22 ++-------------- ...JGroupsRaftComponentAutoConfiguration.java | 14 ++-------- .../JGroupsRaftComponentConverter.java | 15 ++--------- .../JGroupsComponentAutoConfiguration.java | 14 ++-------- .../springboot/JGroupsComponentConverter.java | 14 ++-------- .../JiraComponentAutoConfiguration.java | 14 ++-------- .../springboot/JiraComponentConverter.java | 14 ++-------- .../JmsComponentAutoConfiguration.java | 14 ++-------- .../jms/springboot/JmsComponentConverter.java | 26 ++----------------- .../JMXComponentAutoConfiguration.java | 14 ++-------- .../JoltComponentAutoConfiguration.java | 14 ++-------- .../springboot/JoltComponentConverter.java | 14 ++-------- .../JooqComponentAutoConfiguration.java | 14 ++-------- .../springboot/JooqComponentConverter.java | 15 ++--------- .../JavaLanguageAutoConfiguration.java | 14 ++-------- .../JoorLanguageAutoConfiguration.java | 14 ++-------- .../JpaComponentAutoConfiguration.java | 14 ++-------- .../jpa/springboot/JpaComponentConverter.java | 15 ++--------- .../JqLanguageAutoConfiguration.java | 14 ++-------- .../ScpComponentAutoConfiguration.java | 14 ++-------- .../JsltComponentAutoConfiguration.java | 14 ++-------- .../springboot/JsltComponentConverter.java | 14 ++-------- ...onValidatorComponentAutoConfiguration.java | 14 ++-------- .../JsonApiDataFormatAutoConfiguration.java | 14 ++-------- .../JsonataComponentAutoConfiguration.java | 14 ++-------- .../springboot/JsonataComponentConverter.java | 14 ++-------- .../JsonbDataFormatAutoConfiguration.java | 14 ++-------- .../JsonPathLanguageAutoConfiguration.java | 14 ++-------- .../Jt400ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Jt400ComponentConverter.java | 14 ++-------- .../JteComponentAutoConfiguration.java | 14 ++-------- .../KafkaComponentAutoConfiguration.java | 14 ++-------- .../springboot/KafkaComponentConverter.java | 23 ++-------------- .../KameletComponentAutoConfiguration.java | 14 ++-------- .../springboot/KameletComponentConverter.java | 14 ++-------- .../KeycloakComponentAutoConfiguration.java | 14 ++-------- .../KeycloakComponentConverter.java | 15 ++--------- .../KnativeComponentAutoConfiguration.java | 14 ++-------- .../springboot/KnativeComponentConverter.java | 18 ++----------- .../KServeComponentAutoConfiguration.java | 14 ++-------- .../springboot/KServeComponentConverter.java | 15 ++--------- ...sConfigMapsComponentAutoConfiguration.java | 14 ++-------- ...ubernetesConfigMapsComponentConverter.java | 14 ++-------- ...etesCronJobComponentAutoConfiguration.java | 14 ++-------- .../KubernetesCronJobComponentConverter.java | 14 ++-------- ...omResourcesComponentAutoConfiguration.java | 14 ++-------- ...etesCustomResourcesComponentConverter.java | 14 ++-------- ...DeploymentsComponentAutoConfiguration.java | 14 ++-------- ...bernetesDeploymentsComponentConverter.java | 14 ++-------- ...netesEventsComponentAutoConfiguration.java | 14 ++-------- .../KubernetesEventsComponentConverter.java | 14 ++-------- ...bernetesHPAComponentAutoConfiguration.java | 14 ++-------- .../KubernetesHPAComponentConverter.java | 14 ++-------- ...bernetesJobComponentAutoConfiguration.java | 14 ++-------- .../KubernetesJobComponentConverter.java | 14 ++-------- ...sNamespacesComponentAutoConfiguration.java | 14 ++-------- ...ubernetesNamespacesComponentConverter.java | 14 ++-------- ...rnetesNodesComponentAutoConfiguration.java | 14 ++-------- .../KubernetesNodesComponentConverter.java | 14 ++-------- ...tentVolumesComponentAutoConfiguration.java | 14 ++-------- ...esPersistentVolumesComponentConverter.java | 14 ++-------- ...lumesClaimsComponentAutoConfiguration.java | 14 ++-------- ...istentVolumesClaimsComponentConverter.java | 14 ++-------- ...ernetesPodsComponentAutoConfiguration.java | 14 ++-------- .../KubernetesPodsComponentConverter.java | 14 ++-------- ...ControllersComponentAutoConfiguration.java | 14 ++-------- ...licationControllersComponentConverter.java | 14 ++-------- ...ourcesQuotaComponentAutoConfiguration.java | 14 ++-------- ...netesResourcesQuotaComponentConverter.java | 14 ++-------- ...etesSecretsComponentAutoConfiguration.java | 14 ++-------- .../KubernetesSecretsComponentConverter.java | 14 ++-------- ...iceAccountsComponentAutoConfiguration.java | 14 ++-------- ...etesServiceAccountsComponentConverter.java | 14 ++-------- ...tesServicesComponentAutoConfiguration.java | 14 ++-------- .../KubernetesServicesComponentConverter.java | 14 ++-------- ...uildConfigsComponentAutoConfiguration.java | 14 ++-------- ...enshiftBuildConfigsComponentConverter.java | 14 ++-------- ...shiftBuildsComponentAutoConfiguration.java | 14 ++-------- .../OpenshiftBuildsComponentConverter.java | 14 ++-------- ...mentConfigsComponentAutoConfiguration.java | 14 ++-------- ...ftDeploymentConfigsComponentConverter.java | 14 ++-------- .../KuduComponentAutoConfiguration.java | 14 ++-------- .../springboot/KuduComponentConverter.java | 14 ++-------- ...hain4jAgentComponentAutoConfiguration.java | 14 ++-------- .../LangChain4jAgentComponentConverter.java | 17 ++---------- ...Chain4jChatComponentAutoConfiguration.java | 14 ++-------- .../LangChain4jChatComponentConverter.java | 15 ++--------- ...jEmbeddingsComponentAutoConfiguration.java | 14 ++-------- ...ngChain4jEmbeddingsComponentConverter.java | 15 ++--------- ...eddingStoreComponentAutoConfiguration.java | 14 ++-------- ...ain4jEmbeddingStoreComponentConverter.java | 17 ++---------- ...4jWebSearchComponentAutoConfiguration.java | 14 ++-------- .../LanguageComponentAutoConfiguration.java | 14 ++-------- .../LdapComponentAutoConfiguration.java | 14 ++-------- .../LdifComponentAutoConfiguration.java | 14 ++-------- .../LogComponentAutoConfiguration.java | 14 ++-------- .../log/springboot/LogComponentConverter.java | 14 ++-------- .../LuceneComponentAutoConfiguration.java | 14 ++-------- .../springboot/LuceneComponentConverter.java | 15 ++--------- .../LumberjackComponentAutoConfiguration.java | 14 ++-------- .../LumberjackComponentConverter.java | 14 ++-------- .../LZFDataFormatAutoConfiguration.java | 14 ++-------- .../MailComponentAutoConfiguration.java | 14 ++-------- .../springboot/MailComponentConverter.java | 22 ++-------------- ...eMultipartDataFormatAutoConfiguration.java | 14 ++-------- .../MapstructComponentAutoConfiguration.java | 14 ++-------- .../MapstructComponentConverter.java | 14 ++-------- .../MasterComponentAutoConfiguration.java | 14 ++-------- .../springboot/MasterComponentConverter.java | 15 ++--------- .../MetricsComponentAutoConfiguration.java | 14 ++-------- .../springboot/MetricsComponentConverter.java | 14 ++-------- .../MicrometerComponentAutoConfiguration.java | 14 ++-------- .../MicrometerComponentConverter.java | 14 ++-------- .../MiloBrowseComponentAutoConfiguration.java | 14 ++-------- .../MiloBrowseComponentConverter.java | 15 ++--------- .../MiloClientComponentAutoConfiguration.java | 14 ++-------- .../MiloClientComponentConverter.java | 15 ++--------- .../MiloServerComponentAutoConfiguration.java | 14 ++-------- .../MiloServerComponentConverter.java | 17 ++---------- .../MilvusComponentAutoConfiguration.java | 14 ++-------- .../springboot/MilvusComponentConverter.java | 14 ++-------- .../MinaSftpComponentAutoConfiguration.java | 14 ++-------- .../MinaComponentAutoConfiguration.java | 14 ++-------- .../springboot/MinaComponentConverter.java | 16 ++---------- .../MinioComponentAutoConfiguration.java | 14 ++-------- .../springboot/MinioComponentConverter.java | 19 ++------------ .../MllpComponentAutoConfiguration.java | 14 ++-------- .../springboot/MllpComponentConverter.java | 15 ++--------- .../MockComponentAutoConfiguration.java | 14 ++-------- .../springboot/MockComponentConverter.java | 14 ++-------- .../GridFsComponentAutoConfiguration.java | 14 ++-------- .../MongoDbComponentAutoConfiguration.java | 14 ++-------- .../springboot/MongoDbComponentConverter.java | 14 ++-------- .../MustacheComponentAutoConfiguration.java | 14 ++-------- .../MustacheComponentConverter.java | 14 ++-------- .../MvelComponentAutoConfiguration.java | 14 ++-------- .../MvelLanguageAutoConfiguration.java | 14 ++-------- ...MyBatisBeanComponentAutoConfiguration.java | 14 ++-------- .../MyBatisBeanComponentConverter.java | 14 ++-------- .../MyBatisComponentAutoConfiguration.java | 14 ++-------- .../springboot/MyBatisComponentConverter.java | 14 ++-------- .../NatsComponentAutoConfiguration.java | 14 ++-------- .../springboot/NatsComponentConverter.java | 18 ++----------- .../Neo4jComponentAutoConfiguration.java | 14 ++-------- .../springboot/Neo4jComponentConverter.java | 15 ++--------- .../NettyHttpComponentAutoConfiguration.java | 14 ++-------- .../NettyHttpComponentConverter.java | 26 ++----------------- .../NettyComponentAutoConfiguration.java | 14 ++-------- .../springboot/NettyComponentConverter.java | 23 ++-------------- .../OAIPMHComponentAutoConfiguration.java | 14 ++-------- .../OcsfDataFormatAutoConfiguration.java | 14 ++-------- .../OgnlLanguageAutoConfiguration.java | 14 ++-------- .../Olingo2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Olingo2ComponentConverter.java | 20 ++------------ .../Olingo4ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Olingo4ComponentConverter.java | 18 ++----------- .../OnceComponentAutoConfiguration.java | 14 ++-------- .../OpenAIComponentAutoConfiguration.java | 14 ++-------- .../OpensearchComponentAutoConfiguration.java | 14 ++-------- .../OpensearchComponentConverter.java | 15 ++--------- .../CinderComponentAutoConfiguration.java | 14 ++-------- .../GlanceComponentAutoConfiguration.java | 14 ++-------- .../KeystoneComponentAutoConfiguration.java | 14 ++-------- .../NeutronComponentAutoConfiguration.java | 14 ++-------- .../NovaComponentAutoConfiguration.java | 14 ++-------- .../SwiftComponentAutoConfiguration.java | 14 ++-------- ...enTelemetryComponentAutoConfiguration.java | 14 ++-------- .../OpenTelemetryComponentConverter.java | 14 ++-------- ...OptaPlannerComponentAutoConfiguration.java | 14 ++-------- .../PahoMqtt5ComponentAutoConfiguration.java | 14 ++-------- .../PahoMqtt5ComponentConverter.java | 19 ++------------ .../PahoComponentAutoConfiguration.java | 14 ++-------- .../springboot/PahoComponentConverter.java | 18 ++----------- ...arquetAvroDataFormatAutoConfiguration.java | 14 ++-------- .../PdfComponentAutoConfiguration.java | 14 ++-------- ...icationSlotComponentAutoConfiguration.java | 14 ++-------- .../PgEventComponentAutoConfiguration.java | 14 ++-------- ...oneVectorDbComponentAutoConfiguration.java | 14 ++-------- .../PineconeVectorDbComponentConverter.java | 14 ++-------- ...latformHttpComponentAutoConfiguration.java | 14 ++-------- .../PlatformHttpComponentConverter.java | 15 ++--------- .../Plc4XComponentAutoConfiguration.java | 14 ++-------- .../PQCDataFormatAutoConfiguration.java | 14 ++-------- .../springboot/PQCDataFormatConverter.java | 16 ++---------- .../PQCComponentAutoConfiguration.java | 14 ++-------- .../pqc/springboot/PQCComponentConverter.java | 19 ++------------ .../PrinterComponentAutoConfiguration.java | 14 ++-------- .../ProtobufDataFormatAutoConfiguration.java | 14 ++-------- .../PubNubComponentAutoConfiguration.java | 14 ++-------- .../springboot/PubNubComponentConverter.java | 14 ++-------- .../PulsarComponentAutoConfiguration.java | 14 ++-------- .../springboot/PulsarComponentConverter.java | 19 ++------------ .../PythonLanguageAutoConfiguration.java | 14 ++-------- .../QdrantComponentAutoConfiguration.java | 14 ++-------- .../springboot/QdrantComponentConverter.java | 15 ++--------- .../QuartzComponentAutoConfiguration.java | 14 ++-------- .../springboot/QuartzComponentConverter.java | 15 ++--------- .../QuickfixjComponentAutoConfiguration.java | 14 ++-------- .../QuickfixjComponentConverter.java | 16 ++---------- ...tiveStreamsComponentAutoConfiguration.java | 14 ++-------- .../ReactiveStreamsComponentConverter.java | 14 ++-------- .../RefComponentAutoConfiguration.java | 14 ++-------- ...RestOpenApiComponentAutoConfiguration.java | 14 ++-------- .../RestOpenApiComponentConverter.java | 15 ++--------- .../RestApiComponentAutoConfiguration.java | 14 ++-------- .../RestComponentAutoConfiguration.java | 14 ++-------- .../springboot/RestComponentConverter.java | 14 ++-------- ...otFrameworkComponentAutoConfiguration.java | 14 ++-------- .../RobotFrameworkComponentConverter.java | 14 ++-------- .../RocketMQComponentAutoConfiguration.java | 14 ++-------- .../RssComponentAutoConfiguration.java | 14 ++-------- .../RssDataFormatAutoConfiguration.java | 14 ++-------- .../SagaComponentAutoConfiguration.java | 14 ++-------- .../SalesforceComponentAutoConfiguration.java | 14 ++-------- .../SalesforceComponentConverter.java | 21 ++------------- .../NetWeaverComponentAutoConfiguration.java | 14 ++-------- .../XQueryComponentAutoConfiguration.java | 14 ++-------- .../springboot/XQueryComponentConverter.java | 15 ++--------- .../XQueryLanguageAutoConfiguration.java | 14 ++-------- .../SchedulerComponentAutoConfiguration.java | 14 ++-------- .../SchematronComponentAutoConfiguration.java | 14 ++-------- .../SedaComponentAutoConfiguration.java | 14 ++-------- .../springboot/SedaComponentConverter.java | 14 ++-------- .../ServiceNowComponentAutoConfiguration.java | 14 ++-------- .../ServiceNowComponentConverter.java | 18 ++----------- .../ServletComponentAutoConfiguration.java | 14 ++-------- .../springboot/ServletComponentConverter.java | 17 ++---------- .../SjmsComponentAutoConfiguration.java | 14 ++-------- .../springboot/SjmsComponentConverter.java | 19 ++------------ .../Sjms2ComponentAutoConfiguration.java | 14 ++-------- .../springboot/Sjms2ComponentConverter.java | 19 ++------------ .../SlackComponentAutoConfiguration.java | 14 ++-------- .../SmbComponentAutoConfiguration.java | 14 ++-------- .../SmooksComponentAutoConfiguration.java | 14 ++-------- .../springboot/SmooksComponentConverter.java | 14 ++-------- .../SmooksDataFormatAutoConfiguration.java | 14 ++-------- .../SmppComponentAutoConfiguration.java | 14 ++-------- .../springboot/SmppComponentConverter.java | 15 ++--------- .../SnakeYAMLDataFormatAutoConfiguration.java | 14 ++-------- .../SnmpComponentAutoConfiguration.java | 14 ++-------- .../SoapDataFormatAutoConfiguration.java | 14 ++-------- .../springboot/SoapDataFormatConverter.java | 15 ++--------- .../SolrComponentAutoConfiguration.java | 14 ++-------- .../springboot/SolrComponentConverter.java | 15 ++--------- .../SplunkHECComponentAutoConfiguration.java | 14 ++-------- .../SplunkHECComponentConverter.java | 14 ++-------- ...pringAiChatComponentAutoConfiguration.java | 14 ++-------- .../SpringAiChatComponentConverter.java | 14 ++-------- ...iEmbeddingsComponentAutoConfiguration.java | 14 ++-------- .../SpringAiEmbeddingsComponentConverter.java | 15 ++--------- ...VectorStoreComponentAutoConfiguration.java | 14 ++-------- ...SpringAiVectorStoreComponentConverter.java | 15 ++--------- ...SpringBatchComponentAutoConfiguration.java | 14 ++-------- .../SpringBatchComponentConverter.java | 15 ++--------- .../SpringJdbcComponentAutoConfiguration.java | 14 ++-------- .../SpringJdbcComponentConverter.java | 15 ++--------- .../SpringLdapComponentAutoConfiguration.java | 14 ++-------- ...ingRabbitMQComponentAutoConfiguration.java | 14 ++-------- .../SpringRabbitMQComponentConverter.java | 22 ++-------------- .../RedisComponentAutoConfiguration.java | 14 ++-------- .../springboot/RedisComponentConverter.java | 14 ++-------- .../EventComponentAutoConfiguration.java | 14 ++-------- .../SpelLanguageAutoConfiguration.java | 14 ++-------- ...gWebserviceComponentAutoConfiguration.java | 14 ++-------- .../SqlComponentAutoConfiguration.java | 14 ++-------- .../sql/springboot/SqlComponentConverter.java | 15 ++--------- .../SqlStoredComponentAutoConfiguration.java | 14 ++-------- .../SqlStoredComponentConverter.java | 14 ++-------- .../SshComponentAutoConfiguration.java | 14 ++-------- .../ssh/springboot/SshComponentConverter.java | 16 ++---------- .../StAXComponentAutoConfiguration.java | 14 ++-------- .../XMLTokenizeLanguageAutoConfiguration.java | 14 ++-------- .../StitchComponentAutoConfiguration.java | 14 ++-------- .../springboot/StitchComponentConverter.java | 18 ++----------- .../StreamComponentAutoConfiguration.java | 14 ++-------- ...ingTemplateComponentAutoConfiguration.java | 14 ++-------- .../StripeComponentAutoConfiguration.java | 14 ++-------- .../StubComponentAutoConfiguration.java | 14 ++-------- .../springboot/StubComponentConverter.java | 14 ++-------- .../SwiftMtDataFormatAutoConfiguration.java | 14 ++-------- .../SwiftMxDataFormatAutoConfiguration.java | 14 ++-------- .../SwiftMxDataFormatConverter.java | 17 ++---------- .../SyslogDataFormatAutoConfiguration.java | 14 ++-------- .../TahuEdgeComponentAutoConfiguration.java | 14 ++-------- .../TahuEdgeComponentConverter.java | 15 ++--------- .../TahuHostComponentAutoConfiguration.java | 14 ++-------- .../TahuHostComponentConverter.java | 15 ++--------- .../TarFileDataFormatAutoConfiguration.java | 14 ++-------- .../TelegramComponentAutoConfiguration.java | 14 ++-------- .../TelegramComponentConverter.java | 14 ++-------- ...FlowServingComponentAutoConfiguration.java | 14 ++-------- .../TensorFlowServingComponentConverter.java | 15 ++--------- .../ThriftComponentAutoConfiguration.java | 14 ++-------- .../ThriftDataFormatAutoConfiguration.java | 14 ++-------- .../ThymeleafComponentAutoConfiguration.java | 14 ++-------- .../TikaComponentAutoConfiguration.java | 14 ++-------- .../TimerComponentAutoConfiguration.java | 14 ++-------- .../TwilioComponentAutoConfiguration.java | 14 ++-------- .../springboot/TwilioComponentConverter.java | 15 ++--------- ...rectMessageComponentAutoConfiguration.java | 14 ++-------- ...itterSearchComponentAutoConfiguration.java | 14 ++-------- ...terTimelineComponentAutoConfiguration.java | 14 ++-------- .../UndertowComponentAutoConfiguration.java | 14 ++-------- .../UndertowComponentConverter.java | 17 ++---------- ...iVocityCsvDataFormatAutoConfiguration.java | 14 ++-------- ...ocityFixedDataFormatAutoConfiguration.java | 14 ++-------- ...iVocityTsvDataFormatAutoConfiguration.java | 14 ++-------- .../ValidatorComponentAutoConfiguration.java | 14 ++-------- .../ValidatorComponentConverter.java | 14 ++-------- .../VelocityComponentAutoConfiguration.java | 14 ++-------- .../VelocityComponentConverter.java | 14 ++-------- .../VertxHttpComponentAutoConfiguration.java | 14 ++-------- .../VertxHttpComponentConverter.java | 19 ++------------ .../VertxComponentAutoConfiguration.java | 14 ++-------- .../springboot/VertxComponentConverter.java | 16 ++---------- ...txWebsocketComponentAutoConfiguration.java | 14 ++-------- .../VertxWebsocketComponentConverter.java | 16 ++---------- .../WasmComponentAutoConfiguration.java | 14 ++-------- .../WasmLanguageAutoConfiguration.java | 14 ++-------- .../WeatherComponentAutoConfiguration.java | 14 ++-------- ...ateVectorDbComponentAutoConfiguration.java | 14 ++-------- .../WeaviateVectorDbComponentConverter.java | 14 ++-------- .../Web3jComponentAutoConfiguration.java | 14 ++-------- .../springboot/Web3jComponentConverter.java | 16 ++---------- .../WebhookComponentAutoConfiguration.java | 14 ++-------- .../springboot/WebhookComponentConverter.java | 14 ++-------- .../WhatsAppComponentAutoConfiguration.java | 14 ++-------- .../WhatsAppComponentConverter.java | 14 ++-------- .../WordpressComponentAutoConfiguration.java | 14 ++-------- .../WordpressComponentConverter.java | 15 ++--------- .../WorkdayComponentAutoConfiguration.java | 14 ++-------- .../XChangeComponentAutoConfiguration.java | 14 ++-------- .../XJComponentAutoConfiguration.java | 14 ++-------- .../xj/springboot/XJComponentConverter.java | 17 ++---------- .../XmlSignerComponentAutoConfiguration.java | 14 ++-------- .../XmlSignerComponentConverter.java | 19 ++------------ ...XmlVerifierComponentAutoConfiguration.java | 14 ++-------- .../XmlVerifierComponentConverter.java | 19 ++------------ ...MLSecurityDataFormatAutoConfiguration.java | 14 ++-------- .../XMLSecurityDataFormatConverter.java | 15 ++--------- .../XmppComponentAutoConfiguration.java | 14 ++-------- .../XPathLanguageAutoConfiguration.java | 14 ++-------- .../XsltSaxonComponentAutoConfiguration.java | 14 ++-------- .../XsltSaxonComponentConverter.java | 17 ++---------- .../XsltComponentAutoConfiguration.java | 14 ++-------- .../springboot/XsltComponentConverter.java | 16 ++---------- .../ZendeskComponentAutoConfiguration.java | 14 ++-------- .../springboot/ZendeskComponentConverter.java | 15 ++--------- ...ipDeflaterDataFormatAutoConfiguration.java | 14 ++-------- ...ipDeflaterDataFormatAutoConfiguration.java | 14 ++-------- .../ZipFileDataFormatAutoConfiguration.java | 14 ++-------- .../MasterComponentAutoConfiguration.java | 14 ++-------- .../springboot/MasterComponentConverter.java | 15 ++--------- .../ZooKeeperComponentAutoConfiguration.java | 14 ++-------- .../ZooKeeperComponentConverter.java | 14 ++-------- 710 files changed, 1420 insertions(+), 8948 deletions(-) diff --git a/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentAutoConfiguration.java b/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentAutoConfiguration.java index b03b46d7dc44..37f140f1bef9 100644 --- a/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentAutoConfiguration.java +++ b/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureActiveMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.activemq.customizer") - && target instanceof ActiveMQComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.activemq", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentConverter.java b/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentConverter.java index a57c7f2e12b7..3ea7d6d875ef 100644 --- a/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentConverter.java +++ b/components-starter/camel-activemq-starter/src/main/java/org/apache/camel/component/activemq/springboot/ActiveMQComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -59,29 +60,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.jms.ConnectionFactory": return applicationContext.getBean(ref, jakarta.jms.ConnectionFactory.class); - case "org.springframework.core.task.TaskExecutor": return applicationContext.getBean(ref, org.springframework.core.task.TaskExecutor.class); - case "org.apache.camel.component.jms.JmsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.jms.JmsConfiguration.class); - case "org.springframework.jms.support.destination.DestinationResolver": return applicationContext.getBean(ref, org.springframework.jms.support.destination.DestinationResolver.class); - case "org.springframework.util.ErrorHandler": return applicationContext.getBean(ref, org.springframework.util.ErrorHandler.class); - case "jakarta.jms.ExceptionListener": return applicationContext.getBean(ref, jakarta.jms.ExceptionListener.class); - case "org.springframework.jms.support.converter.MessageConverter": return applicationContext.getBean(ref, org.springframework.jms.support.converter.MessageConverter.class); - case "org.apache.camel.component.jms.MessageCreatedStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageCreatedStrategy.class); - case "org.apache.camel.component.jms.MessageListenerContainerFactory": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageListenerContainerFactory.class); - case "org.apache.camel.component.jms.QueueBrowseStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.QueueBrowseStrategy.class); - case "org.apache.camel.component.jms.TemporaryQueueResolver": return applicationContext.getBean(ref, org.apache.camel.component.jms.TemporaryQueueResolver.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.springframework.transaction.PlatformTransactionManager": return applicationContext.getBean(ref, org.springframework.transaction.PlatformTransactionManager.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.activemq"); } } \ No newline at end of file diff --git a/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentAutoConfiguration.java b/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentAutoConfiguration.java index 531bd6890566..c60f82c5f8da 100644 --- a/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentAutoConfiguration.java +++ b/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureActiveMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.activemq6.customizer") - && target instanceof ActiveMQComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.activemq6", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentConverter.java b/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentConverter.java index e3ded26f77d3..e616c3f0960d 100644 --- a/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentConverter.java +++ b/components-starter/camel-activemq6-starter/src/main/java/org/apache/camel/component/activemq6/springboot/ActiveMQComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -59,29 +60,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.jms.ConnectionFactory": return applicationContext.getBean(ref, jakarta.jms.ConnectionFactory.class); - case "org.springframework.core.task.TaskExecutor": return applicationContext.getBean(ref, org.springframework.core.task.TaskExecutor.class); - case "org.apache.camel.component.jms.JmsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.jms.JmsConfiguration.class); - case "org.springframework.jms.support.destination.DestinationResolver": return applicationContext.getBean(ref, org.springframework.jms.support.destination.DestinationResolver.class); - case "org.springframework.util.ErrorHandler": return applicationContext.getBean(ref, org.springframework.util.ErrorHandler.class); - case "jakarta.jms.ExceptionListener": return applicationContext.getBean(ref, jakarta.jms.ExceptionListener.class); - case "org.springframework.jms.support.converter.MessageConverter": return applicationContext.getBean(ref, org.springframework.jms.support.converter.MessageConverter.class); - case "org.apache.camel.component.jms.MessageCreatedStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageCreatedStrategy.class); - case "org.apache.camel.component.jms.MessageListenerContainerFactory": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageListenerContainerFactory.class); - case "org.apache.camel.component.jms.QueueBrowseStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.QueueBrowseStrategy.class); - case "org.apache.camel.component.jms.TemporaryQueueResolver": return applicationContext.getBean(ref, org.apache.camel.component.jms.TemporaryQueueResolver.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.springframework.transaction.PlatformTransactionManager": return applicationContext.getBean(ref, org.springframework.transaction.PlatformTransactionManager.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.activemq6"); } } \ No newline at end of file diff --git a/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentAutoConfiguration.java b/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentAutoConfiguration.java index 477da82fecab..b0b14853780d 100644 --- a/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentAutoConfiguration.java +++ b/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAMQPComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.amqp.customizer") - && target instanceof AMQPComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.amqp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConverter.java b/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConverter.java index 3da2d100a376..fcc6f312bee3 100644 --- a/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConverter.java +++ b/components-starter/camel-amqp-starter/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -59,29 +60,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.jms.ConnectionFactory": return applicationContext.getBean(ref, jakarta.jms.ConnectionFactory.class); - case "org.springframework.core.task.TaskExecutor": return applicationContext.getBean(ref, org.springframework.core.task.TaskExecutor.class); - case "org.apache.camel.component.jms.JmsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.jms.JmsConfiguration.class); - case "org.springframework.jms.support.destination.DestinationResolver": return applicationContext.getBean(ref, org.springframework.jms.support.destination.DestinationResolver.class); - case "org.springframework.util.ErrorHandler": return applicationContext.getBean(ref, org.springframework.util.ErrorHandler.class); - case "jakarta.jms.ExceptionListener": return applicationContext.getBean(ref, jakarta.jms.ExceptionListener.class); - case "org.springframework.jms.support.converter.MessageConverter": return applicationContext.getBean(ref, org.springframework.jms.support.converter.MessageConverter.class); - case "org.apache.camel.component.jms.MessageCreatedStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageCreatedStrategy.class); - case "org.apache.camel.component.jms.MessageListenerContainerFactory": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageListenerContainerFactory.class); - case "org.apache.camel.component.jms.QueueBrowseStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.QueueBrowseStrategy.class); - case "org.apache.camel.component.jms.TemporaryQueueResolver": return applicationContext.getBean(ref, org.apache.camel.component.jms.TemporaryQueueResolver.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.springframework.transaction.PlatformTransactionManager": return applicationContext.getBean(ref, org.springframework.transaction.PlatformTransactionManager.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.amqp"); } } \ No newline at end of file diff --git a/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentAutoConfiguration.java b/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentAutoConfiguration.java index 7a63eb1f2b95..64e3b48550e4 100644 --- a/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentAutoConfiguration.java +++ b/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureArangoDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.arangodb.customizer") - && target instanceof ArangoDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.arangodb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentConverter.java b/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentConverter.java index c46860d43802..24055aa31abd 100644 --- a/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentConverter.java +++ b/components-starter/camel-arangodb-starter/src/main/java/org/apache/camel/component/arangodb/springboot/ArangoDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.arangodb.ArangoDbConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.arangodb.ArangoDbConfiguration.class); - case "com.arangodb.ArangoDB": return applicationContext.getBean(ref, com.arangodb.ArangoDB.class); - case "io.vertx.core.Vertx": return applicationContext.getBean(ref, io.vertx.core.Vertx.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.arangodb"); } } \ No newline at end of file diff --git a/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentAutoConfiguration.java b/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentAutoConfiguration.java index 32087dc9573c..f316031d4b32 100644 --- a/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentAutoConfiguration.java +++ b/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.as2.customizer") - && target instanceof AS2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.as2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConverter.java b/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConverter.java index d41a19f828ea..019e41f12ab1 100644 --- a/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConverter.java +++ b/components-starter/camel-as2-starter/src/main/java/org/apache/camel/component/as2/springboot/AS2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.as2.AS2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.as2.AS2Configuration.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.as2"); } } \ No newline at end of file diff --git a/components-starter/camel-asn1-starter/src/main/java/org/apache/camel/dataformat/asn1/springboot/ASN1DataFormatAutoConfiguration.java b/components-starter/camel-asn1-starter/src/main/java/org/apache/camel/dataformat/asn1/springboot/ASN1DataFormatAutoConfiguration.java index 29058ac490ff..ce1a4bc6e2b2 100644 --- a/components-starter/camel-asn1-starter/src/main/java/org/apache/camel/dataformat/asn1/springboot/ASN1DataFormatAutoConfiguration.java +++ b/components-starter/camel-asn1-starter/src/main/java/org/apache/camel/dataformat/asn1/springboot/ASN1DataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureASN1DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.asn1.customizer") - && target instanceof ASN1DataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.asn1", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-asterisk-starter/src/main/java/org/apache/camel/component/asterisk/springboot/AsteriskComponentAutoConfiguration.java b/components-starter/camel-asterisk-starter/src/main/java/org/apache/camel/component/asterisk/springboot/AsteriskComponentAutoConfiguration.java index 1d624c13e9d2..b00e1cd59149 100644 --- a/components-starter/camel-asterisk-starter/src/main/java/org/apache/camel/component/asterisk/springboot/AsteriskComponentAutoConfiguration.java +++ b/components-starter/camel-asterisk-starter/src/main/java/org/apache/camel/component/asterisk/springboot/AsteriskComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAsteriskComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.asterisk.customizer") - && target instanceof AsteriskComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.asterisk", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentAutoConfiguration.java b/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentAutoConfiguration.java index e2528df7bed9..dd67e99c5fd4 100644 --- a/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentAutoConfiguration.java +++ b/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWebsocketComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.atmosphere-websocket.customizer") - && target instanceof WebsocketComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.atmosphere-websocket", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentConverter.java b/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentConverter.java index fe48f10477b9..48b3f7d6be07 100644 --- a/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentConverter.java +++ b/components-starter/camel-atmosphere-websocket-starter/src/main/java/org/apache/camel/component/atmosphere/websocket/springboot/WebsocketComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.http.common.HttpRegistry": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpRegistry.class); - case "org.apache.camel.http.common.HttpBinding": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpBinding.class); - case "org.apache.camel.http.common.HttpConfiguration": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpConfiguration.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.atmosphere-websocket"); } } \ No newline at end of file diff --git a/components-starter/camel-atom-starter/src/main/java/org/apache/camel/component/atom/springboot/AtomComponentAutoConfiguration.java b/components-starter/camel-atom-starter/src/main/java/org/apache/camel/component/atom/springboot/AtomComponentAutoConfiguration.java index 1562f5262cef..882810c91ca0 100644 --- a/components-starter/camel-atom-starter/src/main/java/org/apache/camel/component/atom/springboot/AtomComponentAutoConfiguration.java +++ b/components-starter/camel-atom-starter/src/main/java/org/apache/camel/component/atom/springboot/AtomComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAtomComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.atom.customizer") - && target instanceof AtomComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.atom", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentAutoConfiguration.java b/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentAutoConfiguration.java index cc5a29fa8b94..7ae76cbc9102 100644 --- a/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentAutoConfiguration.java +++ b/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAvroComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.avro.customizer") - && target instanceof AvroComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.avro", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentConverter.java b/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentConverter.java index 24dd33ff477b..c0b346f306f5 100644 --- a/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentConverter.java +++ b/components-starter/camel-avro-rpc-starter/src/main/java/org/apache/camel/component/avro/springboot/AvroComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.avro.Protocol": return applicationContext.getBean(ref, org.apache.avro.Protocol.class); - case "org.apache.camel.component.avro.AvroConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.avro.AvroConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.avro"); } } \ No newline at end of file diff --git a/components-starter/camel-avro-starter/src/main/java/org/apache/camel/dataformat/avro/springboot/AvroDataFormatAutoConfiguration.java b/components-starter/camel-avro-starter/src/main/java/org/apache/camel/dataformat/avro/springboot/AvroDataFormatAutoConfiguration.java index 100328d17bd1..2e0c33149476 100644 --- a/components-starter/camel-avro-starter/src/main/java/org/apache/camel/dataformat/avro/springboot/AvroDataFormatAutoConfiguration.java +++ b/components-starter/camel-avro-starter/src/main/java/org/apache/camel/dataformat/avro/springboot/AvroDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.avro.customizer") - && target instanceof AvroDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.avro", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentAutoConfiguration.java b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentAutoConfiguration.java index a02ba538c001..a1e9ef77e84b 100644 --- a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentAutoConfiguration.java +++ b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBedrockAgentComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-bedrock-agent.customizer") - && target instanceof BedrockAgentComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-bedrock-agent", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentConverter.java b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentConverter.java index 808488d5dbf2..d31af0bb8e49 100644 --- a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentConverter.java +++ b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agent/springboot/BedrockAgentComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.bedrock.agent.BedrockAgentConfiguration.class); - case "software.amazon.awssdk.services.bedrockagent.BedrockAgentClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.bedrockagent.BedrockAgentClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-bedrock-agent"); } } \ No newline at end of file diff --git a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentAutoConfiguration.java b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentAutoConfiguration.java index c0d227e54b3c..e3ba20580c4b 100644 --- a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentAutoConfiguration.java +++ b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBedrockAgentRuntimeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-bedrock-agent-runtime.customizer") - && target instanceof BedrockAgentRuntimeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-bedrock-agent-runtime", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentConverter.java b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentConverter.java index ef4284712ca3..085715d88ee1 100644 --- a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentConverter.java +++ b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/agentruntime/springboot/BedrockAgentRuntimeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,18 +51,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration.class); - case "software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeClient.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-bedrock-agent-runtime"); } \ No newline at end of file diff --git a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentAutoConfiguration.java b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentAutoConfiguration.java index 88dbce470fd1..75d1543912a0 100644 --- a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentAutoConfiguration.java +++ b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBedrockComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-bedrock.customizer") - && target instanceof BedrockComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-bedrock", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentConverter.java b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentConverter.java index faba33dea30d..b84348a63dc1 100644 --- a/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentConverter.java +++ b/components-starter/camel-aws-bedrock-starter/src/main/java/org/apache/camel/component/aws2/bedrock/runtime/springboot/BedrockComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.bedrock.runtime.BedrockConfiguration.class); - case "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient.class); - case "software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-bedrock"); } } \ No newline at end of file diff --git a/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentAutoConfiguration.java b/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentAutoConfiguration.java index 40cae25bd84a..cac34424a88e 100644 --- a/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentAutoConfiguration.java +++ b/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCloudtrailComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-cloudtrail.customizer") - && target instanceof CloudtrailComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-cloudtrail", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentConverter.java b/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentConverter.java index 086cae77f1cf..ef7bbbf85ebf 100644 --- a/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentConverter.java +++ b/components-starter/camel-aws-cloudtrail-starter/src/main/java/org/apache/camel/component/aws/cloudtrail/springboot/CloudtrailComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration.class); - case "software.amazon.awssdk.services.cloudtrail.CloudTrailClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.cloudtrail.CloudTrailClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-cloudtrail"); } } \ No newline at end of file diff --git a/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentAutoConfiguration.java b/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentAutoConfiguration.java index 0ce314f83b75..a297e029fd0d 100644 --- a/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentAutoConfiguration.java +++ b/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAWSConfigComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-config.customizer") - && target instanceof AWSConfigComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-config", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentConverter.java b/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentConverter.java index 136eb508625a..a125067a15b9 100644 --- a/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentConverter.java +++ b/components-starter/camel-aws-config-starter/src/main/java/org/apache/camel/component/aws/config/springboot/AWSConfigComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws.config.AWSConfigConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws.config.AWSConfigConfiguration.class); - case "software.amazon.awssdk.services.config.ConfigClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.config.ConfigClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-config"); } } \ No newline at end of file diff --git a/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentAutoConfiguration.java b/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentAutoConfiguration.java index 2cc2acea6485..5c2310f1f5ee 100644 --- a/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentAutoConfiguration.java +++ b/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureParameterStoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-parameter-store.customizer") - && target instanceof ParameterStoreComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-parameter-store", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentConverter.java b/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentConverter.java index e02038a45c0a..ea326cce7ee7 100644 --- a/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentConverter.java +++ b/components-starter/camel-aws-parameter-store-starter/src/main/java/org/apache/camel/component/aws/parameterstore/springboot/ParameterStoreComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws.parameterstore.ParameterStoreConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws.parameterstore.ParameterStoreConfiguration.class); - case "software.amazon.awssdk.services.ssm.SsmClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.ssm.SsmClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-parameter-store"); } } \ No newline at end of file diff --git a/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentAutoConfiguration.java b/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentAutoConfiguration.java index fd86829fb52b..0eb060fc236e 100644 --- a/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentAutoConfiguration.java +++ b/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSecretsManagerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-secrets-manager.customizer") - && target instanceof SecretsManagerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-secrets-manager", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentConverter.java b/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentConverter.java index d70d77cd0bda..149f715c83a2 100644 --- a/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentConverter.java +++ b/components-starter/camel-aws-secrets-manager-starter/src/main/java/org/apache/camel/component/aws/secretsmanager/springboot/SecretsManagerComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws.secretsmanager.SecretsManagerConfiguration.class); - case "software.amazon.awssdk.services.secretsmanager.SecretsManagerClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-secrets-manager"); } } \ No newline at end of file diff --git a/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentAutoConfiguration.java b/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentAutoConfiguration.java index 23f8474abe05..fab0c4cbf98a 100644 --- a/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentAutoConfiguration.java +++ b/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSecurityHubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws-security-hub.customizer") - && target instanceof SecurityHubComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-security-hub", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentConverter.java b/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentConverter.java index 81450a4fce98..70a30fe1c58e 100644 --- a/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentConverter.java +++ b/components-starter/camel-aws-security-hub-starter/src/main/java/org/apache/camel/component/aws/securityhub/springboot/SecurityHubComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws.securityhub.SecurityHubConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws.securityhub.SecurityHubConfiguration.class); - case "software.amazon.awssdk.services.securityhub.SecurityHubClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.securityhub.SecurityHubClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws-security-hub"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentAutoConfiguration.java b/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentAutoConfiguration.java index cb399daab789..d0407fdd0e93 100644 --- a/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAthena2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-athena.customizer") - && target instanceof Athena2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-athena", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentConverter.java b/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentConverter.java index 4368a347ee73..ccdfa3c08f25 100644 --- a/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentConverter.java +++ b/components-starter/camel-aws2-athena-starter/src/main/java/org/apache/camel/component/aws2/athena/springboot/Athena2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.athena.Athena2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.athena.Athena2Configuration.class); - case "software.amazon.awssdk.services.athena.AthenaClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.athena.AthenaClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-athena"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentAutoConfiguration.java b/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentAutoConfiguration.java index eeaa69168b27..4c5ad87e1fe4 100644 --- a/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureComprehend2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-comprehend.customizer") - && target instanceof Comprehend2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-comprehend", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentConverter.java b/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentConverter.java index f6c2296a8eb4..a2c0104fefdd 100644 --- a/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentConverter.java +++ b/components-starter/camel-aws2-comprehend-starter/src/main/java/org/apache/camel/component/aws2/comprehend/springboot/Comprehend2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.comprehend.Comprehend2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.comprehend.Comprehend2Configuration.class); - case "software.amazon.awssdk.services.comprehend.ComprehendClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.comprehend.ComprehendClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-comprehend"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentAutoConfiguration.java b/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentAutoConfiguration.java index 5b01968e1ce7..29a813c237f6 100644 --- a/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCw2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-cw.customizer") - && target instanceof Cw2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-cw", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentConverter.java b/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentConverter.java index b0b6bf265553..8d3956416b54 100644 --- a/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentConverter.java +++ b/components-starter/camel-aws2-cw-starter/src/main/java/org/apache/camel/component/aws2/cw/springboot/Cw2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.cw.Cw2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.cw.Cw2Configuration.class); - case "software.amazon.awssdk.services.cloudwatch.CloudWatchClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.cloudwatch.CloudWatchClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-cw"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentAutoConfiguration.java b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentAutoConfiguration.java index 5f93cf9cfe8a..60a913d8dbd2 100644 --- a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDdb2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-ddb.customizer") - && target instanceof Ddb2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ddb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentConverter.java b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentConverter.java index 75ae0b8b59a8..25207ba70ac2 100644 --- a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentConverter.java +++ b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddb/springboot/Ddb2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.ddb.Ddb2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.ddb.Ddb2Configuration.class); - case "software.amazon.awssdk.services.dynamodb.DynamoDbClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.dynamodb.DynamoDbClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-ddb"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentAutoConfiguration.java b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentAutoConfiguration.java index bf0addc658c1..61f2e2123d72 100644 --- a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDdb2StreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-ddbstream.customizer") - && target instanceof Ddb2StreamComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ddbstream", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentConverter.java b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentConverter.java index a4654163e4ad..659d1bfeacf7 100644 --- a/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentConverter.java +++ b/components-starter/camel-aws2-ddb-starter/src/main/java/org/apache/camel/component/aws2/ddbstream/springboot/Ddb2StreamComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.ddbstream.Ddb2StreamConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.ddbstream.Ddb2StreamConfiguration.class); - case "software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.dynamodb.streams.DynamoDbStreamsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-ddbstream"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentAutoConfiguration.java b/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentAutoConfiguration.java index 1099f93112d4..b03124d4c134 100644 --- a/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAWS2EC2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-ec2.customizer") - && target instanceof AWS2EC2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ec2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentConverter.java b/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentConverter.java index 120ee4580d59..8f1dc52ec6f4 100644 --- a/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentConverter.java +++ b/components-starter/camel-aws2-ec2-starter/src/main/java/org/apache/camel/component/aws2/ec2/springboot/AWS2EC2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "software.amazon.awssdk.services.ec2.Ec2Client": return applicationContext.getBean(ref, software.amazon.awssdk.services.ec2.Ec2Client.class); - case "org.apache.camel.component.aws2.ec2.AWS2EC2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.ec2.AWS2EC2Configuration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-ec2"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentAutoConfiguration.java b/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentAutoConfiguration.java index d1a8bf5c00b0..eb6efdfed3f2 100644 --- a/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureECS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-ecs.customizer") - && target instanceof ECS2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ecs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentConverter.java b/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentConverter.java index 16979edbb96c..c3f83bf5bdb0 100644 --- a/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentConverter.java +++ b/components-starter/camel-aws2-ecs-starter/src/main/java/org/apache/camel/component/aws2/ecs/springboot/ECS2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.ecs.ECS2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.ecs.ECS2Configuration.class); - case "software.amazon.awssdk.services.ecs.EcsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.ecs.EcsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-ecs"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentAutoConfiguration.java b/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentAutoConfiguration.java index 651deeb3012f..374ab8b1aa99 100644 --- a/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureEKS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-eks.customizer") - && target instanceof EKS2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-eks", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentConverter.java b/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentConverter.java index 879f932bae88..4558ef4fd314 100644 --- a/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentConverter.java +++ b/components-starter/camel-aws2-eks-starter/src/main/java/org/apache/camel/component/aws2/eks/springboot/EKS2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.eks.EKS2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.eks.EKS2Configuration.class); - case "software.amazon.awssdk.services.eks.EksClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.eks.EksClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-eks"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentAutoConfiguration.java b/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentAutoConfiguration.java index 9680deabb708..1323e8ccfad2 100644 --- a/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureEventbridgeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-eventbridge.customizer") - && target instanceof EventbridgeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-eventbridge", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentConverter.java b/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentConverter.java index 4b3cf6cfc641..71676fe022f9 100644 --- a/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentConverter.java +++ b/components-starter/camel-aws2-eventbridge-starter/src/main/java/org/apache/camel/component/aws2/eventbridge/springboot/EventbridgeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.eventbridge.EventbridgeConfiguration.class); - case "software.amazon.awssdk.services.eventbridge.EventBridgeClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.eventbridge.EventBridgeClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-eventbridge"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentAutoConfiguration.java b/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentAutoConfiguration.java index 4be00028caa8..59f58b4a803d 100644 --- a/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIAM2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-iam.customizer") - && target instanceof IAM2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-iam", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentConverter.java b/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentConverter.java index 8539cf474746..03bc419b8903 100644 --- a/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentConverter.java +++ b/components-starter/camel-aws2-iam-starter/src/main/java/org/apache/camel/component/aws2/iam/springboot/IAM2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.iam.IAM2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.iam.IAM2Configuration.class); - case "software.amazon.awssdk.services.iam.IamClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.iam.IamClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-iam"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentAutoConfiguration.java b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentAutoConfiguration.java index 13cce3dab655..6d740e41feeb 100644 --- a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKinesisFirehose2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-kinesis-firehose.customizer") - && target instanceof KinesisFirehose2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-kinesis-firehose", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentConverter.java b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentConverter.java index 19c79e3ae691..6bed1a9e151a 100644 --- a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentConverter.java +++ b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/firehose/springboot/KinesisFirehose2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.firehose.KinesisFirehose2Configuration.class); - case "software.amazon.awssdk.services.firehose.FirehoseClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.firehose.FirehoseClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-kinesis-firehose"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentAutoConfiguration.java b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentAutoConfiguration.java index 26061366b3c1..4f0290d0e35f 100644 --- a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKinesis2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-kinesis.customizer") - && target instanceof Kinesis2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-kinesis", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentConverter.java b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentConverter.java index 13beb96561e8..9eac1250e801 100644 --- a/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentConverter.java +++ b/components-starter/camel-aws2-kinesis-starter/src/main/java/org/apache/camel/component/aws2/kinesis/springboot/Kinesis2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.kinesis.Kinesis2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.kinesis.Kinesis2Configuration.class); - case "software.amazon.awssdk.services.kinesis.KinesisAsyncClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.kinesis.KinesisAsyncClient.class); - case "software.amazon.awssdk.services.kinesis.KinesisClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.kinesis.KinesisClient.class); - case "software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient.class); - case "software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-kinesis"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentAutoConfiguration.java b/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentAutoConfiguration.java index 095ed45188f3..ded70d198594 100644 --- a/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKMS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-kms.customizer") - && target instanceof KMS2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-kms", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentConverter.java b/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentConverter.java index 9861f0e13ea1..27deb8320868 100644 --- a/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentConverter.java +++ b/components-starter/camel-aws2-kms-starter/src/main/java/org/apache/camel/component/aws2/kms/springboot/KMS2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.kms.KMS2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.kms.KMS2Configuration.class); - case "software.amazon.awssdk.services.kms.KmsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.kms.KmsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-kms"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentAutoConfiguration.java b/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentAutoConfiguration.java index a09b1b973358..1790a0b9c11d 100644 --- a/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLambda2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-lambda.customizer") - && target instanceof Lambda2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-lambda", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentConverter.java b/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentConverter.java index dae797f04d4e..1c7ee6e008f3 100644 --- a/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentConverter.java +++ b/components-starter/camel-aws2-lambda-starter/src/main/java/org/apache/camel/component/aws2/lambda/springboot/Lambda2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.lambda.Lambda2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.lambda.Lambda2Configuration.class); - case "software.amazon.awssdk.services.lambda.LambdaClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.lambda.LambdaClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-lambda"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentAutoConfiguration.java b/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentAutoConfiguration.java index 01b73e0be193..3bab6a49d1cb 100644 --- a/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMQ2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-mq.customizer") - && target instanceof MQ2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-mq", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentConverter.java b/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentConverter.java index 3432605f5d46..4676ffd66478 100644 --- a/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentConverter.java +++ b/components-starter/camel-aws2-mq-starter/src/main/java/org/apache/camel/component/aws2/mq/springboot/MQ2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.mq.MQ2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.mq.MQ2Configuration.class); - case "software.amazon.awssdk.services.mq.MqClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.mq.MqClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-mq"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentAutoConfiguration.java b/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentAutoConfiguration.java index a93bbc7a62f0..cd2bbdbec067 100644 --- a/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMSK2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-msk.customizer") - && target instanceof MSK2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-msk", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentConverter.java b/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentConverter.java index a1424aa55fda..78a31f0a8821 100644 --- a/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentConverter.java +++ b/components-starter/camel-aws2-msk-starter/src/main/java/org/apache/camel/component/aws2/msk/springboot/MSK2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.msk.MSK2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.msk.MSK2Configuration.class); - case "software.amazon.awssdk.services.kafka.KafkaClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.kafka.KafkaClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-msk"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentAutoConfiguration.java b/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentAutoConfiguration.java index 016e7dafa422..38eb4699bcfb 100644 --- a/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePolly2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-polly.customizer") - && target instanceof Polly2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-polly", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentConverter.java b/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentConverter.java index 7f1a1934dd0a..12d4346633ba 100644 --- a/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentConverter.java +++ b/components-starter/camel-aws2-polly-starter/src/main/java/org/apache/camel/component/aws2/polly/springboot/Polly2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.polly.Polly2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.polly.Polly2Configuration.class); - case "software.amazon.awssdk.services.polly.PollyClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.polly.PollyClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-polly"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentAutoConfiguration.java b/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentAutoConfiguration.java index 2be298bd0120..0cde0f7e29ae 100644 --- a/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRedshiftData2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-redshift-data.customizer") - && target instanceof RedshiftData2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-redshift-data", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentConverter.java b/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentConverter.java index 76d6c7f6613d..3ef9c9e9e274 100644 --- a/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentConverter.java +++ b/components-starter/camel-aws2-redshift-starter/src/main/java/org/apache/camel/component/aws2/redshift/data/springboot/RedshiftData2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.redshift.data.RedshiftData2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.redshift.data.RedshiftData2Configuration.class); - case "software.amazon.awssdk.services.redshiftdata.RedshiftDataClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.redshiftdata.RedshiftDataClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-redshift-data"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentAutoConfiguration.java b/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentAutoConfiguration.java index a1bde1cc818d..535b67d0fa82 100644 --- a/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRekognition2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-rekognition.customizer") - && target instanceof Rekognition2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-rekognition", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentConverter.java b/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentConverter.java index a25f116edf74..cf76e83d0fff 100644 --- a/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentConverter.java +++ b/components-starter/camel-aws2-rekognition-starter/src/main/java/org/apache/camel/component/aws2/rekognition/springboot/Rekognition2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.rekognition.Rekognition2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.rekognition.Rekognition2Configuration.class); - case "software.amazon.awssdk.services.rekognition.RekognitionClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.rekognition.RekognitionClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-rekognition"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentAutoConfiguration.java b/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentAutoConfiguration.java index b81b00a616fb..6a6ae87bf1c2 100644 --- a/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAWS2S3Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-s3.customizer") - && target instanceof AWS2S3Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-s3", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentConverter.java b/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentConverter.java index f02a51fc1aaf..5a6b7ef80c0a 100644 --- a/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentConverter.java +++ b/components-starter/camel-aws2-s3-starter/src/main/java/org/apache/camel/component/aws2/s3/springboot/AWS2S3ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.s3.AWS2S3Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.s3.AWS2S3Configuration.class); - case "software.amazon.awssdk.services.s3.S3Client": return applicationContext.getBean(ref, software.amazon.awssdk.services.s3.S3Client.class); - case "software.amazon.awssdk.services.s3.presigner.S3Presigner": return applicationContext.getBean(ref, software.amazon.awssdk.services.s3.presigner.S3Presigner.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-s3"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentAutoConfiguration.java b/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentAutoConfiguration.java index a1524b12ecd2..802875430fa1 100644 --- a/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureAWS2S3VectorsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-s3-vectors.customizer") - && target instanceof AWS2S3VectorsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-s3-vectors", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentConverter.java b/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentConverter.java index 3032fb1004ef..ebbfc9399fc3 100644 --- a/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentConverter.java +++ b/components-starter/camel-aws2-s3-vectors-starter/src/main/java/org/apache/camel/component/aws2/s3vectors/springboot/AWS2S3VectorsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.s3vectors.AWS2S3VectorsConfiguration.class); - case "software.amazon.awssdk.services.s3vectors.S3VectorsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.s3vectors.S3VectorsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-s3-vectors"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentAutoConfiguration.java b/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentAutoConfiguration.java index ba919970b60a..94d9a7788960 100644 --- a/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSes2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-ses.customizer") - && target instanceof Ses2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ses", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConverter.java b/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConverter.java index 61425d363393..e9c4b1365707 100644 --- a/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConverter.java +++ b/components-starter/camel-aws2-ses-starter/src/main/java/org/apache/camel/component/aws2/ses/springboot/Ses2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.ses.Ses2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.ses.Ses2Configuration.class); - case "software.amazon.awssdk.services.ses.SesClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.ses.SesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-ses"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentAutoConfiguration.java b/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentAutoConfiguration.java index 400c5fabc76d..bceb817ccace 100644 --- a/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSns2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-sns.customizer") - && target instanceof Sns2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-sns", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentConverter.java b/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentConverter.java index 524c66872027..eb3588af6bf9 100644 --- a/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentConverter.java +++ b/components-starter/camel-aws2-sns-starter/src/main/java/org/apache/camel/component/aws2/sns/springboot/Sns2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.sns.Sns2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.sns.Sns2Configuration.class); - case "software.amazon.awssdk.services.sns.SnsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.sns.SnsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-sns"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentAutoConfiguration.java b/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentAutoConfiguration.java index 05bdcb500e4e..eb04b7f806a5 100644 --- a/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSqs2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-sqs.customizer") - && target instanceof Sqs2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-sqs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentConverter.java b/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentConverter.java index 7def5603db03..7a6e5f925069 100644 --- a/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentConverter.java +++ b/components-starter/camel-aws2-sqs-starter/src/main/java/org/apache/camel/component/aws2/sqs/springboot/Sqs2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.sqs.Sqs2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.sqs.Sqs2Configuration.class); - case "software.amazon.awssdk.services.sqs.SqsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.sqs.SqsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-sqs"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentAutoConfiguration.java b/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentAutoConfiguration.java index 76927718874b..108854523813 100644 --- a/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStepFunctions2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-step-functions.customizer") - && target instanceof StepFunctions2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-step-functions", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentConverter.java b/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentConverter.java index 6379dab3fb03..079f9bc9d302 100644 --- a/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentConverter.java +++ b/components-starter/camel-aws2-step-functions-starter/src/main/java/org/apache/camel/component/aws2/stepfunctions/springboot/StepFunctions2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.stepfunctions.StepFunctions2Configuration.class); - case "software.amazon.awssdk.services.sfn.SfnClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.sfn.SfnClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-step-functions"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentAutoConfiguration.java b/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentAutoConfiguration.java index 2466b1bac84d..ef82993b2e1e 100644 --- a/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSTS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-sts.customizer") - && target instanceof STS2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-sts", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentConverter.java b/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentConverter.java index 330696d2e0e6..a960382dad3c 100644 --- a/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentConverter.java +++ b/components-starter/camel-aws2-sts-starter/src/main/java/org/apache/camel/component/aws2/sts/springboot/STS2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.sts.STS2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.sts.STS2Configuration.class); - case "software.amazon.awssdk.services.sts.StsClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.sts.StsClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-sts"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentAutoConfiguration.java b/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentAutoConfiguration.java index fc4311363b4b..a40225dd10ee 100644 --- a/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTextract2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-textract.customizer") - && target instanceof Textract2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-textract", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentConverter.java b/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentConverter.java index ff0242a49633..4413a26a6dac 100644 --- a/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentConverter.java +++ b/components-starter/camel-aws2-textract-starter/src/main/java/org/apache/camel/component/aws2/textract/springboot/Textract2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.textract.Textract2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.textract.Textract2Configuration.class); - case "software.amazon.awssdk.services.textract.TextractClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.textract.TextractClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-textract"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentAutoConfiguration.java b/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentAutoConfiguration.java index 101ab2d60702..63b732865bc8 100644 --- a/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTimestream2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-timestream.customizer") - && target instanceof Timestream2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-timestream", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentConverter.java b/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentConverter.java index 31b7998d93c7..87f8847291d7 100644 --- a/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentConverter.java +++ b/components-starter/camel-aws2-timestream-starter/src/main/java/org/apache/camel/component/aws2/timestream/springboot/Timestream2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.timestream.Timestream2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.timestream.Timestream2Configuration.class); - case "software.amazon.awssdk.services.timestreamquery.TimestreamQueryClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.timestreamquery.TimestreamQueryClient.class); - case "software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.timestreamwrite.TimestreamWriteClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-timestream"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentAutoConfiguration.java b/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentAutoConfiguration.java index f254abfd689f..e6516ae8e353 100644 --- a/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTranscribe2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-transcribe.customizer") - && target instanceof Transcribe2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-transcribe", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentConverter.java b/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentConverter.java index 80912c00543a..fc50c0abc75c 100644 --- a/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentConverter.java +++ b/components-starter/camel-aws2-transcribe-starter/src/main/java/org/apache/camel/component/aws2/transcribe/springboot/Transcribe2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.transcribe.Transcribe2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.transcribe.Transcribe2Configuration.class); - case "software.amazon.awssdk.services.transcribe.TranscribeClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.transcribe.TranscribeClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-transcribe"); } } \ No newline at end of file diff --git a/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentAutoConfiguration.java b/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentAutoConfiguration.java index f275731056c6..b0a48c077c84 100644 --- a/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentAutoConfiguration.java +++ b/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTranslate2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.aws2-translate.customizer") - && target instanceof Translate2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-translate", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentConverter.java b/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentConverter.java index 6837094db650..751a125f95eb 100644 --- a/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentConverter.java +++ b/components-starter/camel-aws2-translate-starter/src/main/java/org/apache/camel/component/aws2/translate/springboot/Translate2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.aws2.translate.Translate2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.translate.Translate2Configuration.class); - case "software.amazon.awssdk.services.translate.TranslateClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.translate.TranslateClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.aws2-translate"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentAutoConfiguration.java b/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentAutoConfiguration.java index 12de1db048e8..767dac1d7e35 100644 --- a/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentAutoConfiguration.java +++ b/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCosmosDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-cosmosdb.customizer") - && target instanceof CosmosDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-cosmosdb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentConverter.java b/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentConverter.java index d76a643ef640..1c1e9f996651 100644 --- a/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentConverter.java +++ b/components-starter/camel-azure-cosmosdb-starter/src/main/java/org/apache/camel/component/azure/cosmosdb/springboot/CosmosDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.azure.cosmosdb.CosmosDbConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.cosmosdb.CosmosDbConfiguration.class); - case "com.azure.cosmos.CosmosAsyncClient": return applicationContext.getBean(ref, com.azure.cosmos.CosmosAsyncClient.class); - case "com.azure.cosmos.models.ThroughputProperties": return applicationContext.getBean(ref, com.azure.cosmos.models.ThroughputProperties.class); - case "com.azure.cosmos.models.ChangeFeedProcessorOptions": return applicationContext.getBean(ref, com.azure.cosmos.models.ChangeFeedProcessorOptions.class); - case "com.azure.cosmos.models.CosmosQueryRequestOptions": return applicationContext.getBean(ref, com.azure.cosmos.models.CosmosQueryRequestOptions.class); - case "com.azure.cosmos.models.IndexingPolicy": return applicationContext.getBean(ref, com.azure.cosmos.models.IndexingPolicy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-cosmosdb"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentAutoConfiguration.java b/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentAutoConfiguration.java index e81c0550b199..3ffa4db835ce 100644 --- a/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentAutoConfiguration.java +++ b/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureEventGridComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-eventgrid.customizer") - && target instanceof EventGridComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-eventgrid", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentConverter.java b/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentConverter.java index 62829063465b..9500d1924405 100644 --- a/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentConverter.java +++ b/components-starter/camel-azure-eventgrid-starter/src/main/java/org/apache/camel/component/azure/eventgrid/springboot/EventGridComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.azure.eventgrid.EventGridConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.eventgrid.EventGridConfiguration.class); - case "com.azure.messaging.eventgrid.EventGridPublisherClient": return applicationContext.getBean(ref, com.azure.messaging.eventgrid.EventGridPublisherClient.class); - case "com.azure.core.credential.AzureKeyCredential": return applicationContext.getBean(ref, com.azure.core.credential.AzureKeyCredential.class); - case "com.azure.core.credential.TokenCredential": return applicationContext.getBean(ref, com.azure.core.credential.TokenCredential.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-eventgrid"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentAutoConfiguration.java b/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentAutoConfiguration.java index 0854a31656c8..832ddc2d9646 100644 --- a/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentAutoConfiguration.java +++ b/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureEventHubsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-eventhubs.customizer") - && target instanceof EventHubsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-eventhubs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentConverter.java b/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentConverter.java index 1f2e0921425e..6912c7142a1d 100644 --- a/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentConverter.java +++ b/components-starter/camel-azure-eventhubs-starter/src/main/java/org/apache/camel/component/azure/eventhubs/springboot/EventHubsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -53,23 +54,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.azure.core.amqp.AmqpRetryOptions": return applicationContext.getBean(ref, com.azure.core.amqp.AmqpRetryOptions.class); - case "org.apache.camel.component.azure.eventhubs.EventHubsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.eventhubs.EventHubsConfiguration.class); - case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class); - case "com.azure.messaging.eventhubs.CheckpointStore": return applicationContext.getBean(ref, com.azure.messaging.eventhubs.CheckpointStore.class); - case "com.azure.messaging.eventhubs.EventHubProducerAsyncClient": return applicationContext.getBean(ref, com.azure.messaging.eventhubs.EventHubProducerAsyncClient.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "com.azure.core.credential.TokenCredential": return applicationContext.getBean(ref, com.azure.core.credential.TokenCredential.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-eventhubs"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-files-starter/src/main/java/org/apache/camel/component/file/azure/springboot/FilesComponentAutoConfiguration.java b/components-starter/camel-azure-files-starter/src/main/java/org/apache/camel/component/file/azure/springboot/FilesComponentAutoConfiguration.java index c7bbc44b3dcc..671a658c7f0f 100644 --- a/components-starter/camel-azure-files-starter/src/main/java/org/apache/camel/component/file/azure/springboot/FilesComponentAutoConfiguration.java +++ b/components-starter/camel-azure-files-starter/src/main/java/org/apache/camel/component/file/azure/springboot/FilesComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFilesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-files.customizer") - && target instanceof FilesComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-files", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-key-vault-starter/src/main/java/org/apache/camel/component/azure/key/vault/springboot/KeyVaultComponentAutoConfiguration.java b/components-starter/camel-azure-key-vault-starter/src/main/java/org/apache/camel/component/azure/key/vault/springboot/KeyVaultComponentAutoConfiguration.java index 5f66a8d87aff..f0c1ed6b6c5a 100644 --- a/components-starter/camel-azure-key-vault-starter/src/main/java/org/apache/camel/component/azure/key/vault/springboot/KeyVaultComponentAutoConfiguration.java +++ b/components-starter/camel-azure-key-vault-starter/src/main/java/org/apache/camel/component/azure/key/vault/springboot/KeyVaultComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKeyVaultComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-key-vault.customizer") - && target instanceof KeyVaultComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-key-vault", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentAutoConfiguration.java b/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentAutoConfiguration.java index 3ef4654b3e0b..4fdb9dba5671 100644 --- a/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentAutoConfiguration.java +++ b/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureServiceBusComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-servicebus.customizer") - && target instanceof ServiceBusComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-servicebus", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentConverter.java b/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentConverter.java index 3c62222ded44..5219a0274dce 100644 --- a/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentConverter.java +++ b/components-starter/camel-azure-servicebus-starter/src/main/java/org/apache/camel/component/azure/servicebus/springboot/ServiceBusComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -55,25 +56,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.azure.core.amqp.AmqpRetryOptions": return applicationContext.getBean(ref, com.azure.core.amqp.AmqpRetryOptions.class); - case "com.azure.core.util.ClientOptions": return applicationContext.getBean(ref, com.azure.core.util.ClientOptions.class); - case "org.apache.camel.component.azure.servicebus.ServiceBusConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.servicebus.ServiceBusConfiguration.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "com.azure.core.amqp.ProxyOptions": return applicationContext.getBean(ref, com.azure.core.amqp.ProxyOptions.class); - case "com.azure.messaging.servicebus.ServiceBusProcessorClient": return applicationContext.getBean(ref, com.azure.messaging.servicebus.ServiceBusProcessorClient.class); - case "com.azure.messaging.servicebus.ServiceBusSenderClient": return applicationContext.getBean(ref, com.azure.messaging.servicebus.ServiceBusSenderClient.class); - case "com.azure.messaging.servicebus.ServiceBusTransactionContext": return applicationContext.getBean(ref, com.azure.messaging.servicebus.ServiceBusTransactionContext.class); - case "com.azure.core.credential.TokenCredential": return applicationContext.getBean(ref, com.azure.core.credential.TokenCredential.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-servicebus"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentAutoConfiguration.java b/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentAutoConfiguration.java index 772a3860d301..b77481d0f9c9 100644 --- a/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentAutoConfiguration.java +++ b/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBlobComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-storage-blob.customizer") - && target instanceof BlobComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-storage-blob", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentConverter.java b/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentConverter.java index d6588f26c16f..4229097e252a 100644 --- a/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentConverter.java +++ b/components-starter/camel-azure-storage-blob-starter/src/main/java/org/apache/camel/component/azure/storage/blob/springboot/BlobComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.azure.storage.blob.BlobConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.storage.blob.BlobConfiguration.class); - case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class); - case "com.azure.storage.blob.BlobServiceClient": return applicationContext.getBean(ref, com.azure.storage.blob.BlobServiceClient.class); - case "com.azure.core.util.Context": return applicationContext.getBean(ref, com.azure.core.util.Context.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-storage-blob"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentAutoConfiguration.java b/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentAutoConfiguration.java index b324a45b4089..96451ceb6d57 100644 --- a/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentAutoConfiguration.java +++ b/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDataLakeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-storage-datalake.customizer") - && target instanceof DataLakeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-storage-datalake", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentConverter.java b/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentConverter.java index 97887396ae5c..c5fb15dc8cf8 100644 --- a/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentConverter.java +++ b/components-starter/camel-azure-storage-datalake-starter/src/main/java/org/apache/camel/component/azure/storage/datalake/springboot/DataLakeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.azure.storage.datalake.DataLakeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.storage.datalake.DataLakeConfiguration.class); - case "com.azure.storage.file.datalake.DataLakeServiceClient": return applicationContext.getBean(ref, com.azure.storage.file.datalake.DataLakeServiceClient.class); - case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class); - case "com.azure.identity.ClientSecretCredential": return applicationContext.getBean(ref, com.azure.identity.ClientSecretCredential.class); - case "com.azure.core.credential.AzureSasCredential": return applicationContext.getBean(ref, com.azure.core.credential.AzureSasCredential.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-storage-datalake"); } } \ No newline at end of file diff --git a/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentAutoConfiguration.java b/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentAutoConfiguration.java index 110627c66305..1a6c898c04af 100644 --- a/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentAutoConfiguration.java +++ b/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureQueueComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.azure-storage-queue.customizer") - && target instanceof QueueComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-storage-queue", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentConverter.java b/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentConverter.java index 2c02863babc9..9a3b9a4cdb55 100644 --- a/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentConverter.java +++ b/components-starter/camel-azure-storage-queue-starter/src/main/java/org/apache/camel/component/azure/storage/queue/springboot/QueueComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.azure.storage.queue.QueueConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.storage.queue.QueueConfiguration.class); - case "com.azure.storage.queue.QueueServiceClient": return applicationContext.getBean(ref, com.azure.storage.queue.QueueServiceClient.class); - case "com.azure.storage.common.StorageSharedKeyCredential": return applicationContext.getBean(ref, com.azure.storage.common.StorageSharedKeyCredential.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.azure-storage-queue"); } } \ No newline at end of file diff --git a/components-starter/camel-barcode-starter/src/main/java/org/apache/camel/dataformat/barcode/springboot/BarcodeDataFormatAutoConfiguration.java b/components-starter/camel-barcode-starter/src/main/java/org/apache/camel/dataformat/barcode/springboot/BarcodeDataFormatAutoConfiguration.java index 845f4ad6bd62..41eb37ba4c55 100644 --- a/components-starter/camel-barcode-starter/src/main/java/org/apache/camel/dataformat/barcode/springboot/BarcodeDataFormatAutoConfiguration.java +++ b/components-starter/camel-barcode-starter/src/main/java/org/apache/camel/dataformat/barcode/springboot/BarcodeDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureBarcodeDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.barcode.customizer") - && target instanceof BarcodeDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.barcode", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-base64-starter/src/main/java/org/apache/camel/dataformat/base64/springboot/Base64DataFormatAutoConfiguration.java b/components-starter/camel-base64-starter/src/main/java/org/apache/camel/dataformat/base64/springboot/Base64DataFormatAutoConfiguration.java index ec6963e22673..fdf14ec17f5b 100644 --- a/components-starter/camel-base64-starter/src/main/java/org/apache/camel/dataformat/base64/springboot/Base64DataFormatAutoConfiguration.java +++ b/components-starter/camel-base64-starter/src/main/java/org/apache/camel/dataformat/base64/springboot/Base64DataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureBase64DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.base64.customizer") - && target instanceof Base64DataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.base64", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java b/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java index 5859ee832794..308ccc96e82c 100644 --- a/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java +++ b/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBeanComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.bean.customizer") - && target instanceof BeanComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.bean", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java b/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java index bc4989024ef4..ede6fe905f8d 100644 --- a/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java +++ b/components-starter/camel-bean-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureClassComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.class.customizer") - && target instanceof ClassComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.class", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bean-starter/src/main/java/org/apache/camel/language/bean/springboot/BeanLanguageAutoConfiguration.java b/components-starter/camel-bean-starter/src/main/java/org/apache/camel/language/bean/springboot/BeanLanguageAutoConfiguration.java index 388e24f00b80..1dda8647f255 100644 --- a/components-starter/camel-bean-starter/src/main/java/org/apache/camel/language/bean/springboot/BeanLanguageAutoConfiguration.java +++ b/components-starter/camel-bean-starter/src/main/java/org/apache/camel/language/bean/springboot/BeanLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureBeanLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.bean.customizer") - && target instanceof BeanLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.bean", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentAutoConfiguration.java b/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentAutoConfiguration.java index 5bb9035675e1..44d2184f3ad5 100644 --- a/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentAutoConfiguration.java +++ b/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBeanValidatorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.bean-validator.customizer") - && target instanceof BeanValidatorComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.bean-validator", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentConverter.java b/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentConverter.java index a81414638175..909685551206 100644 --- a/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentConverter.java +++ b/components-starter/camel-bean-validator-starter/src/main/java/org/apache/camel/component/bean/validator/springboot/BeanValidatorComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.validation.ConstraintValidatorFactory": return applicationContext.getBean(ref, jakarta.validation.ConstraintValidatorFactory.class); - case "jakarta.validation.MessageInterpolator": return applicationContext.getBean(ref, jakarta.validation.MessageInterpolator.class); - case "jakarta.validation.TraversableResolver": return applicationContext.getBean(ref, jakarta.validation.TraversableResolver.class); - case "jakarta.validation.ValidationProviderResolver": return applicationContext.getBean(ref, jakarta.validation.ValidationProviderResolver.class); - case "jakarta.validation.ValidatorFactory": return applicationContext.getBean(ref, jakarta.validation.ValidatorFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.bean-validator"); } } \ No newline at end of file diff --git a/components-starter/camel-beanio-starter/src/main/java/org/apache/camel/dataformat/beanio/springboot/BeanIODataFormatAutoConfiguration.java b/components-starter/camel-beanio-starter/src/main/java/org/apache/camel/dataformat/beanio/springboot/BeanIODataFormatAutoConfiguration.java index 0efd7282c4de..a226b5f4b82d 100644 --- a/components-starter/camel-beanio-starter/src/main/java/org/apache/camel/dataformat/beanio/springboot/BeanIODataFormatAutoConfiguration.java +++ b/components-starter/camel-beanio-starter/src/main/java/org/apache/camel/dataformat/beanio/springboot/BeanIODataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureBeanIODataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.beanio.customizer") - && target instanceof BeanIODataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.beanio", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/csv/springboot/BindyCsvDataFormatAutoConfiguration.java b/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/csv/springboot/BindyCsvDataFormatAutoConfiguration.java index ddb04978560a..2f2dd4c4d535 100644 --- a/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/csv/springboot/BindyCsvDataFormatAutoConfiguration.java +++ b/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/csv/springboot/BindyCsvDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureBindyCsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.bindy-csv.customizer") - && target instanceof BindyCsvDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.bindy-csv", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/fixed/springboot/BindyFixedLengthDataFormatAutoConfiguration.java b/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/fixed/springboot/BindyFixedLengthDataFormatAutoConfiguration.java index 5210a5008013..93f0f0d4b476 100644 --- a/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/fixed/springboot/BindyFixedLengthDataFormatAutoConfiguration.java +++ b/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/fixed/springboot/BindyFixedLengthDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureBindyFixedLengthDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.bindy-fixed.customizer") - && target instanceof BindyFixedLengthDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.bindy-fixed", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/kvp/springboot/BindyKeyValuePairDataFormatAutoConfiguration.java b/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/kvp/springboot/BindyKeyValuePairDataFormatAutoConfiguration.java index 9bf1f4e57041..bce6d03980aa 100644 --- a/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/kvp/springboot/BindyKeyValuePairDataFormatAutoConfiguration.java +++ b/components-starter/camel-bindy-starter/src/main/java/org/apache/camel/dataformat/bindy/kvp/springboot/BindyKeyValuePairDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureBindyKeyValuePairDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.bindy-kvp.customizer") - && target instanceof BindyKeyValuePairDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.bindy-kvp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-bonita-starter/src/main/java/org/apache/camel/component/bonita/springboot/BonitaComponentAutoConfiguration.java b/components-starter/camel-bonita-starter/src/main/java/org/apache/camel/component/bonita/springboot/BonitaComponentAutoConfiguration.java index 9751c57c4007..dc340d1fa1a4 100644 --- a/components-starter/camel-bonita-starter/src/main/java/org/apache/camel/component/bonita/springboot/BonitaComponentAutoConfiguration.java +++ b/components-starter/camel-bonita-starter/src/main/java/org/apache/camel/component/bonita/springboot/BonitaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBonitaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.bonita.customizer") - && target instanceof BonitaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.bonita", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentAutoConfiguration.java b/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentAutoConfiguration.java index 22b108685634..46b3d67ec7b0 100644 --- a/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentAutoConfiguration.java +++ b/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBoxComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.box.customizer") - && target instanceof BoxComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.box", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentConverter.java b/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentConverter.java index 48103c4790d9..2868fb4f7f87 100644 --- a/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentConverter.java +++ b/components-starter/camel-box-starter/src/main/java/org/apache/camel/component/box/springboot/BoxComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.box.BoxConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.box.BoxConfiguration.class); - case "com.box.sdk.IAccessTokenCache": return applicationContext.getBean(ref, com.box.sdk.IAccessTokenCache.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.box"); } } \ No newline at end of file diff --git a/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentAutoConfiguration.java b/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentAutoConfiguration.java index 23f994732414..2caeebc6b184 100644 --- a/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentAutoConfiguration.java +++ b/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBraintreeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.braintree.customizer") - && target instanceof BraintreeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.braintree", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentConverter.java b/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentConverter.java index 7a0ede1e5af8..546e95a0bb8a 100644 --- a/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentConverter.java +++ b/components-starter/camel-braintree-starter/src/main/java/org/apache/camel/component/braintree/springboot/BraintreeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.braintree.BraintreeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.braintree.BraintreeConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.braintree"); } } \ No newline at end of file diff --git a/components-starter/camel-browse-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java b/components-starter/camel-browse-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java index 8d7bfd6204ef..23ebbb1a76c0 100644 --- a/components-starter/camel-browse-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java +++ b/components-starter/camel-browse-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureBrowseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.browse.customizer") - && target instanceof BrowseComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.browse", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentAutoConfiguration.java b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentAutoConfiguration.java index d0acaea83927..d38027b8c6db 100644 --- a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentAutoConfiguration.java +++ b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCaffeineCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.caffeine-cache.customizer") - && target instanceof CaffeineCacheComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.caffeine-cache", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentConverter.java b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentConverter.java index c49523615e48..5d844b136d76 100644 --- a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentConverter.java +++ b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/cache/springboot/CaffeineCacheComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.github.benmanes.caffeine.cache.CacheLoader": return applicationContext.getBean(ref, com.github.benmanes.caffeine.cache.CacheLoader.class); - case "org.apache.camel.component.caffeine.CaffeineConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.caffeine.CaffeineConfiguration.class); - case "com.github.benmanes.caffeine.cache.RemovalListener": return applicationContext.getBean(ref, com.github.benmanes.caffeine.cache.RemovalListener.class); - case "com.github.benmanes.caffeine.cache.stats.StatsCounter": return applicationContext.getBean(ref, com.github.benmanes.caffeine.cache.stats.StatsCounter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.caffeine-cache"); } } \ No newline at end of file diff --git a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentAutoConfiguration.java b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentAutoConfiguration.java index 372751644548..24cd0f2583f1 100644 --- a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentAutoConfiguration.java +++ b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCaffeineLoadCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.caffeine-loadcache.customizer") - && target instanceof CaffeineLoadCacheComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.caffeine-loadcache", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentConverter.java b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentConverter.java index 2e60a2fac86f..3df0ccf68bda 100644 --- a/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentConverter.java +++ b/components-starter/camel-caffeine-starter/src/main/java/org/apache/camel/component/caffeine/load/springboot/CaffeineLoadCacheComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.github.benmanes.caffeine.cache.CacheLoader": return applicationContext.getBean(ref, com.github.benmanes.caffeine.cache.CacheLoader.class); - case "org.apache.camel.component.caffeine.CaffeineConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.caffeine.CaffeineConfiguration.class); - case "com.github.benmanes.caffeine.cache.RemovalListener": return applicationContext.getBean(ref, com.github.benmanes.caffeine.cache.RemovalListener.class); - case "com.github.benmanes.caffeine.cache.stats.StatsCounter": return applicationContext.getBean(ref, com.github.benmanes.caffeine.cache.stats.StatsCounter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.caffeine-loadcache"); } } \ No newline at end of file diff --git a/components-starter/camel-cassandraql-starter/src/main/java/org/apache/camel/component/cassandra/springboot/CassandraComponentAutoConfiguration.java b/components-starter/camel-cassandraql-starter/src/main/java/org/apache/camel/component/cassandra/springboot/CassandraComponentAutoConfiguration.java index b00fbabc33b8..2015570ac0cc 100644 --- a/components-starter/camel-cassandraql-starter/src/main/java/org/apache/camel/component/cassandra/springboot/CassandraComponentAutoConfiguration.java +++ b/components-starter/camel-cassandraql-starter/src/main/java/org/apache/camel/component/cassandra/springboot/CassandraComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCassandraComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cql.customizer") - && target instanceof CassandraComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cql", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cbor-starter/src/main/java/org/apache/camel/component/cbor/springboot/CBORDataFormatAutoConfiguration.java b/components-starter/camel-cbor-starter/src/main/java/org/apache/camel/component/cbor/springboot/CBORDataFormatAutoConfiguration.java index 3b92bff0debd..8f702c4ad9e2 100644 --- a/components-starter/camel-cbor-starter/src/main/java/org/apache/camel/component/cbor/springboot/CBORDataFormatAutoConfiguration.java +++ b/components-starter/camel-cbor-starter/src/main/java/org/apache/camel/component/cbor/springboot/CBORDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureCBORDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.cbor.customizer") - && target instanceof CBORDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.cbor", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-chatscript-starter/src/main/java/org/apache/camel/component/chatscript/springboot/ChatScriptComponentAutoConfiguration.java b/components-starter/camel-chatscript-starter/src/main/java/org/apache/camel/component/chatscript/springboot/ChatScriptComponentAutoConfiguration.java index ed533b90fb80..d712ba65d48a 100644 --- a/components-starter/camel-chatscript-starter/src/main/java/org/apache/camel/component/chatscript/springboot/ChatScriptComponentAutoConfiguration.java +++ b/components-starter/camel-chatscript-starter/src/main/java/org/apache/camel/component/chatscript/springboot/ChatScriptComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureChatScriptComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.chatscript.customizer") - && target instanceof ChatScriptComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.chatscript", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java b/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java index 1bc31f702413..53f308efff08 100644 --- a/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java +++ b/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureChunkComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.chunk.customizer") - && target instanceof ChunkComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.chunk", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-clickup-starter/src/main/java/org/apache/camel/component/clickup/springboot/ClickUpComponentAutoConfiguration.java b/components-starter/camel-clickup-starter/src/main/java/org/apache/camel/component/clickup/springboot/ClickUpComponentAutoConfiguration.java index deaae8f9bad4..af4a9ad49315 100644 --- a/components-starter/camel-clickup-starter/src/main/java/org/apache/camel/component/clickup/springboot/ClickUpComponentAutoConfiguration.java +++ b/components-starter/camel-clickup-starter/src/main/java/org/apache/camel/component/clickup/springboot/ClickUpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureClickUpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.clickup.customizer") - && target instanceof ClickUpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.clickup", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java b/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java index c168a20b1bf3..bb6a49d47e30 100644 --- a/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java +++ b/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCMComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cm-sms.customizer") - && target instanceof CMComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cm-sms", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java b/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java index 0c1803a7de75..79857401bb26 100644 --- a/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java +++ b/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCoAPComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.coap.customizer") - && target instanceof CoAPComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.coap", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentConverter.java b/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentConverter.java index 86974bad1cbc..509709b2d2cd 100644 --- a/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentConverter.java +++ b/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.eclipse.californium.core.CoapClient": return applicationContext.getBean(ref, org.eclipse.californium.core.CoapClient.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.coap"); } } \ No newline at end of file diff --git a/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java b/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java index bd1ff83fb085..d48b3b803719 100644 --- a/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java +++ b/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCometdComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cometd.customizer") - && target instanceof CometdComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cometd", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConverter.java b/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConverter.java index 035b41ee51fc..7651544f011f 100644 --- a/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConverter.java +++ b/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.cometd.bayeux.server.SecurityPolicy": return applicationContext.getBean(ref, org.cometd.bayeux.server.SecurityPolicy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.cometd"); } } \ No newline at end of file diff --git a/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java b/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java index 5c205407b073..0df5bd34a9de 100644 --- a/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java +++ b/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureConsulComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.consul.customizer") - && target instanceof ConsulComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.consul", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentConverter.java b/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentConverter.java index 7a8bd6b057cb..b98f94a5d8f2 100644 --- a/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentConverter.java +++ b/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.consul.ConsulConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.consul.ConsulConfiguration.class); - case "org.kiwiproject.consul.Consul": return applicationContext.getBean(ref, org.kiwiproject.consul.Consul.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - case "java.math.BigInteger": return applicationContext.getBean(ref, java.math.BigInteger.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.consul"); } } \ No newline at end of file diff --git a/components-starter/camel-controlbus-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java b/components-starter/camel-controlbus-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java index 0a4776bd05fc..2ca8a6e6bf98 100644 --- a/components-starter/camel-controlbus-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java +++ b/components-starter/camel-controlbus-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureControlBusComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.controlbus.customizer") - && target instanceof ControlBusComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.controlbus", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/constant/springboot/ConstantLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/constant/springboot/ConstantLanguageAutoConfiguration.java index 37dbcfd17ae8..559a49ab027b 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/constant/springboot/ConstantLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/constant/springboot/ConstantLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureConstantLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.constant.customizer") - && target instanceof ConstantLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.constant", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/header/springboot/HeaderLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/header/springboot/HeaderLanguageAutoConfiguration.java index 0c807bd374dd..915b7ac5ee21 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/header/springboot/HeaderLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/header/springboot/HeaderLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureHeaderLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.header.customizer") - && target instanceof HeaderLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.header", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/property/springboot/ExchangePropertyLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/property/springboot/ExchangePropertyLanguageAutoConfiguration.java index 3f43019500d1..44fef8a38258 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/property/springboot/ExchangePropertyLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/property/springboot/ExchangePropertyLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureExchangePropertyLanguage return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.exchange-property.customizer") - && target instanceof ExchangePropertyLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.exchange-property", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/ref/springboot/RefLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/ref/springboot/RefLanguageAutoConfiguration.java index f6e532eeb82a..684c68111f1e 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/ref/springboot/RefLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/ref/springboot/RefLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureRefLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.ref.customizer") - && target instanceof RefLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.ref", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/FileLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/FileLanguageAutoConfiguration.java index dae04bf522fa..e8ee21740be5 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/FileLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/FileLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureFileLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.file.customizer") - && target instanceof FileLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.file", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/SimpleLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/SimpleLanguageAutoConfiguration.java index 99f57362b8b7..6a2757caa149 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/SimpleLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/simple/springboot/SimpleLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureSimpleLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.simple.customizer") - && target instanceof SimpleLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.simple", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/tokenizer/springboot/TokenizeLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/tokenizer/springboot/TokenizeLanguageAutoConfiguration.java index 6e384a71694f..5d5350bd2f05 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/tokenizer/springboot/TokenizeLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/tokenizer/springboot/TokenizeLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureTokenizeLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.tokenize.customizer") - && target instanceof TokenizeLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.tokenize", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/variable/springboot/VariableLanguageAutoConfiguration.java b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/variable/springboot/VariableLanguageAutoConfiguration.java index f10d6855aaa6..fee9a2713623 100644 --- a/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/variable/springboot/VariableLanguageAutoConfiguration.java +++ b/components-starter/camel-core-starter/src/main/java/org/apache/camel/language/variable/springboot/VariableLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureVariableLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.variable.customizer") - && target instanceof VariableLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.variable", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java b/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java index ca910ca8b4e3..28e48a7fe133 100644 --- a/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java +++ b/components-starter/camel-couchbase-starter/src/main/java/org/apache/camel/component/couchbase/springboot/CouchbaseComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCouchbaseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.couchbase.customizer") - && target instanceof CouchbaseComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.couchbase", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-couchdb-starter/src/main/java/org/apache/camel/component/couchdb/springboot/CouchDbComponentAutoConfiguration.java b/components-starter/camel-couchdb-starter/src/main/java/org/apache/camel/component/couchdb/springboot/CouchDbComponentAutoConfiguration.java index 98e48ffdad39..416dd84d7a7a 100644 --- a/components-starter/camel-couchdb-starter/src/main/java/org/apache/camel/component/couchdb/springboot/CouchDbComponentAutoConfiguration.java +++ b/components-starter/camel-couchdb-starter/src/main/java/org/apache/camel/component/couchdb/springboot/CouchDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCouchDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.couchdb.customizer") - && target instanceof CouchDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.couchdb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cron-starter/src/main/java/org/apache/camel/component/cron/springboot/CronComponentAutoConfiguration.java b/components-starter/camel-cron-starter/src/main/java/org/apache/camel/component/cron/springboot/CronComponentAutoConfiguration.java index 0095673fbf5a..e5210b530af6 100644 --- a/components-starter/camel-cron-starter/src/main/java/org/apache/camel/component/cron/springboot/CronComponentAutoConfiguration.java +++ b/components-starter/camel-cron-starter/src/main/java/org/apache/camel/component/cron/springboot/CronComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCronComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cron.customizer") - && target instanceof CronComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cron", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-crypto-pgp-starter/src/main/java/org/apache/camel/converter/crypto/springboot/PGPDataFormatAutoConfiguration.java b/components-starter/camel-crypto-pgp-starter/src/main/java/org/apache/camel/converter/crypto/springboot/PGPDataFormatAutoConfiguration.java index cdb5896842ba..2df8ed5b8746 100644 --- a/components-starter/camel-crypto-pgp-starter/src/main/java/org/apache/camel/converter/crypto/springboot/PGPDataFormatAutoConfiguration.java +++ b/components-starter/camel-crypto-pgp-starter/src/main/java/org/apache/camel/converter/crypto/springboot/PGPDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configurePGPDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.pgp.customizer") - && target instanceof PGPDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.pgp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentAutoConfiguration.java b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentAutoConfiguration.java index 855e11470926..1416ec533c3d 100644 --- a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentAutoConfiguration.java +++ b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDigitalSignatureComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.crypto.customizer") - && target instanceof DigitalSignatureComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.crypto", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentConverter.java b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentConverter.java index 101ac553f3a8..b661def70bc4 100644 --- a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentConverter.java +++ b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/component/crypto/springboot/DigitalSignatureComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -53,23 +54,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "java.security.KeyStore": return applicationContext.getBean(ref, java.security.KeyStore.class); - case "java.security.PrivateKey": return applicationContext.getBean(ref, java.security.PrivateKey.class); - case "java.security.cert.Certificate": return applicationContext.getBean(ref, java.security.cert.Certificate.class); - case "org.apache.camel.component.crypto.DigitalSignatureConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.crypto.DigitalSignatureConfiguration.class); - case "org.apache.camel.support.jsse.KeyStoreParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.KeyStoreParameters.class); - case "java.security.PublicKey": return applicationContext.getBean(ref, java.security.PublicKey.class); - case "java.security.SecureRandom": return applicationContext.getBean(ref, java.security.SecureRandom.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.crypto"); } } \ No newline at end of file diff --git a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatAutoConfiguration.java b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatAutoConfiguration.java index ebdabf3dbc03..a2ddd4bd253f 100644 --- a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatAutoConfiguration.java +++ b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureCryptoDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.crypto.customizer") - && target instanceof CryptoDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.crypto", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatConverter.java b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatConverter.java index cab40a8a4610..38e616c5cc32 100644 --- a/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatConverter.java +++ b/components-starter/camel-crypto-starter/src/main/java/org/apache/camel/converter/crypto/springboot/CryptoDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "java.security.Key": return applicationContext.getBean(ref, java.security.Key.class); - case "java.security.spec.AlgorithmParameterSpec": return applicationContext.getBean(ref, java.security.spec.AlgorithmParameterSpec.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.crypto"); } } \ No newline at end of file diff --git a/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatAutoConfiguration.java b/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatAutoConfiguration.java index bc33ab594671..71429643343f 100644 --- a/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatAutoConfiguration.java +++ b/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureCsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.csv.customizer") - && target instanceof CsvDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.csv", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentAutoConfiguration.java b/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentAutoConfiguration.java index 4925a3c6c9fe..2cb48a1e626e 100644 --- a/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentAutoConfiguration.java +++ b/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCxfRsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cxfrs.customizer") - && target instanceof CxfRsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cxfrs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentConverter.java b/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentConverter.java index f1e1d7bc2574..fae37981a5c5 100644 --- a/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentConverter.java +++ b/components-starter/camel-cxf-rest-starter/src/main/java/org/apache/camel/component/cxf/jaxrs/springboot/CxfRsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.cxfrs"); } } \ No newline at end of file diff --git a/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentAutoConfiguration.java b/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentAutoConfiguration.java index 2a7ffef90633..de6432035d6f 100644 --- a/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentAutoConfiguration.java +++ b/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCxfComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cxf.customizer") - && target instanceof CxfComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cxf", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentConverter.java b/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentConverter.java index a784a2412322..7df583d9bace 100644 --- a/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentConverter.java +++ b/components-starter/camel-cxf-soap-starter/src/main/java/org/apache/camel/component/cxf/jaxws/springboot/CxfComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.cxf"); } } \ No newline at end of file diff --git a/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentAutoConfiguration.java b/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentAutoConfiguration.java index 1b5af299108e..97ef66a11db0 100644 --- a/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentAutoConfiguration.java +++ b/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCyberArkVaultComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.cyberark-vault.customizer") - && target instanceof CyberArkVaultComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cyberark-vault", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentConverter.java b/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentConverter.java index 2f04fe5a9db7..0b6230f9bb9e 100644 --- a/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentConverter.java +++ b/components-starter/camel-cyberark-vault-starter/src/main/java/org/apache/camel/component/cyberark/vault/springboot/CyberArkVaultComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.cyberark.vault.CyberArkVaultConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.cyberark.vault.CyberArkVaultConfiguration.class); - case "org.apache.camel.component.cyberark.vault.client.ConjurClient": return applicationContext.getBean(ref, org.apache.camel.component.cyberark.vault.client.ConjurClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.cyberark-vault"); } } \ No newline at end of file diff --git a/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentAutoConfiguration.java b/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentAutoConfiguration.java index 2206b18f3325..03eccb9c2001 100644 --- a/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentAutoConfiguration.java +++ b/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDaprComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dapr.customizer") - && target instanceof DaprComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dapr", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentConverter.java b/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentConverter.java index f23feee6c820..409098babce0 100644 --- a/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentConverter.java +++ b/components-starter/camel-dapr-starter/src/main/java/org/apache/camel/component/dapr/springboot/DaprComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.dapr.client.DaprClient": return applicationContext.getBean(ref, io.dapr.client.DaprClient.class); - case "org.apache.camel.component.dapr.DaprConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.dapr.DaprConfiguration.class); - case "io.dapr.client.DaprPreviewClient": return applicationContext.getBean(ref, io.dapr.client.DaprPreviewClient.class); - case "io.dapr.client.domain.HttpExtension": return applicationContext.getBean(ref, io.dapr.client.domain.HttpExtension.class); - case "io.dapr.workflows.client.DaprWorkflowClient": return applicationContext.getBean(ref, io.dapr.workflows.client.DaprWorkflowClient.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.dapr"); } } \ No newline at end of file diff --git a/components-starter/camel-dataformat-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java b/components-starter/camel-dataformat-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java index b11f9030e6e5..72e886db9952 100644 --- a/components-starter/camel-dataformat-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java +++ b/components-starter/camel-dataformat-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDataFormatComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dataformat.customizer") - && target instanceof DataFormatComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dataformat", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java index d1409ab8ec9e..1a213b1fb2a9 100644 --- a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java +++ b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDataSetComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dataset.customizer") - && target instanceof DataSetComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dataset", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentConverter.java b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentConverter.java index f0e882a21d17..07b70c9426d4 100644 --- a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentConverter.java +++ b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.ExchangeFormatter": return applicationContext.getBean(ref, org.apache.camel.spi.ExchangeFormatter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.dataset"); } } \ No newline at end of file diff --git a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentAutoConfiguration.java b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentAutoConfiguration.java index fc18a9341d94..55eb349b3a62 100644 --- a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentAutoConfiguration.java +++ b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDataSetTestComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dataset-test.customizer") - && target instanceof DataSetTestComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dataset-test", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentConverter.java b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentConverter.java index e9829d65ff45..4cf8e5c90e71 100644 --- a/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentConverter.java +++ b/components-starter/camel-dataset-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetTestComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.ExchangeFormatter": return applicationContext.getBean(ref, org.apache.camel.spi.ExchangeFormatter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.dataset-test"); } } \ No newline at end of file diff --git a/components-starter/camel-datasonnet-starter/src/main/java/org/apache/camel/language/datasonnet/springboot/DatasonnetLanguageAutoConfiguration.java b/components-starter/camel-datasonnet-starter/src/main/java/org/apache/camel/language/datasonnet/springboot/DatasonnetLanguageAutoConfiguration.java index 05f08e106fe0..1e488d0581e7 100644 --- a/components-starter/camel-datasonnet-starter/src/main/java/org/apache/camel/language/datasonnet/springboot/DatasonnetLanguageAutoConfiguration.java +++ b/components-starter/camel-datasonnet-starter/src/main/java/org/apache/camel/language/datasonnet/springboot/DatasonnetLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureDatasonnetLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.datasonnet.customizer") - && target instanceof DatasonnetLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.datasonnet", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentAutoConfiguration.java b/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentAutoConfiguration.java index 9bee841c35b7..26d720fac24b 100644 --- a/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentAutoConfiguration.java +++ b/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDebeziumDb2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.debezium-db2.customizer") - && target instanceof DebeziumDb2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-db2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentConverter.java b/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentConverter.java index 9a498a109a2b..b57964d7e372 100644 --- a/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentConverter.java +++ b/components-starter/camel-debezium-db2-starter/src/main/java/org/apache/camel/component/debezium/db2/springboot/DebeziumDb2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.debezium.db2.configuration.Db2ConnectorEmbeddedDebeziumConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.debezium.db2.configuration.Db2ConnectorEmbeddedDebeziumConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.debezium-db2"); } } \ No newline at end of file diff --git a/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentAutoConfiguration.java b/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentAutoConfiguration.java index d5b71c5cb5a3..7ca5b1e19971 100644 --- a/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentAutoConfiguration.java +++ b/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDebeziumMongodbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.debezium-mongodb.customizer") - && target instanceof DebeziumMongodbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-mongodb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentConverter.java b/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentConverter.java index e51cacafed79..e0c71d18a13a 100644 --- a/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentConverter.java +++ b/components-starter/camel-debezium-mongodb-starter/src/main/java/org/apache/camel/component/debezium/mongodb/springboot/DebeziumMongodbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.debezium.mongodb.configuration.MongoDbConnectorEmbeddedDebeziumConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.debezium.mongodb.configuration.MongoDbConnectorEmbeddedDebeziumConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.debezium-mongodb"); } } \ No newline at end of file diff --git a/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentAutoConfiguration.java b/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentAutoConfiguration.java index 57fbbe20c387..2fb5163d4975 100644 --- a/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentAutoConfiguration.java +++ b/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDebeziumMySqlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.debezium-mysql.customizer") - && target instanceof DebeziumMySqlComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-mysql", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentConverter.java b/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentConverter.java index cdcc5466c85c..fcf6630e1e13 100644 --- a/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentConverter.java +++ b/components-starter/camel-debezium-mysql-starter/src/main/java/org/apache/camel/component/debezium/mysql/springboot/DebeziumMySqlComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.debezium.mysql.configuration.MySqlConnectorEmbeddedDebeziumConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.debezium.mysql.configuration.MySqlConnectorEmbeddedDebeziumConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.debezium-mysql"); } } \ No newline at end of file diff --git a/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentAutoConfiguration.java b/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentAutoConfiguration.java index 88d249c0d0e5..828f26cb3754 100644 --- a/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentAutoConfiguration.java +++ b/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDebeziumOracleComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.debezium-oracle.customizer") - && target instanceof DebeziumOracleComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-oracle", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentConverter.java b/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentConverter.java index 802963781524..bdf5469fdb5c 100644 --- a/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentConverter.java +++ b/components-starter/camel-debezium-oracle-starter/src/main/java/org/apache/camel/component/debezium/oracle/springboot/DebeziumOracleComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.debezium.oracle.configuration.OracleConnectorEmbeddedDebeziumConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.debezium.oracle.configuration.OracleConnectorEmbeddedDebeziumConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.debezium-oracle"); } } \ No newline at end of file diff --git a/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentAutoConfiguration.java b/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentAutoConfiguration.java index 6a35ae2eda61..e5e7173b8cd3 100644 --- a/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentAutoConfiguration.java +++ b/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDebeziumPostgresComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.debezium-postgres.customizer") - && target instanceof DebeziumPostgresComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-postgres", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentConverter.java b/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentConverter.java index 63ae8ad447bb..77a8ec82e810 100644 --- a/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentConverter.java +++ b/components-starter/camel-debezium-postgres-starter/src/main/java/org/apache/camel/component/debezium/postgres/springboot/DebeziumPostgresComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.debezium.postgres.configuration.PostgresConnectorEmbeddedDebeziumConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.debezium.postgres.configuration.PostgresConnectorEmbeddedDebeziumConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.debezium-postgres"); } } \ No newline at end of file diff --git a/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentAutoConfiguration.java b/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentAutoConfiguration.java index d0efffd28ea9..87b2fdc880c2 100644 --- a/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentAutoConfiguration.java +++ b/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDebeziumSqlserverComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.debezium-sqlserver.customizer") - && target instanceof DebeziumSqlserverComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-sqlserver", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentConverter.java b/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentConverter.java index a0b394b39235..e568c2366b2b 100644 --- a/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentConverter.java +++ b/components-starter/camel-debezium-sqlserver-starter/src/main/java/org/apache/camel/component/debezium/sqlserver/springboot/DebeziumSqlserverComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.debezium.sqlserver.configuration.SqlServerConnectorEmbeddedDebeziumConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.debezium.sqlserver.configuration.SqlServerConnectorEmbeddedDebeziumConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.debezium-sqlserver"); } } \ No newline at end of file diff --git a/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/component/dfdl/springboot/DfdlComponentAutoConfiguration.java b/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/component/dfdl/springboot/DfdlComponentAutoConfiguration.java index 242f3a7e8560..8cb95a1435c6 100644 --- a/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/component/dfdl/springboot/DfdlComponentAutoConfiguration.java +++ b/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/component/dfdl/springboot/DfdlComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDfdlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dfdl.customizer") - && target instanceof DfdlComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dfdl", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/dataformat/dfdl/springboot/DfdlDataFormatAutoConfiguration.java b/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/dataformat/dfdl/springboot/DfdlDataFormatAutoConfiguration.java index 72fe054616b4..288c5951ba55 100644 --- a/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/dataformat/dfdl/springboot/DfdlDataFormatAutoConfiguration.java +++ b/components-starter/camel-dfdl-starter/src/main/java/org/apache/camel/dataformat/dfdl/springboot/DfdlDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureDfdlDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.dfdl.customizer") - && target instanceof DfdlDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.dfdl", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentAutoConfiguration.java b/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentAutoConfiguration.java index 7c3e72c8f39c..fad4d23a87ba 100644 --- a/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentAutoConfiguration.java +++ b/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDhis2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dhis2.customizer") - && target instanceof Dhis2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dhis2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentConverter.java b/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentConverter.java index 1f1728523f1a..1e502bc794d1 100644 --- a/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentConverter.java +++ b/components-starter/camel-dhis2-starter/src/main/java/org/apache/camel/component/dhis2/springboot/Dhis2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.hisp.dhis.integration.sdk.api.Dhis2Client": return applicationContext.getBean(ref, org.hisp.dhis.integration.sdk.api.Dhis2Client.class); - case "org.apache.camel.component.dhis2.Dhis2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.dhis2.Dhis2Configuration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.dhis2"); } } \ No newline at end of file diff --git a/components-starter/camel-direct-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java b/components-starter/camel-direct-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java index 55a4ed85cdcb..baef6741e901 100644 --- a/components-starter/camel-direct-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java +++ b/components-starter/camel-direct-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDirectComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.direct.customizer") - && target instanceof DirectComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.direct", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentAutoConfiguration.java b/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentAutoConfiguration.java index 5c7aeaf72b79..63b01765de40 100644 --- a/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentAutoConfiguration.java +++ b/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDisruptorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.disruptor.customizer") - && target instanceof DisruptorComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.disruptor", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentAutoConfiguration.java b/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentAutoConfiguration.java index e431d7012fbc..c767ff619ce1 100644 --- a/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentAutoConfiguration.java +++ b/components-starter/camel-disruptor-starter/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDisruptorVmComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.disruptor-vm.customizer") - && target instanceof DisruptorVmComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.disruptor-vm", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-djl-starter/src/main/java/org/apache/camel/component/djl/springboot/DJLComponentAutoConfiguration.java b/components-starter/camel-djl-starter/src/main/java/org/apache/camel/component/djl/springboot/DJLComponentAutoConfiguration.java index f2fd32033b90..08c442235799 100644 --- a/components-starter/camel-djl-starter/src/main/java/org/apache/camel/component/djl/springboot/DJLComponentAutoConfiguration.java +++ b/components-starter/camel-djl-starter/src/main/java/org/apache/camel/component/djl/springboot/DJLComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDJLComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.djl.customizer") - && target instanceof DJLComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.djl", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dns-starter/src/main/java/org/apache/camel/component/dns/springboot/DnsComponentAutoConfiguration.java b/components-starter/camel-dns-starter/src/main/java/org/apache/camel/component/dns/springboot/DnsComponentAutoConfiguration.java index 3a429f2eb933..ffb4f6cb9676 100644 --- a/components-starter/camel-dns-starter/src/main/java/org/apache/camel/component/dns/springboot/DnsComponentAutoConfiguration.java +++ b/components-starter/camel-dns-starter/src/main/java/org/apache/camel/component/dns/springboot/DnsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDnsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dns.customizer") - && target instanceof DnsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dns", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentAutoConfiguration.java b/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentAutoConfiguration.java index 864424c34985..ec04ae2ca8f1 100644 --- a/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentAutoConfiguration.java +++ b/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDockerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.docker.customizer") - && target instanceof DockerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.docker", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentConverter.java b/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentConverter.java index 54914a9c68b7..771c45c485eb 100644 --- a/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentConverter.java +++ b/components-starter/camel-docker-starter/src/main/java/org/apache/camel/component/docker/springboot/DockerComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.docker.DockerConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.docker.DockerConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.docker"); } } \ No newline at end of file diff --git a/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentAutoConfiguration.java b/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentAutoConfiguration.java index 113f50c1350b..d6f6af12b520 100644 --- a/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentAutoConfiguration.java +++ b/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDoclingComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.docling.customizer") - && target instanceof DoclingComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.docling", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentConverter.java b/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentConverter.java index af1131246e52..16f43dda1ed3 100644 --- a/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentConverter.java +++ b/components-starter/camel-docling-starter/src/main/java/org/apache/camel/component/docling/springboot/DoclingComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.docling.DoclingConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.docling.DoclingConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.docling"); } } \ No newline at end of file diff --git a/components-starter/camel-drill-starter/src/main/java/org/apache/camel/component/drill/springboot/DrillComponentAutoConfiguration.java b/components-starter/camel-drill-starter/src/main/java/org/apache/camel/component/drill/springboot/DrillComponentAutoConfiguration.java index 919de5f36102..2738fda8db53 100644 --- a/components-starter/camel-drill-starter/src/main/java/org/apache/camel/component/drill/springboot/DrillComponentAutoConfiguration.java +++ b/components-starter/camel-drill-starter/src/main/java/org/apache/camel/component/drill/springboot/DrillComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDrillComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.drill.customizer") - && target instanceof DrillComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.drill", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dropbox-starter/src/main/java/org/apache/camel/component/dropbox/springboot/DropboxComponentAutoConfiguration.java b/components-starter/camel-dropbox-starter/src/main/java/org/apache/camel/component/dropbox/springboot/DropboxComponentAutoConfiguration.java index b1856080633a..fdb9d22da214 100644 --- a/components-starter/camel-dropbox-starter/src/main/java/org/apache/camel/component/dropbox/springboot/DropboxComponentAutoConfiguration.java +++ b/components-starter/camel-dropbox-starter/src/main/java/org/apache/camel/component/dropbox/springboot/DropboxComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDropboxComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dropbox.customizer") - && target instanceof DropboxComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dropbox", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/control/springboot/DynamicRouterControlComponentAutoConfiguration.java b/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/control/springboot/DynamicRouterControlComponentAutoConfiguration.java index 4eb669e0bdf9..ba01cc3452bb 100644 --- a/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/control/springboot/DynamicRouterControlComponentAutoConfiguration.java +++ b/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/control/springboot/DynamicRouterControlComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDynamicRouterControlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dynamic-router-control.customizer") - && target instanceof DynamicRouterControlComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dynamic-router-control", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/routing/springboot/DynamicRouterComponentAutoConfiguration.java b/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/routing/springboot/DynamicRouterComponentAutoConfiguration.java index 9e25cf640b83..09bfe5ee223f 100644 --- a/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/routing/springboot/DynamicRouterComponentAutoConfiguration.java +++ b/components-starter/camel-dynamic-router-starter/src/main/java/org/apache/camel/component/dynamicrouter/routing/springboot/DynamicRouterComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDynamicRouterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.dynamic-router.customizer") - && target instanceof DynamicRouterComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dynamic-router", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentAutoConfiguration.java b/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentAutoConfiguration.java index ac426c7aeffa..c0013a2fd0cc 100644 --- a/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentAutoConfiguration.java +++ b/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureEhcacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ehcache.customizer") - && target instanceof EhcacheComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ehcache", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentConverter.java b/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentConverter.java index c26ff07959f5..7d496d4dd94a 100644 --- a/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentConverter.java +++ b/components-starter/camel-ehcache-starter/src/main/java/org/apache/camel/component/ehcache/springboot/EhcacheComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.ehcache.CacheManager": return applicationContext.getBean(ref, org.ehcache.CacheManager.class); - case "org.ehcache.config.Configuration": return applicationContext.getBean(ref, org.ehcache.config.Configuration.class); - case "org.ehcache.config.CacheConfiguration": return applicationContext.getBean(ref, org.ehcache.config.CacheConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ehcache"); } } \ No newline at end of file diff --git a/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentAutoConfiguration.java b/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentAutoConfiguration.java index eea80255b62e..f3b5c3ff68f3 100644 --- a/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentAutoConfiguration.java +++ b/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureElasticsearchRestClientComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.elasticsearch-rest-client.customizer") - && target instanceof ElasticsearchRestClientComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.elasticsearch-rest-client", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentConverter.java b/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentConverter.java index ed5beda868b7..ee42ca841c16 100644 --- a/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentConverter.java +++ b/components-starter/camel-elasticsearch-rest-client-starter/src/main/java/org/apache/camel/component/elasticsearch/rest/client/springboot/ElasticsearchRestClientComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.elasticsearch.client.RestClient": return applicationContext.getBean(ref, org.elasticsearch.client.RestClient.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.elasticsearch-rest-client"); } \ No newline at end of file diff --git a/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentAutoConfiguration.java b/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentAutoConfiguration.java index 9e34570963c8..d96cf70cf9a8 100644 --- a/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentAutoConfiguration.java +++ b/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureElasticsearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.elasticsearch.customizer") - && target instanceof ElasticsearchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.elasticsearch", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentConverter.java b/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentConverter.java index df42df2174ac..fc1c0c6e2dca 100644 --- a/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentConverter.java +++ b/components-starter/camel-elasticsearch-starter/src/main/java/org/apache/camel/component/es/springboot/ElasticsearchComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.elasticsearch.client.RestClient": return applicationContext.getBean(ref, org.elasticsearch.client.RestClient.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.elasticsearch"); } \ No newline at end of file diff --git a/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentAutoConfiguration.java b/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentAutoConfiguration.java index e2c97c52a320..7f6b1fcd5836 100644 --- a/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentAutoConfiguration.java +++ b/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureExecComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.exec.customizer") - && target instanceof ExecComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.exec", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-fastjson-starter/src/main/java/org/apache/camel/component/fastjson/springboot/FastjsonDataFormatAutoConfiguration.java b/components-starter/camel-fastjson-starter/src/main/java/org/apache/camel/component/fastjson/springboot/FastjsonDataFormatAutoConfiguration.java index 26aa79e685ee..dc0dae50bef5 100644 --- a/components-starter/camel-fastjson-starter/src/main/java/org/apache/camel/component/fastjson/springboot/FastjsonDataFormatAutoConfiguration.java +++ b/components-starter/camel-fastjson-starter/src/main/java/org/apache/camel/component/fastjson/springboot/FastjsonDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureFastjsonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.fastjson.customizer") - && target instanceof FastjsonDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.fastjson", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentAutoConfiguration.java b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentAutoConfiguration.java index 94d5f36bae01..65cabc9628fb 100644 --- a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentAutoConfiguration.java +++ b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFhirComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.fhir.customizer") - && target instanceof FhirComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.fhir", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentConverter.java b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentConverter.java index d0592f7b1bbd..9e0224429bd7 100644 --- a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentConverter.java +++ b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "ca.uhn.fhir.rest.client.api.IGenericClient": return applicationContext.getBean(ref, ca.uhn.fhir.rest.client.api.IGenericClient.class); - case "ca.uhn.fhir.rest.client.api.IRestfulClientFactory": return applicationContext.getBean(ref, ca.uhn.fhir.rest.client.api.IRestfulClientFactory.class); - case "org.apache.camel.component.fhir.FhirConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.fhir.FhirConfiguration.class); - case "ca.uhn.fhir.context.FhirContext": return applicationContext.getBean(ref, ca.uhn.fhir.context.FhirContext.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.fhir"); } } \ No newline at end of file diff --git a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirJsonDataFormatAutoConfiguration.java b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirJsonDataFormatAutoConfiguration.java index bc545a5e9bc9..7e49490b940b 100644 --- a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirJsonDataFormatAutoConfiguration.java +++ b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirJsonDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureFhirJsonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.fhir-json.customizer") - && target instanceof FhirJsonDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.fhir-json", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirXmlDataFormatAutoConfiguration.java b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirXmlDataFormatAutoConfiguration.java index e044d2b72a86..d73e4556b969 100644 --- a/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirXmlDataFormatAutoConfiguration.java +++ b/components-starter/camel-fhir-starter/src/main/java/org/apache/camel/component/fhir/springboot/FhirXmlDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureFhirXmlDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.fhir-xml.customizer") - && target instanceof FhirXmlDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.fhir-xml", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/FileComponentAutoConfiguration.java b/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/FileComponentAutoConfiguration.java index 81d78f917152..81a0289b9cb0 100644 --- a/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/FileComponentAutoConfiguration.java +++ b/components-starter/camel-file-starter/src/main/java/org/apache/camel/component/file/springboot/FileComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFileComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.file.customizer") - && target instanceof FileComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.file", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentAutoConfiguration.java b/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentAutoConfiguration.java index c108c2e0a495..6d0330e776de 100644 --- a/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentAutoConfiguration.java +++ b/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFileWatchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.file-watch.customizer") - && target instanceof FileWatchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.file-watch", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentConverter.java b/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentConverter.java index 04293797e2b5..e9f75ae05fb5 100644 --- a/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentConverter.java +++ b/components-starter/camel-file-watch-starter/src/main/java/org/apache/camel/component/file/watch/springboot/FileWatchComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.methvin.watcher.hashing.FileHasher": return applicationContext.getBean(ref, io.methvin.watcher.hashing.FileHasher.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.file-watch"); } } \ No newline at end of file diff --git a/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/component/flatpack/springboot/FlatpackComponentAutoConfiguration.java b/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/component/flatpack/springboot/FlatpackComponentAutoConfiguration.java index 1e8fce9f2e46..93e2ec0d96f6 100644 --- a/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/component/flatpack/springboot/FlatpackComponentAutoConfiguration.java +++ b/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/component/flatpack/springboot/FlatpackComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFlatpackComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.flatpack.customizer") - && target instanceof FlatpackComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.flatpack", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatAutoConfiguration.java b/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatAutoConfiguration.java index 542cfc8c3eb4..3bb942388ac4 100644 --- a/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatAutoConfiguration.java +++ b/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureFlatpackDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.flatpack.customizer") - && target instanceof FlatpackDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.flatpack", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatConverter.java b/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatConverter.java index f6e82bdae33c..e94071d84564 100644 --- a/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatConverter.java +++ b/components-starter/camel-flatpack-starter/src/main/java/org/apache/camel/dataformat/flatpack/springboot/FlatpackDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "net.sf.flatpack.ParserFactory": return applicationContext.getBean(ref, net.sf.flatpack.ParserFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.flatpack"); } } \ No newline at end of file diff --git a/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentAutoConfiguration.java b/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentAutoConfiguration.java index ba75b11e8cd2..b42b819f0093 100644 --- a/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentAutoConfiguration.java +++ b/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFlinkComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.flink.customizer") - && target instanceof FlinkComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.flink", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentConverter.java b/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentConverter.java index 5b93cc8bce73..884b278f872f 100644 --- a/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentConverter.java +++ b/components-starter/camel-flink-starter/src/main/java/org/apache/camel/component/flink/springboot/FlinkComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.flink.DataSetCallback": return applicationContext.getBean(ref, org.apache.camel.component.flink.DataSetCallback.class); - case "org.apache.flink.streaming.api.datastream.DataStream": return applicationContext.getBean(ref, org.apache.flink.streaming.api.datastream.DataStream.class); - case "org.apache.camel.component.flink.DataStreamCallback": return applicationContext.getBean(ref, org.apache.camel.component.flink.DataStreamCallback.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.flink"); } } \ No newline at end of file diff --git a/components-starter/camel-flowable-starter/src/main/java/org/apache/camel/component/flowable/springboot/FlowableComponentAutoConfiguration.java b/components-starter/camel-flowable-starter/src/main/java/org/apache/camel/component/flowable/springboot/FlowableComponentAutoConfiguration.java index 8eda4404e9ab..80e8e48cf1cc 100644 --- a/components-starter/camel-flowable-starter/src/main/java/org/apache/camel/component/flowable/springboot/FlowableComponentAutoConfiguration.java +++ b/components-starter/camel-flowable-starter/src/main/java/org/apache/camel/component/flowable/springboot/FlowableComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFlowableComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.flowable.customizer") - && target instanceof FlowableComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.flowable", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-fop-starter/src/main/java/org/apache/camel/component/fop/springboot/FopComponentAutoConfiguration.java b/components-starter/camel-fop-starter/src/main/java/org/apache/camel/component/fop/springboot/FopComponentAutoConfiguration.java index 618ed07d37de..5ebbee17a20b 100644 --- a/components-starter/camel-fop-starter/src/main/java/org/apache/camel/component/fop/springboot/FopComponentAutoConfiguration.java +++ b/components-starter/camel-fop-starter/src/main/java/org/apache/camel/component/fop/springboot/FopComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFopComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.fop.customizer") - && target instanceof FopComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.fop", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-fory-starter/src/main/java/org/apache/camel/component/fory/springboot/ForyDataFormatAutoConfiguration.java b/components-starter/camel-fory-starter/src/main/java/org/apache/camel/component/fory/springboot/ForyDataFormatAutoConfiguration.java index a30115076d67..417007e578d3 100644 --- a/components-starter/camel-fory-starter/src/main/java/org/apache/camel/component/fory/springboot/ForyDataFormatAutoConfiguration.java +++ b/components-starter/camel-fory-starter/src/main/java/org/apache/camel/component/fory/springboot/ForyDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureForyDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.fory.customizer") - && target instanceof ForyDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.fory", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentAutoConfiguration.java b/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentAutoConfiguration.java index a93cda07cbda..cb6394d6faa2 100644 --- a/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentAutoConfiguration.java +++ b/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFreemarkerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.freemarker.customizer") - && target instanceof FreemarkerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.freemarker", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConverter.java b/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConverter.java index f9125601937d..f092a8491ab0 100644 --- a/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConverter.java +++ b/components-starter/camel-freemarker-starter/src/main/java/org/apache/camel/component/freemarker/springboot/FreemarkerComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "freemarker.template.Configuration": return applicationContext.getBean(ref, freemarker.template.Configuration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.freemarker"); } } \ No newline at end of file diff --git a/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpComponentAutoConfiguration.java b/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpComponentAutoConfiguration.java index 7398886d8f5d..58dbecfb455f 100644 --- a/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpComponentAutoConfiguration.java +++ b/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFtpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ftp.customizer") - && target instanceof FtpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ftp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpsComponentAutoConfiguration.java b/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpsComponentAutoConfiguration.java index 74c6757fd3e4..f385c832d1be 100644 --- a/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpsComponentAutoConfiguration.java +++ b/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/FtpsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFtpsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ftps.customizer") - && target instanceof FtpsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ftps", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/SftpComponentAutoConfiguration.java b/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/SftpComponentAutoConfiguration.java index ef6ab1e03f2b..a4bf766367fb 100644 --- a/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/SftpComponentAutoConfiguration.java +++ b/components-starter/camel-ftp-starter/src/main/java/org/apache/camel/component/file/remote/springboot/SftpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSftpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.sftp.customizer") - && target instanceof SftpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sftp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentAutoConfiguration.java b/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentAutoConfiguration.java index 9f94b17bb576..bdc756abb6a5 100644 --- a/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentAutoConfiguration.java +++ b/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGeoCoderComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.geocoder.customizer") - && target instanceof GeoCoderComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.geocoder", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentConverter.java b/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentConverter.java index bfcc3e12aace..61b022303761 100644 --- a/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentConverter.java +++ b/components-starter/camel-geocoder-starter/src/main/java/org/apache/camel/component/geocoder/springboot/GeoCoderComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.google.maps.GeoApiContext": return applicationContext.getBean(ref, com.google.maps.GeoApiContext.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.geocoder"); } } \ No newline at end of file diff --git a/components-starter/camel-git-starter/src/main/java/org/apache/camel/component/git/springboot/GitComponentAutoConfiguration.java b/components-starter/camel-git-starter/src/main/java/org/apache/camel/component/git/springboot/GitComponentAutoConfiguration.java index 5489c49fbb86..3c86379bf1e6 100644 --- a/components-starter/camel-git-starter/src/main/java/org/apache/camel/component/git/springboot/GitComponentAutoConfiguration.java +++ b/components-starter/camel-git-starter/src/main/java/org/apache/camel/component/git/springboot/GitComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGitComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.git.customizer") - && target instanceof GitComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.git", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-github2-starter/src/main/java/org/apache/camel/component/github2/springboot/GitHub2ComponentAutoConfiguration.java b/components-starter/camel-github2-starter/src/main/java/org/apache/camel/component/github2/springboot/GitHub2ComponentAutoConfiguration.java index 066803489839..6f4ec82a548c 100644 --- a/components-starter/camel-github2-starter/src/main/java/org/apache/camel/component/github2/springboot/GitHub2ComponentAutoConfiguration.java +++ b/components-starter/camel-github2-starter/src/main/java/org/apache/camel/component/github2/springboot/GitHub2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGitHub2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.github2.customizer") - && target instanceof GitHub2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.github2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentAutoConfiguration.java b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentAutoConfiguration.java index a8cda0591e42..b99207b10152 100644 --- a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentAutoConfiguration.java +++ b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleBigQueryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-bigquery.customizer") - && target instanceof GoogleBigQueryComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-bigquery", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentConverter.java b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentConverter.java index 405decacaf57..4a4c25877a9b 100644 --- a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentConverter.java +++ b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/springboot/GoogleBigQueryComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-bigquery"); } } \ No newline at end of file diff --git a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java index f7bc97e54350..76c4b33fc1d6 100644 --- a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java +++ b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleBigQuerySQLComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-bigquery-sql.customizer") - && target instanceof GoogleBigQuerySQLComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-bigquery-sql", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConverter.java b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConverter.java index 54f60001c587..a36e7d15827c 100644 --- a/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConverter.java +++ b/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.bigquery.GoogleBigQueryConnectionFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-bigquery-sql"); } } \ No newline at end of file diff --git a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentAutoConfiguration.java b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentAutoConfiguration.java index d1015403100f..b170e568be88 100644 --- a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentAutoConfiguration.java +++ b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleCalendarComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-calendar.customizer") - && target instanceof GoogleCalendarComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-calendar", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentConverter.java b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentConverter.java index 5b44d7e78137..90a8a16f8500 100644 --- a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentConverter.java +++ b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/springboot/GoogleCalendarComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.calendar.GoogleCalendarConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.calendar.GoogleCalendarConfiguration.class); - case "org.apache.camel.component.google.calendar.GoogleCalendarClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.calendar.GoogleCalendarClientFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-calendar"); } } \ No newline at end of file diff --git a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentAutoConfiguration.java b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentAutoConfiguration.java index 7e50f7c17820..4989d589adea 100644 --- a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentAutoConfiguration.java +++ b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleCalendarStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-calendar-stream.customizer") - && target instanceof GoogleCalendarStreamComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-calendar-stream", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConverter.java b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConverter.java index e2e4cfc94e81..d531bab8f7d2 100644 --- a/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConverter.java +++ b/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,18 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.calendar.stream.GoogleCalendarStreamConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.calendar.stream.GoogleCalendarStreamConfiguration.class); - case "org.apache.camel.component.google.calendar.GoogleCalendarClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.calendar.GoogleCalendarClientFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-calendar-stream"); } } \ No newline at end of file diff --git a/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentAutoConfiguration.java b/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentAutoConfiguration.java index ef2985b1249e..60f5a3866516 100644 --- a/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentAutoConfiguration.java +++ b/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleDriveComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-drive.customizer") - && target instanceof GoogleDriveComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-drive", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentConverter.java b/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentConverter.java index c4e6598a5227..e82d651d32ce 100644 --- a/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentConverter.java +++ b/components-starter/camel-google-drive-starter/src/main/java/org/apache/camel/component/google/drive/springboot/GoogleDriveComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.drive.GoogleDriveConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.drive.GoogleDriveConfiguration.class); - case "org.apache.camel.component.google.drive.GoogleDriveClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.drive.GoogleDriveClientFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-drive"); } } \ No newline at end of file diff --git a/components-starter/camel-google-functions-starter/src/main/java/org/apache/camel/component/google/functions/springboot/GoogleCloudFunctionsComponentAutoConfiguration.java b/components-starter/camel-google-functions-starter/src/main/java/org/apache/camel/component/google/functions/springboot/GoogleCloudFunctionsComponentAutoConfiguration.java index f6e46d83c3c3..0f78114bc5c2 100644 --- a/components-starter/camel-google-functions-starter/src/main/java/org/apache/camel/component/google/functions/springboot/GoogleCloudFunctionsComponentAutoConfiguration.java +++ b/components-starter/camel-google-functions-starter/src/main/java/org/apache/camel/component/google/functions/springboot/GoogleCloudFunctionsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleCloudFunctionsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-functions.customizer") - && target instanceof GoogleCloudFunctionsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-functions", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentAutoConfiguration.java b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentAutoConfiguration.java index 8864a1bb9cb8..3a70a5154d3a 100644 --- a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentAutoConfiguration.java +++ b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleMailComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-mail.customizer") - && target instanceof GoogleMailComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-mail", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentConverter.java b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentConverter.java index d748b0b2bfe0..063961e7663e 100644 --- a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentConverter.java +++ b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/springboot/GoogleMailComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.mail.GoogleMailConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.mail.GoogleMailConfiguration.class); - case "org.apache.camel.component.google.mail.GoogleMailClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.mail.GoogleMailClientFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-mail"); } } \ No newline at end of file diff --git a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentAutoConfiguration.java b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentAutoConfiguration.java index f4b0e717bafd..5b7b0e8be7be 100644 --- a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentAutoConfiguration.java +++ b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleMailStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-mail-stream.customizer") - && target instanceof GoogleMailStreamComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-mail-stream", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConverter.java b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConverter.java index f6da04fb492f..6bdd5b78fbd2 100644 --- a/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConverter.java +++ b/components-starter/camel-google-mail-starter/src/main/java/org/apache/camel/component/google/mail/stream/springboot/GoogleMailStreamComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.mail.GoogleMailClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.mail.GoogleMailClientFactory.class); - case "org.apache.camel.component.google.mail.stream.GoogleMailStreamConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.mail.stream.GoogleMailStreamConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-mail-stream"); } } \ No newline at end of file diff --git a/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentAutoConfiguration.java b/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentAutoConfiguration.java index 08bc7753195f..102991119665 100644 --- a/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentAutoConfiguration.java +++ b/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGooglePubsubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-pubsub.customizer") - && target instanceof GooglePubsubComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-pubsub", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentConverter.java b/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentConverter.java index 4d24daac9273..8faa1fa55bf0 100644 --- a/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentConverter.java +++ b/components-starter/camel-google-pubsub-starter/src/main/java/org/apache/camel/component/google/pubsub/springboot/GooglePubsubComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-pubsub"); } } \ No newline at end of file diff --git a/components-starter/camel-google-secret-manager-starter/src/main/java/org/apache/camel/component/google/secret/manager/springboot/GoogleSecretManagerComponentAutoConfiguration.java b/components-starter/camel-google-secret-manager-starter/src/main/java/org/apache/camel/component/google/secret/manager/springboot/GoogleSecretManagerComponentAutoConfiguration.java index 67cf53de2e5f..c5bc16f4c625 100644 --- a/components-starter/camel-google-secret-manager-starter/src/main/java/org/apache/camel/component/google/secret/manager/springboot/GoogleSecretManagerComponentAutoConfiguration.java +++ b/components-starter/camel-google-secret-manager-starter/src/main/java/org/apache/camel/component/google/secret/manager/springboot/GoogleSecretManagerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleSecretManagerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-secret-manager.customizer") - && target instanceof GoogleSecretManagerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-secret-manager", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentAutoConfiguration.java b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentAutoConfiguration.java index f48a5d189706..171834073963 100644 --- a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentAutoConfiguration.java +++ b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleSheetsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-sheets.customizer") - && target instanceof GoogleSheetsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-sheets", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentConverter.java b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentConverter.java index 89379124ed61..32e05e1887b7 100644 --- a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentConverter.java +++ b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/springboot/GoogleSheetsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.sheets.GoogleSheetsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.sheets.GoogleSheetsConfiguration.class); - case "org.apache.camel.component.google.sheets.GoogleSheetsClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.sheets.GoogleSheetsClientFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-sheets"); } } \ No newline at end of file diff --git a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentAutoConfiguration.java b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentAutoConfiguration.java index aa38ac44e74b..6ea61f92f3c7 100644 --- a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentAutoConfiguration.java +++ b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleSheetsStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-sheets-stream.customizer") - && target instanceof GoogleSheetsStreamComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-sheets-stream", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentConverter.java b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentConverter.java index f17bf9e2259a..44d3e8186cdb 100644 --- a/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentConverter.java +++ b/components-starter/camel-google-sheets-starter/src/main/java/org/apache/camel/component/google/sheets/stream/springboot/GoogleSheetsStreamComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.sheets.stream.GoogleSheetsStreamConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.sheets.stream.GoogleSheetsStreamConfiguration.class); - case "org.apache.camel.component.google.sheets.GoogleSheetsClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.google.sheets.GoogleSheetsClientFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-sheets-stream"); } } \ No newline at end of file diff --git a/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentAutoConfiguration.java b/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentAutoConfiguration.java index a41727423011..61f927e603d3 100644 --- a/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentAutoConfiguration.java +++ b/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleCloudStorageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-storage.customizer") - && target instanceof GoogleCloudStorageComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-storage", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentConverter.java b/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentConverter.java index e711e979d284..f6749ae1bae7 100644 --- a/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentConverter.java +++ b/components-starter/camel-google-storage-starter/src/main/java/org/apache/camel/component/google/storage/springboot/GoogleCloudStorageComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.storage.GoogleCloudStorageConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.storage.GoogleCloudStorageConfiguration.class); - case "com.google.cloud.storage.StorageClass": return applicationContext.getBean(ref, com.google.cloud.storage.StorageClass.class); - case "com.google.cloud.storage.Storage": return applicationContext.getBean(ref, com.google.cloud.storage.Storage.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-storage"); } } \ No newline at end of file diff --git a/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentAutoConfiguration.java b/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentAutoConfiguration.java index cf8ac5614ec5..53e4ebc44d90 100644 --- a/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentAutoConfiguration.java +++ b/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGoogleVertexAIComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.google-vertexai.customizer") - && target instanceof GoogleVertexAIComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-vertexai", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentConverter.java b/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentConverter.java index e7169d87e86b..fe9eef734a1a 100644 --- a/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentConverter.java +++ b/components-starter/camel-google-vertexai-starter/src/main/java/org/apache/camel/component/google/vertexai/springboot/GoogleVertexAIComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.google.vertexai.GoogleVertexAIConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.vertexai.GoogleVertexAIConfiguration.class); - case "com.google.genai.Client": return applicationContext.getBean(ref, com.google.genai.Client.class); - case "com.google.cloud.aiplatform.v1.PredictionServiceClient": return applicationContext.getBean(ref, com.google.cloud.aiplatform.v1.PredictionServiceClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-vertexai"); } } \ No newline at end of file diff --git a/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentAutoConfiguration.java b/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentAutoConfiguration.java index 6c7c4eaffae6..aeb4ad17de10 100644 --- a/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentAutoConfiguration.java +++ b/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGraphqlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.graphql.customizer") - && target instanceof GraphqlComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.graphql", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentConverter.java b/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentConverter.java index 6f50f6a970b0..0c799d3d2451 100644 --- a/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentConverter.java +++ b/components-starter/camel-graphql-starter/src/main/java/org/apache/camel/component/graphql/springboot/GraphqlComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.hc.client5.http.classic.HttpClient": return applicationContext.getBean(ref, org.apache.hc.client5.http.classic.HttpClient.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.graphql"); } } \ No newline at end of file diff --git a/components-starter/camel-grok-starter/src/main/java/org/apache/camel/component/grok/springboot/GrokDataFormatAutoConfiguration.java b/components-starter/camel-grok-starter/src/main/java/org/apache/camel/component/grok/springboot/GrokDataFormatAutoConfiguration.java index 44ccade939eb..6f33991b0063 100644 --- a/components-starter/camel-grok-starter/src/main/java/org/apache/camel/component/grok/springboot/GrokDataFormatAutoConfiguration.java +++ b/components-starter/camel-grok-starter/src/main/java/org/apache/camel/component/grok/springboot/GrokDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureGrokDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.grok.customizer") - && target instanceof GrokDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.grok", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/language/groovy/springboot/GroovyLanguageAutoConfiguration.java b/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/language/groovy/springboot/GroovyLanguageAutoConfiguration.java index 220c428c8f7c..ede5867ee490 100644 --- a/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/language/groovy/springboot/GroovyLanguageAutoConfiguration.java +++ b/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/language/groovy/springboot/GroovyLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureGroovyLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.groovy.customizer") - && target instanceof GroovyLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.groovy", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java b/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java index 18de41cb1faf..4174bf290a98 100644 --- a/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java +++ b/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGrpcComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.grpc.customizer") - && target instanceof GrpcComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.grpc", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-gson-starter/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatAutoConfiguration.java b/components-starter/camel-gson-starter/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatAutoConfiguration.java index 4956505a5e1d..eda201b77ab2 100644 --- a/components-starter/camel-gson-starter/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatAutoConfiguration.java +++ b/components-starter/camel-gson-starter/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureGsonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.gson.customizer") - && target instanceof GsonDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.gson", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hashicorp-vault-starter/src/main/java/org/apache/camel/component/hashicorp/vault/springboot/HashicorpVaultComponentAutoConfiguration.java b/components-starter/camel-hashicorp-vault-starter/src/main/java/org/apache/camel/component/hashicorp/vault/springboot/HashicorpVaultComponentAutoConfiguration.java index 1b7caf1b342a..25dbbbb5aac3 100644 --- a/components-starter/camel-hashicorp-vault-starter/src/main/java/org/apache/camel/component/hashicorp/vault/springboot/HashicorpVaultComponentAutoConfiguration.java +++ b/components-starter/camel-hashicorp-vault-starter/src/main/java/org/apache/camel/component/hashicorp/vault/springboot/HashicorpVaultComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHashicorpVaultComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hashicorp-vault.customizer") - && target instanceof HashicorpVaultComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hashicorp-vault", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java index abfd3930d85c..5bd1e322265f 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastAtomicnumberComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-atomicvalue.customizer") - && target instanceof HazelcastAtomicnumberComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-atomicvalue", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConverter.java index 75e8e1e991c9..a9eb8c50f6f4 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/springboot/HazelcastAtomicnumberComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-atomicvalue"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java index 7de2459b00b1..b45375098cdc 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastInstanceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-instance.customizer") - && target instanceof HazelcastInstanceComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-instance", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConverter.java index 048874ba4f22..1b3b09e4eefc 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/instance/springboot/HazelcastInstanceComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-instance"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java index af1b23c671de..1c11dd1afabe 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastListComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-list.customizer") - && target instanceof HazelcastListComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-list", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConverter.java index 4f921318db8a..c8bb7abe243b 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/list/springboot/HazelcastListComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-list"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java index 213fb1e8f022..eeabdc327367 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastMapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-map.customizer") - && target instanceof HazelcastMapComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-map", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConverter.java index 3f376e4421ad..6fa37646f447 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/map/springboot/HazelcastMapComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-map"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java index d5dba7fa4edc..16b6c6e9a422 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastMultimapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-multimap.customizer") - && target instanceof HazelcastMultimapComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-multimap", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConverter.java index 0bc5f9dcdd84..2b8eacc57547 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/multimap/springboot/HazelcastMultimapComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-multimap"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java index a12dbfdc274a..d33b0a1fad2d 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastQueueComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-queue.customizer") - && target instanceof HazelcastQueueComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-queue", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConverter.java index d00c7d987f6a..b330f31cdac2 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/queue/springboot/HazelcastQueueComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-queue"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java index 145faf343aee..414d359cb80a 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastReplicatedmapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-replicatedmap.customizer") - && target instanceof HazelcastReplicatedmapComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-replicatedmap", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentConverter.java index b373b6596c67..37772181fb4a 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/replicatedmap/springboot/HazelcastReplicatedmapComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-replicatedmap"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentAutoConfiguration.java index b71222d6161b..aa3046707e61 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastRingbufferComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-ringbuffer.customizer") - && target instanceof HazelcastRingbufferComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-ringbuffer", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConverter.java index 91a308ae17d1..e7327a25e7cb 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-ringbuffer"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java index 3880f5ad0648..c030fbbca7d3 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastSedaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-seda.customizer") - && target instanceof HazelcastSedaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-seda", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConverter.java index 2c212026eff6..ce0c3325d0c8 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-seda"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java index 16e1f68b1b68..e01e96b06225 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastSetComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-set.customizer") - && target instanceof HazelcastSetComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-set", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConverter.java index 71e42af55002..3e67794822b8 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-set"); } } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java index 5e63c08341b5..c5399fb3b2d7 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHazelcastTopicComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hazelcast-topic.customizer") - && target instanceof HazelcastTopicComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-topic", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConverter.java index 7e4c16febee8..308dd50fe38a 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.hazelcast.core.HazelcastInstance": return applicationContext.getBean(ref, com.hazelcast.core.HazelcastInstance.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hazelcast-topic"); } } \ No newline at end of file diff --git a/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java b/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java index 914e4c2487db..cd84c5b191e5 100644 --- a/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java +++ b/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureHL7DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.hl7.customizer") - && target instanceof HL7DataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.hl7", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConverter.java b/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConverter.java index 50e2ad4aae68..58134c98c941 100644 --- a/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConverter.java +++ b/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "ca.uhn.hl7v2.parser.Parser": return applicationContext.getBean(ref, ca.uhn.hl7v2.parser.Parser.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.hl7"); } } \ No newline at end of file diff --git a/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/Hl7TerserLanguageAutoConfiguration.java b/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/Hl7TerserLanguageAutoConfiguration.java index e3d2e49234c2..d27442f7fd7d 100644 --- a/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/Hl7TerserLanguageAutoConfiguration.java +++ b/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/Hl7TerserLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureHl7TerserLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.hl7terser.customizer") - && target instanceof Hl7TerserLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.hl7terser", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentAutoConfiguration.java b/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentAutoConfiguration.java index 2386f9139824..5e95b5b8386e 100644 --- a/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentAutoConfiguration.java +++ b/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.http.customizer") - && target instanceof HttpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.http", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConverter.java b/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConverter.java index e32c093ce0ed..2e0fc9b26672 100644 --- a/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConverter.java +++ b/components-starter/camel-http-starter/src/main/java/org/apache/camel/component/http/springboot/HttpComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -56,26 +57,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.hc.client5.http.cookie.CookieStore": return applicationContext.getBean(ref, org.apache.hc.client5.http.cookie.CookieStore.class); - case "org.apache.camel.component.http.HttpActivityListener": return applicationContext.getBean(ref, org.apache.camel.component.http.HttpActivityListener.class); - case "org.apache.hc.client5.http.io.HttpClientConnectionManager": return applicationContext.getBean(ref, org.apache.hc.client5.http.io.HttpClientConnectionManager.class); - case "org.apache.camel.http.common.HttpBinding": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpBinding.class); - case "org.apache.camel.component.http.HttpClientConfigurer": return applicationContext.getBean(ref, org.apache.camel.component.http.HttpClientConfigurer.class); - case "org.apache.camel.http.common.HttpConfiguration": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpConfiguration.class); - case "org.apache.hc.core5.http.protocol.HttpContext": return applicationContext.getBean(ref, org.apache.hc.core5.http.protocol.HttpContext.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - case "javax.net.ssl.HostnameVerifier": return applicationContext.getBean(ref, javax.net.ssl.HostnameVerifier.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.http"); } } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-dms-starter/src/main/java/org/apache/camel/component/huaweicloud/dms/springboot/DMSComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-dms-starter/src/main/java/org/apache/camel/component/huaweicloud/dms/springboot/DMSComponentAutoConfiguration.java index 24d7e25f981d..3f5e67941fe2 100644 --- a/components-starter/camel-huaweicloud-dms-starter/src/main/java/org/apache/camel/component/huaweicloud/dms/springboot/DMSComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-dms-starter/src/main/java/org/apache/camel/component/huaweicloud/dms/springboot/DMSComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureDMSComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-dms.customizer") - && target instanceof DMSComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-dms", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-frs-starter/src/main/java/org/apache/camel/component/huaweicloud/frs/springboot/FaceRecognitionComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-frs-starter/src/main/java/org/apache/camel/component/huaweicloud/frs/springboot/FaceRecognitionComponentAutoConfiguration.java index a5354f7114f9..09c2a120e485 100644 --- a/components-starter/camel-huaweicloud-frs-starter/src/main/java/org/apache/camel/component/huaweicloud/frs/springboot/FaceRecognitionComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-frs-starter/src/main/java/org/apache/camel/component/huaweicloud/frs/springboot/FaceRecognitionComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFaceRecognitionComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-frs.customizer") - && target instanceof FaceRecognitionComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-frs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-functiongraph-starter/src/main/java/org/apache/camel/springboot/FunctionGraphComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-functiongraph-starter/src/main/java/org/apache/camel/springboot/FunctionGraphComponentAutoConfiguration.java index 170aca84ac18..e02250e8322b 100644 --- a/components-starter/camel-huaweicloud-functiongraph-starter/src/main/java/org/apache/camel/springboot/FunctionGraphComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-functiongraph-starter/src/main/java/org/apache/camel/springboot/FunctionGraphComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureFunctionGraphComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-functiongraph.customizer") - && target instanceof FunctionGraphComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-functiongraph", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-iam-starter/src/main/java/org/apache/camel/component/huaweicloud/iam/springboot/IAMComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-iam-starter/src/main/java/org/apache/camel/component/huaweicloud/iam/springboot/IAMComponentAutoConfiguration.java index de50f1774817..04dad8206dda 100644 --- a/components-starter/camel-huaweicloud-iam-starter/src/main/java/org/apache/camel/component/huaweicloud/iam/springboot/IAMComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-iam-starter/src/main/java/org/apache/camel/component/huaweicloud/iam/springboot/IAMComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIAMComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-iam.customizer") - && target instanceof IAMComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-iam", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-imagerecognition-starter/src/main/java/org/apache/camel/component/huaweicloud/image/springboot/ImageRecognitionComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-imagerecognition-starter/src/main/java/org/apache/camel/component/huaweicloud/image/springboot/ImageRecognitionComponentAutoConfiguration.java index a1c59d9a9a6e..ed87510396f4 100644 --- a/components-starter/camel-huaweicloud-imagerecognition-starter/src/main/java/org/apache/camel/component/huaweicloud/image/springboot/ImageRecognitionComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-imagerecognition-starter/src/main/java/org/apache/camel/component/huaweicloud/image/springboot/ImageRecognitionComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureImageRecognitionComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-imagerecognition.customizer") - && target instanceof ImageRecognitionComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-imagerecognition", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-obs-starter/src/main/java/org/apache/camel/component/huaweicloud/obs/springboot/OBSComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-obs-starter/src/main/java/org/apache/camel/component/huaweicloud/obs/springboot/OBSComponentAutoConfiguration.java index b00b296d39ad..c6f04388f6ea 100644 --- a/components-starter/camel-huaweicloud-obs-starter/src/main/java/org/apache/camel/component/huaweicloud/obs/springboot/OBSComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-obs-starter/src/main/java/org/apache/camel/component/huaweicloud/obs/springboot/OBSComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOBSComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-obs.customizer") - && target instanceof OBSComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-obs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-huaweicloud-smn-starter/src/main/java/org/apache/camel/component/huaweicloud/smn/springboot/SimpleNotificationComponentAutoConfiguration.java b/components-starter/camel-huaweicloud-smn-starter/src/main/java/org/apache/camel/component/huaweicloud/smn/springboot/SimpleNotificationComponentAutoConfiguration.java index 92ccec219641..a079a8e1c704 100644 --- a/components-starter/camel-huaweicloud-smn-starter/src/main/java/org/apache/camel/component/huaweicloud/smn/springboot/SimpleNotificationComponentAutoConfiguration.java +++ b/components-starter/camel-huaweicloud-smn-starter/src/main/java/org/apache/camel/component/huaweicloud/smn/springboot/SimpleNotificationComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSimpleNotificationComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.hwcloud-smn.customizer") - && target instanceof SimpleNotificationComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-smn", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentAutoConfiguration.java b/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentAutoConfiguration.java index 3e5790870749..a8d853ed6d44 100644 --- a/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIBMCOSComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-cos.customizer") - && target instanceof IBMCOSComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-cos", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentConverter.java b/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentConverter.java index 77f5c0a57826..5424d30d7c8e 100644 --- a/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentConverter.java +++ b/components-starter/camel-ibm-cos-starter/src/main/java/org/apache/camel/component/ibm/cos/springboot/IBMCOSComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.ibm.cos.IBMCOSConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ibm.cos.IBMCOSConfiguration.class); - case "com.ibm.cloud.objectstorage.services.s3.AmazonS3": return applicationContext.getBean(ref, com.ibm.cloud.objectstorage.services.s3.AmazonS3.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ibm-cos"); } } \ No newline at end of file diff --git a/components-starter/camel-ibm-secrets-manager-starter/src/main/java/org/apache/camel/component/ibm/secrets/manager/springboot/IBMSecretsManagerComponentAutoConfiguration.java b/components-starter/camel-ibm-secrets-manager-starter/src/main/java/org/apache/camel/component/ibm/secrets/manager/springboot/IBMSecretsManagerComponentAutoConfiguration.java index 3e1503a10c6e..4a579aa7a36f 100644 --- a/components-starter/camel-ibm-secrets-manager-starter/src/main/java/org/apache/camel/component/ibm/secrets/manager/springboot/IBMSecretsManagerComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-secrets-manager-starter/src/main/java/org/apache/camel/component/ibm/secrets/manager/springboot/IBMSecretsManagerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIBMSecretsManagerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-secrets-manager.customizer") - && target instanceof IBMSecretsManagerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-secrets-manager", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentAutoConfiguration.java b/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentAutoConfiguration.java index 5c8c3dd129e3..d558b7dec298 100644 --- a/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWatsonDiscoveryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-watson-discovery.customizer") - && target instanceof WatsonDiscoveryComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-discovery", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentConverter.java b/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentConverter.java index be8f10588d49..548e1c50df39 100644 --- a/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentConverter.java +++ b/components-starter/camel-ibm-watson-discovery-starter/src/main/java/org/apache/camel/component/ibm/watson/discovery/springboot/WatsonDiscoveryComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.ibm.watson.discovery.WatsonDiscoveryConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ibm.watson.discovery.WatsonDiscoveryConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ibm-watson-discovery"); } } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentAutoConfiguration.java b/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentAutoConfiguration.java index c46ecff06007..60cbf09faa76 100644 --- a/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWatsonLanguageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-watson-language.customizer") - && target instanceof WatsonLanguageComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-language", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentConverter.java b/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentConverter.java index 5f97f154758a..290b00d67f66 100644 --- a/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentConverter.java +++ b/components-starter/camel-ibm-watson-language-starter/src/main/java/org/apache/camel/component/ibm/watson/language/springboot/WatsonLanguageComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.ibm.watson.language.WatsonLanguageConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ibm.watson.language.WatsonLanguageConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ibm-watson-language"); } } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentAutoConfiguration.java b/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentAutoConfiguration.java index 2f2375287ded..16a721e1ebe5 100644 --- a/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWatsonSpeechToTextComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-watson-speech-to-text.customizer") - && target instanceof WatsonSpeechToTextComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-speech-to-text", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentConverter.java b/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentConverter.java index 879972f101d1..408638ef1fab 100644 --- a/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentConverter.java +++ b/components-starter/camel-ibm-watson-speech-to-text-starter/src/main/java/org/apache/camel/component/ibm/watson/stt/springboot/WatsonSpeechToTextComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ibm.watson.stt.WatsonSpeechToTextConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ibm-watson-speech-to-text"); } } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentAutoConfiguration.java b/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentAutoConfiguration.java index 74d3f6f5a5bd..847fc1c3fab4 100644 --- a/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWatsonTextToSpeechComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-watson-text-to-speech.customizer") - && target instanceof WatsonTextToSpeechComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-text-to-speech", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentConverter.java b/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentConverter.java index 7d5a2ca7800a..9fc5e951b2cf 100644 --- a/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentConverter.java +++ b/components-starter/camel-ibm-watson-text-to-speech-starter/src/main/java/org/apache/camel/component/ibm/watson/tts/springboot/WatsonTextToSpeechComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.ibm.watson.tts.WatsonTextToSpeechConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ibm.watson.tts.WatsonTextToSpeechConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ibm-watson-text-to-speech"); } } \ No newline at end of file diff --git a/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentAutoConfiguration.java b/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentAutoConfiguration.java index 1b6036125a8d..b601bc790c60 100644 --- a/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentAutoConfiguration.java +++ b/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWatsonxAiComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ibm-watsonx-ai.customizer") - && target instanceof WatsonxAiComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watsonx-ai", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentConverter.java b/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentConverter.java index 6c081dab25c2..6d6ee176c2c7 100644 --- a/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentConverter.java +++ b/components-starter/camel-ibm-watsonx-ai-starter/src/main/java/org/apache/camel/component/ibm/watsonx/ai/springboot/WatsonxAiComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.ibm.watsonx.ai.WatsonxAiConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ibm.watsonx.ai.WatsonxAiConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ibm-watsonx-ai"); } } \ No newline at end of file diff --git a/components-starter/camel-ical-starter/src/main/java/org/apache/camel/component/ical/springboot/ICalDataFormatAutoConfiguration.java b/components-starter/camel-ical-starter/src/main/java/org/apache/camel/component/ical/springboot/ICalDataFormatAutoConfiguration.java index 89f0806ed138..cd0c691d8f4e 100644 --- a/components-starter/camel-ical-starter/src/main/java/org/apache/camel/component/ical/springboot/ICalDataFormatAutoConfiguration.java +++ b/components-starter/camel-ical-starter/src/main/java/org/apache/camel/component/ical/springboot/ICalDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureICalDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.ical.customizer") - && target instanceof ICalDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.ical", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentAutoConfiguration.java b/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentAutoConfiguration.java index cb328d79f14d..55a9ab248968 100644 --- a/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentAutoConfiguration.java +++ b/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIggyComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.iggy.customizer") - && target instanceof IggyComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.iggy", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentConverter.java b/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentConverter.java index 571223167266..42a4865fb3a2 100644 --- a/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentConverter.java +++ b/components-starter/camel-iggy-starter/src/main/java/org/apache/camel/component/iggy/springboot/IggyComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.iggy.IggyConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.iggy.IggyConfiguration.class); - case "org.apache.iggy.message.Partitioning": return applicationContext.getBean(ref, org.apache.iggy.message.Partitioning.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.iggy"); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentAutoConfiguration.java index 264259a5bcf5..5347a4fe2451 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-cache.customizer") - && target instanceof IgniteCacheComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-cache", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentConverter.java index e8a02bfe749d..b009bf8a7a18 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/cache/springboot/IgniteCacheComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-cache"); } } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentAutoConfiguration.java index 98750d2d35d1..c2d073d799c6 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteComputeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-compute.customizer") - && target instanceof IgniteComputeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-compute", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentConverter.java index 9f67b6801f40..2bbb0151eb0e 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/compute/springboot/IgniteComputeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-compute"); } } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentAutoConfiguration.java index 1193c3fed4b7..015135fdc02f 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteEventsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-events.customizer") - && target instanceof IgniteEventsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-events", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentConverter.java index 0d99e5c596fa..f1c88c644f01 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/events/springboot/IgniteEventsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-events"); } } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentAutoConfiguration.java index 69cf5e60586e..d36e16ac2b87 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteIdGenComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-idgen.customizer") - && target instanceof IgniteIdGenComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-idgen", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentConverter.java index d938a9ad5e32..012e6f3ff35e 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/idgen/springboot/IgniteIdGenComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-idgen"); } } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentAutoConfiguration.java index 22f062f2b4b9..2954456e8108 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteMessagingComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-messaging.customizer") - && target instanceof IgniteMessagingComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-messaging", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentConverter.java index b269956eebe4..7c1946f7d6a5 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/messaging/springboot/IgniteMessagingComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-messaging"); } } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentAutoConfiguration.java index 4efa1c769f33..f6315585e243 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteQueueComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-queue.customizer") - && target instanceof IgniteQueueComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-queue", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentConverter.java index 04b5a805a13e..65ceef1cee50 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/queue/springboot/IgniteQueueComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-queue"); } } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentAutoConfiguration.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentAutoConfiguration.java index 25ef8ebb8f83..894f37f29a17 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentAutoConfiguration.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureIgniteSetComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ignite-set.customizer") - && target instanceof IgniteSetComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-set", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentConverter.java b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentConverter.java index ae2d26678141..5bc3937ff3d2 100644 --- a/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentConverter.java +++ b/components-starter/camel-ignite-starter/src/main/java/org/apache/camel/component/ignite/set/springboot/IgniteSetComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ignite.Ignite": return applicationContext.getBean(ref, org.apache.ignite.Ignite.class); - case "org.apache.ignite.configuration.IgniteConfiguration": return applicationContext.getBean(ref, org.apache.ignite.configuration.IgniteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ignite-set"); } } \ No newline at end of file diff --git a/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentAutoConfiguration.java b/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentAutoConfiguration.java index 8f870703c53b..abf598f1d1ed 100644 --- a/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentAutoConfiguration.java +++ b/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureInfinispanEmbeddedComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.infinispan-embedded.customizer") - && target instanceof InfinispanEmbeddedComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.infinispan-embedded", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentConverter.java b/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentConverter.java index 1ef31865137e..e2877619d9d9 100644 --- a/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentConverter.java +++ b/components-starter/camel-infinispan-embedded-starter/src/main/java/org/apache/camel/component/infinispan/embedded/springboot/InfinispanEmbeddedComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration.class); - case "org.apache.camel.component.infinispan.InfinispanQueryBuilder": return applicationContext.getBean(ref, org.apache.camel.component.infinispan.InfinispanQueryBuilder.class); - case "org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedCustomListener": return applicationContext.getBean(ref, org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedCustomListener.class); - case "org.infinispan.manager.EmbeddedCacheManager": return applicationContext.getBean(ref, org.infinispan.manager.EmbeddedCacheManager.class); - case "org.infinispan.configuration.cache.Configuration": return applicationContext.getBean(ref, org.infinispan.configuration.cache.Configuration.class); - case "java.util.function.BiFunction": return applicationContext.getBean(ref, java.util.function.BiFunction.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.infinispan-embedded"); } } \ No newline at end of file diff --git a/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentAutoConfiguration.java b/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentAutoConfiguration.java index ccbad7595259..d72f14d06b05 100644 --- a/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentAutoConfiguration.java +++ b/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureInfinispanRemoteComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.infinispan.customizer") - && target instanceof InfinispanRemoteComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.infinispan", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentConverter.java b/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentConverter.java index 6bf5c538c9d8..342f67660830 100644 --- a/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentConverter.java +++ b/components-starter/camel-infinispan-starter/src/main/java/org/apache/camel/component/infinispan/remote/springboot/InfinispanRemoteComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration.class); - case "org.apache.camel.component.infinispan.InfinispanQueryBuilder": return applicationContext.getBean(ref, org.apache.camel.component.infinispan.InfinispanQueryBuilder.class); - case "org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener": return applicationContext.getBean(ref, org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener.class); - case "org.infinispan.client.hotrod.RemoteCacheManager": return applicationContext.getBean(ref, org.infinispan.client.hotrod.RemoteCacheManager.class); - case "org.infinispan.client.hotrod.configuration.Configuration": return applicationContext.getBean(ref, org.infinispan.client.hotrod.configuration.Configuration.class); - case "java.util.function.BiFunction": return applicationContext.getBean(ref, java.util.function.BiFunction.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.infinispan"); } } \ No newline at end of file diff --git a/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentAutoConfiguration.java b/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentAutoConfiguration.java index f93b00b60161..e1923374d259 100644 --- a/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentAutoConfiguration.java +++ b/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureInfluxDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.influxdb.customizer") - && target instanceof InfluxDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.influxdb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentConverter.java b/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentConverter.java index f24b8c0856ba..d90bc6bbebf0 100644 --- a/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentConverter.java +++ b/components-starter/camel-influxdb-starter/src/main/java/org/apache/camel/component/influxdb/springboot/InfluxDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.influxdb.InfluxDB": return applicationContext.getBean(ref, org.influxdb.InfluxDB.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.influxdb"); } } \ No newline at end of file diff --git a/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentAutoConfiguration.java b/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentAutoConfiguration.java index 8ba753ea7e22..903cf05d2286 100644 --- a/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentAutoConfiguration.java +++ b/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureInfluxDb2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.influxdb2.customizer") - && target instanceof InfluxDb2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.influxdb2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentConverter.java b/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentConverter.java index 74f81ec63feb..6003f5e7b566 100644 --- a/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentConverter.java +++ b/components-starter/camel-influxdb2-starter/src/main/java/org/apache/camel/component/influxdb2/springboot/InfluxDb2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.influxdb.client.InfluxDBClient": return applicationContext.getBean(ref, com.influxdb.client.InfluxDBClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.influxdb2"); } } \ No newline at end of file diff --git a/components-starter/camel-iso8583-starter/src/main/java/org/apache/camel/dataformat/iso8583/springboot/Iso8583DataFormatAutoConfiguration.java b/components-starter/camel-iso8583-starter/src/main/java/org/apache/camel/dataformat/iso8583/springboot/Iso8583DataFormatAutoConfiguration.java index a47bc9d167d6..59991c97fb82 100644 --- a/components-starter/camel-iso8583-starter/src/main/java/org/apache/camel/dataformat/iso8583/springboot/Iso8583DataFormatAutoConfiguration.java +++ b/components-starter/camel-iso8583-starter/src/main/java/org/apache/camel/dataformat/iso8583/springboot/Iso8583DataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureIso8583DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.iso8583.customizer") - && target instanceof Iso8583DataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.iso8583", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jackson-avro-starter/src/main/java/org/apache/camel/component/jackson/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java b/components-starter/camel-jackson-avro-starter/src/main/java/org/apache/camel/component/jackson/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java index 20a67d1f680c..16d95a02c92a 100644 --- a/components-starter/camel-jackson-avro-starter/src/main/java/org/apache/camel/component/jackson/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson-avro-starter/src/main/java/org/apache/camel/component/jackson/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJacksonAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.avro-jackson.customizer") - && target instanceof JacksonAvroDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.avro-jackson", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jackson-protobuf-starter/src/main/java/org/apache/camel/component/jackson/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java b/components-starter/camel-jackson-protobuf-starter/src/main/java/org/apache/camel/component/jackson/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java index aaf0b0e3af94..1a963c9fd83d 100644 --- a/components-starter/camel-jackson-protobuf-starter/src/main/java/org/apache/camel/component/jackson/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson-protobuf-starter/src/main/java/org/apache/camel/component/jackson/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJacksonProtobufDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.protobuf-jackson.customizer") - && target instanceof JacksonProtobufDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.protobuf-jackson", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatAutoConfiguration.java b/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatAutoConfiguration.java index 6ec92334cd1a..768c398c7042 100644 --- a/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJacksonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.jackson.customizer") - && target instanceof JacksonDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.jackson", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConverter.java b/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConverter.java index 1fe3878d51b8..c91bd96daf31 100644 --- a/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConverter.java +++ b/components-starter/camel-jackson-starter/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.jackson.SchemaResolver": return applicationContext.getBean(ref, org.apache.camel.component.jackson.SchemaResolver.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.jackson"); } } \ No newline at end of file diff --git a/components-starter/camel-jacksonxml-starter/src/main/java/org/apache/camel/component/jacksonxml/springboot/JacksonXMLDataFormatAutoConfiguration.java b/components-starter/camel-jacksonxml-starter/src/main/java/org/apache/camel/component/jacksonxml/springboot/JacksonXMLDataFormatAutoConfiguration.java index 76a343598e8b..305025f33d41 100644 --- a/components-starter/camel-jacksonxml-starter/src/main/java/org/apache/camel/component/jacksonxml/springboot/JacksonXMLDataFormatAutoConfiguration.java +++ b/components-starter/camel-jacksonxml-starter/src/main/java/org/apache/camel/component/jacksonxml/springboot/JacksonXMLDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJacksonXMLDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.jackson-xml.customizer") - && target instanceof JacksonXMLDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.jackson-xml", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-javascript-starter/src/main/java/org/apache/camel/language/js/springboot/JavaScriptLanguageAutoConfiguration.java b/components-starter/camel-javascript-starter/src/main/java/org/apache/camel/language/js/springboot/JavaScriptLanguageAutoConfiguration.java index bdb9543a479b..1b4655ca4224 100644 --- a/components-starter/camel-javascript-starter/src/main/java/org/apache/camel/language/js/springboot/JavaScriptLanguageAutoConfiguration.java +++ b/components-starter/camel-javascript-starter/src/main/java/org/apache/camel/language/js/springboot/JavaScriptLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureJavaScriptLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.js.customizer") - && target instanceof JavaScriptLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.js", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java b/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java index 9149f9949515..43ee11f0c383 100644 --- a/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java +++ b/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJaxbDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.jaxb.customizer") - && target instanceof JaxbDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.jaxb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java b/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java index 3ef7b72be6d3..224439b72b2d 100644 --- a/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java +++ b/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jcache.customizer") - && target instanceof JCacheComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jcache", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConverter.java b/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConverter.java index a1a5a8e2fc71..dec605a63cf0 100644 --- a/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConverter.java +++ b/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.cache.configuration.Configuration": return applicationContext.getBean(ref, javax.cache.configuration.Configuration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jcache"); } } \ No newline at end of file diff --git a/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java b/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java index 27c2efa1a58f..a76d5fbc722a 100644 --- a/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java +++ b/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJcrComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jcr.customizer") - && target instanceof JcrComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jcr", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java b/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java index f34ed8b93a59..4662ef7f46a7 100644 --- a/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java +++ b/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJdbcComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jdbc.customizer") - && target instanceof JdbcComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jdbc", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConverter.java b/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConverter.java index 526cac1aac66..78873e20cd49 100644 --- a/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConverter.java +++ b/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.sql.DataSource": return applicationContext.getBean(ref, javax.sql.DataSource.class); - case "org.apache.camel.component.jdbc.ConnectionStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jdbc.ConnectionStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jdbc"); } } \ No newline at end of file diff --git a/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentAutoConfiguration12.java b/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentAutoConfiguration12.java index 36c868750715..5017b6ba6eb8 100644 --- a/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentAutoConfiguration12.java +++ b/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentAutoConfiguration12.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJettyHttpComponent12() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jetty.customizer") - && target instanceof JettyHttpComponent12; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jetty", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentConverter12.java b/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentConverter12.java index aaa1d3176a78..5f2cf960c4c0 100644 --- a/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentConverter12.java +++ b/components-starter/camel-jetty-starter/src/main/java/org/apache/camel/component/jetty12/springboot/JettyHttpComponentConverter12.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -55,25 +56,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.eclipse.jetty.util.thread.ThreadPool": return applicationContext.getBean(ref, org.eclipse.jetty.util.thread.ThreadPool.class); - case "org.eclipse.jetty.server.handler.ErrorHandler": return applicationContext.getBean(ref, org.eclipse.jetty.server.handler.ErrorHandler.class); - case "org.apache.camel.http.common.HttpBinding": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpBinding.class); - case "org.apache.camel.http.common.HttpConfiguration": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpConfiguration.class); - case "org.eclipse.jetty.jmx.MBeanContainer": return applicationContext.getBean(ref, org.eclipse.jetty.jmx.MBeanContainer.class); - case "org.eclipse.jetty.server.RequestLog": return applicationContext.getBean(ref, org.eclipse.jetty.server.RequestLog.class); - case "org.eclipse.jetty.server.SecureRequestCustomizer": return applicationContext.getBean(ref, org.eclipse.jetty.server.SecureRequestCustomizer.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jetty"); } } \ No newline at end of file diff --git a/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentAutoConfiguration.java b/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentAutoConfiguration.java index a7f8b1e1e82e..df21ae1957fd 100644 --- a/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentAutoConfiguration.java +++ b/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJGroupsRaftComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jgroups-raft.customizer") - && target instanceof JGroupsRaftComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jgroups-raft", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentConverter.java b/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentConverter.java index a7b2bd84148e..9581b1f99aa8 100644 --- a/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentConverter.java +++ b/components-starter/camel-jgroups-raft-starter/src/main/java/org/apache/camel/component/jgroups/raft/springboot/JGroupsRaftComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.jgroups.raft.RaftHandle": return applicationContext.getBean(ref, org.jgroups.raft.RaftHandle.class); - case "org.jgroups.raft.StateMachine": return applicationContext.getBean(ref, org.jgroups.raft.StateMachine.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jgroups-raft"); } } \ No newline at end of file diff --git a/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java b/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java index 0754ea0b6c9d..b498f7bb4797 100644 --- a/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java +++ b/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJGroupsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jgroups.customizer") - && target instanceof JGroupsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jgroups", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConverter.java b/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConverter.java index c2a75de098d8..abc09c471e1a 100644 --- a/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConverter.java +++ b/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.jgroups.JChannel": return applicationContext.getBean(ref, org.jgroups.JChannel.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jgroups"); } } \ No newline at end of file diff --git a/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentAutoConfiguration.java b/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentAutoConfiguration.java index 0dbf5bca22c7..952d706f0ca1 100644 --- a/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentAutoConfiguration.java +++ b/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJiraComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jira.customizer") - && target instanceof JiraComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jira", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConverter.java b/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConverter.java index fcc1b7cc4038..35dc642e2061 100644 --- a/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConverter.java +++ b/components-starter/camel-jira-starter/src/main/java/org/apache/camel/component/jira/springboot/JiraComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.jira.JiraConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.jira.JiraConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jira"); } } \ No newline at end of file diff --git a/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentAutoConfiguration.java b/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentAutoConfiguration.java index 3b5f30e58fc0..e0924eec530d 100644 --- a/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentAutoConfiguration.java +++ b/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJmsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jms.customizer") - && target instanceof JmsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jms", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConverter.java b/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConverter.java index f66074bbf251..4559e4635d55 100644 --- a/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConverter.java +++ b/components-starter/camel-jms-starter/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -59,29 +60,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.jms.ConnectionFactory": return applicationContext.getBean(ref, jakarta.jms.ConnectionFactory.class); - case "org.springframework.core.task.TaskExecutor": return applicationContext.getBean(ref, org.springframework.core.task.TaskExecutor.class); - case "org.apache.camel.component.jms.JmsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.jms.JmsConfiguration.class); - case "org.springframework.jms.support.destination.DestinationResolver": return applicationContext.getBean(ref, org.springframework.jms.support.destination.DestinationResolver.class); - case "org.springframework.util.ErrorHandler": return applicationContext.getBean(ref, org.springframework.util.ErrorHandler.class); - case "jakarta.jms.ExceptionListener": return applicationContext.getBean(ref, jakarta.jms.ExceptionListener.class); - case "org.springframework.jms.support.converter.MessageConverter": return applicationContext.getBean(ref, org.springframework.jms.support.converter.MessageConverter.class); - case "org.apache.camel.component.jms.MessageCreatedStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageCreatedStrategy.class); - case "org.apache.camel.component.jms.MessageListenerContainerFactory": return applicationContext.getBean(ref, org.apache.camel.component.jms.MessageListenerContainerFactory.class); - case "org.apache.camel.component.jms.QueueBrowseStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jms.QueueBrowseStrategy.class); - case "org.apache.camel.component.jms.TemporaryQueueResolver": return applicationContext.getBean(ref, org.apache.camel.component.jms.TemporaryQueueResolver.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.springframework.transaction.PlatformTransactionManager": return applicationContext.getBean(ref, org.springframework.transaction.PlatformTransactionManager.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jms"); } } \ No newline at end of file diff --git a/components-starter/camel-jmx-starter/src/main/java/org/apache/camel/component/jmx/springboot/JMXComponentAutoConfiguration.java b/components-starter/camel-jmx-starter/src/main/java/org/apache/camel/component/jmx/springboot/JMXComponentAutoConfiguration.java index 96b67fefe61f..101a431b86d9 100644 --- a/components-starter/camel-jmx-starter/src/main/java/org/apache/camel/component/jmx/springboot/JMXComponentAutoConfiguration.java +++ b/components-starter/camel-jmx-starter/src/main/java/org/apache/camel/component/jmx/springboot/JMXComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJMXComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jmx.customizer") - && target instanceof JMXComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jmx", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentAutoConfiguration.java b/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentAutoConfiguration.java index 343aada4c8a1..bf68b7ebfc7d 100644 --- a/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentAutoConfiguration.java +++ b/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJoltComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jolt.customizer") - && target instanceof JoltComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jolt", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConverter.java b/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConverter.java index b230814ab309..7b8ee88558be 100644 --- a/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConverter.java +++ b/components-starter/camel-jolt-starter/src/main/java/org/apache/camel/component/jolt/springboot/JoltComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.bazaarvoice.jolt.Transform": return applicationContext.getBean(ref, com.bazaarvoice.jolt.Transform.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jolt"); } } \ No newline at end of file diff --git a/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentAutoConfiguration.java b/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentAutoConfiguration.java index a1d9cad95b90..2263256a7e11 100644 --- a/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentAutoConfiguration.java +++ b/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJooqComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jooq.customizer") - && target instanceof JooqComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jooq", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentConverter.java b/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentConverter.java index 7f60f7249d05..f5ad7ccb2431 100644 --- a/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentConverter.java +++ b/components-starter/camel-jooq-starter/src/main/java/org/apache/camel/component/jooq/springboot/JooqComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.jooq.JooqConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.jooq.JooqConfiguration.class); - case "org.jooq.Configuration": return applicationContext.getBean(ref, org.jooq.Configuration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jooq"); } } \ No newline at end of file diff --git a/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JavaLanguageAutoConfiguration.java b/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JavaLanguageAutoConfiguration.java index 7b09425643c1..3113fbf85913 100644 --- a/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JavaLanguageAutoConfiguration.java +++ b/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JavaLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureJavaLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.java.customizer") - && target instanceof JavaLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.java", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JoorLanguageAutoConfiguration.java b/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JoorLanguageAutoConfiguration.java index ce0c2016072d..db9d911a0b30 100644 --- a/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JoorLanguageAutoConfiguration.java +++ b/components-starter/camel-joor-starter/src/main/java/org/apache/camel/language/joor/springboot/JoorLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureJoorLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.joor.customizer") - && target instanceof JoorLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.joor", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentAutoConfiguration.java b/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentAutoConfiguration.java index 2aac0516b122..e11c7e09956b 100644 --- a/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentAutoConfiguration.java +++ b/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJpaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jpa.customizer") - && target instanceof JpaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jpa", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentConverter.java b/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentConverter.java index 66a2fc34e1ec..546270c43845 100644 --- a/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentConverter.java +++ b/components-starter/camel-jpa-starter/src/main/java/org/apache/camel/component/jpa/springboot/JpaComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.persistence.EntityManagerFactory": return applicationContext.getBean(ref, jakarta.persistence.EntityManagerFactory.class); - case "org.apache.camel.component.jpa.TransactionStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jpa.TransactionStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jpa"); } } \ No newline at end of file diff --git a/components-starter/camel-jq-starter/src/main/java/org/apache/camel/language/jq/springboot/JqLanguageAutoConfiguration.java b/components-starter/camel-jq-starter/src/main/java/org/apache/camel/language/jq/springboot/JqLanguageAutoConfiguration.java index 6c52d62fbb78..feb6ee89c3ed 100644 --- a/components-starter/camel-jq-starter/src/main/java/org/apache/camel/language/jq/springboot/JqLanguageAutoConfiguration.java +++ b/components-starter/camel-jq-starter/src/main/java/org/apache/camel/language/jq/springboot/JqLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureJqLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.jq.customizer") - && target instanceof JqLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.jq", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jsch-starter/src/main/java/org/apache/camel/component/scp/springboot/ScpComponentAutoConfiguration.java b/components-starter/camel-jsch-starter/src/main/java/org/apache/camel/component/scp/springboot/ScpComponentAutoConfiguration.java index e3cede46fc2a..5d2be5afc6d6 100644 --- a/components-starter/camel-jsch-starter/src/main/java/org/apache/camel/component/scp/springboot/ScpComponentAutoConfiguration.java +++ b/components-starter/camel-jsch-starter/src/main/java/org/apache/camel/component/scp/springboot/ScpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureScpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.scp.customizer") - && target instanceof ScpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.scp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentAutoConfiguration.java b/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentAutoConfiguration.java index c41e976b367e..f2e3ad486157 100644 --- a/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentAutoConfiguration.java +++ b/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJsltComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jslt.customizer") - && target instanceof JsltComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jslt", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentConverter.java b/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentConverter.java index 005539e3b8fe..da31a681329b 100644 --- a/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentConverter.java +++ b/components-starter/camel-jslt-starter/src/main/java/org/apache/camel/component/jslt/springboot/JsltComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.schibsted.spt.data.jslt.filters.JsonFilter": return applicationContext.getBean(ref, com.schibsted.spt.data.jslt.filters.JsonFilter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jslt"); } } \ No newline at end of file diff --git a/components-starter/camel-json-validator-starter/src/main/java/org/apache/camel/component/jsonvalidator/springboot/JsonValidatorComponentAutoConfiguration.java b/components-starter/camel-json-validator-starter/src/main/java/org/apache/camel/component/jsonvalidator/springboot/JsonValidatorComponentAutoConfiguration.java index 7fa8da7e9720..0de0e29de42f 100644 --- a/components-starter/camel-json-validator-starter/src/main/java/org/apache/camel/component/jsonvalidator/springboot/JsonValidatorComponentAutoConfiguration.java +++ b/components-starter/camel-json-validator-starter/src/main/java/org/apache/camel/component/jsonvalidator/springboot/JsonValidatorComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJsonValidatorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.json-validator.customizer") - && target instanceof JsonValidatorComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.json-validator", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jsonapi-starter/src/main/java/org/apache/camel/component/jsonapi/springboot/JsonApiDataFormatAutoConfiguration.java b/components-starter/camel-jsonapi-starter/src/main/java/org/apache/camel/component/jsonapi/springboot/JsonApiDataFormatAutoConfiguration.java index 4c7506df01f9..533642d32808 100644 --- a/components-starter/camel-jsonapi-starter/src/main/java/org/apache/camel/component/jsonapi/springboot/JsonApiDataFormatAutoConfiguration.java +++ b/components-starter/camel-jsonapi-starter/src/main/java/org/apache/camel/component/jsonapi/springboot/JsonApiDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJsonApiDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.json-api.customizer") - && target instanceof JsonApiDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.json-api", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentAutoConfiguration.java b/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentAutoConfiguration.java index 97d97eaeb038..3db995abf295 100644 --- a/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentAutoConfiguration.java +++ b/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJsonataComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jsonata.customizer") - && target instanceof JsonataComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jsonata", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentConverter.java b/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentConverter.java index 7c47e81177e2..092e5f77c2dc 100644 --- a/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentConverter.java +++ b/components-starter/camel-jsonata-starter/src/main/java/org/apache/camel/component/jsonata/springboot/JsonataComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.jsonata.JsonataFrameBinding": return applicationContext.getBean(ref, org.apache.camel.component.jsonata.JsonataFrameBinding.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jsonata"); } } \ No newline at end of file diff --git a/components-starter/camel-jsonb-starter/src/main/java/org/apache/camel/component/jsonb/springboot/JsonbDataFormatAutoConfiguration.java b/components-starter/camel-jsonb-starter/src/main/java/org/apache/camel/component/jsonb/springboot/JsonbDataFormatAutoConfiguration.java index 1152aa0bc4bb..149709fde916 100644 --- a/components-starter/camel-jsonb-starter/src/main/java/org/apache/camel/component/jsonb/springboot/JsonbDataFormatAutoConfiguration.java +++ b/components-starter/camel-jsonb-starter/src/main/java/org/apache/camel/component/jsonb/springboot/JsonbDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureJsonbDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.jsonb.customizer") - && target instanceof JsonbDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.jsonb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jsonpath-starter/src/main/java/org/apache/camel/jsonpath/springboot/JsonPathLanguageAutoConfiguration.java b/components-starter/camel-jsonpath-starter/src/main/java/org/apache/camel/jsonpath/springboot/JsonPathLanguageAutoConfiguration.java index b13e92e88bb3..d817dff680a3 100644 --- a/components-starter/camel-jsonpath-starter/src/main/java/org/apache/camel/jsonpath/springboot/JsonPathLanguageAutoConfiguration.java +++ b/components-starter/camel-jsonpath-starter/src/main/java/org/apache/camel/jsonpath/springboot/JsonPathLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureJsonPathLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.jsonpath.customizer") - && target instanceof JsonPathLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.jsonpath", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentAutoConfiguration.java b/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentAutoConfiguration.java index eab4a1b0b669..bab904f1694e 100644 --- a/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentAutoConfiguration.java +++ b/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJt400Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jt400.customizer") - && target instanceof Jt400Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jt400", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentConverter.java b/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentConverter.java index aec1a6c6ff60..3fe3bcab4155 100644 --- a/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentConverter.java +++ b/components-starter/camel-jt400-starter/src/main/java/org/apache/camel/component/jt400/springboot/Jt400ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.ibm.as400.access.AS400ConnectionPool": return applicationContext.getBean(ref, com.ibm.as400.access.AS400ConnectionPool.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.jt400"); } } \ No newline at end of file diff --git a/components-starter/camel-jte-starter/src/main/java/org/apache/camel/component/jte/springboot/JteComponentAutoConfiguration.java b/components-starter/camel-jte-starter/src/main/java/org/apache/camel/component/jte/springboot/JteComponentAutoConfiguration.java index f7ec04a92b20..f4d75b2f34d4 100644 --- a/components-starter/camel-jte-starter/src/main/java/org/apache/camel/component/jte/springboot/JteComponentAutoConfiguration.java +++ b/components-starter/camel-jte-starter/src/main/java/org/apache/camel/component/jte/springboot/JteComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureJteComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.jte.customizer") - && target instanceof JteComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jte", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentAutoConfiguration.java b/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentAutoConfiguration.java index afaece99d9a7..3c365ccfb49a 100644 --- a/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentAutoConfiguration.java +++ b/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKafkaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kafka.customizer") - && target instanceof KafkaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kafka", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentConverter.java b/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentConverter.java index 9184b75c75ca..713a61a20467 100644 --- a/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentConverter.java +++ b/components-starter/camel-kafka-starter/src/main/java/org/apache/camel/component/kafka/springboot/KafkaComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -56,26 +57,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.kafka.KafkaConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.kafka.KafkaConfiguration.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.component.kafka.serde.KafkaHeaderDeserializer": return applicationContext.getBean(ref, org.apache.camel.component.kafka.serde.KafkaHeaderDeserializer.class); - case "org.apache.camel.spi.StateRepository": return applicationContext.getBean(ref, org.apache.camel.spi.StateRepository.class); - case "org.apache.camel.component.kafka.consumer.KafkaManualCommitFactory": return applicationContext.getBean(ref, org.apache.camel.component.kafka.consumer.KafkaManualCommitFactory.class); - case "org.apache.camel.component.kafka.PollExceptionStrategy": return applicationContext.getBean(ref, org.apache.camel.component.kafka.PollExceptionStrategy.class); - case "org.apache.camel.component.kafka.serde.KafkaHeaderSerializer": return applicationContext.getBean(ref, org.apache.camel.component.kafka.serde.KafkaHeaderSerializer.class); - case "java.util.concurrent.ExecutorService": return applicationContext.getBean(ref, java.util.concurrent.ExecutorService.class); - case "org.apache.camel.component.kafka.KafkaClientFactory": return applicationContext.getBean(ref, org.apache.camel.component.kafka.KafkaClientFactory.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kafka"); } } \ No newline at end of file diff --git a/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentAutoConfiguration.java b/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentAutoConfiguration.java index 1e978ff9f13f..157502c74490 100644 --- a/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentAutoConfiguration.java +++ b/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKameletComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kamelet.customizer") - && target instanceof KameletComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kamelet", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentConverter.java b/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentConverter.java index 134aa94739c6..37c1bb414765 100644 --- a/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentConverter.java +++ b/components-starter/camel-kamelet-starter/src/main/java/org/apache/camel/component/kamelet/springboot/KameletComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.RouteTemplateLoaderListener": return applicationContext.getBean(ref, org.apache.camel.spi.RouteTemplateLoaderListener.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kamelet"); } } \ No newline at end of file diff --git a/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentAutoConfiguration.java b/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentAutoConfiguration.java index d51f8f968e03..221131fe2973 100644 --- a/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentAutoConfiguration.java +++ b/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKeycloakComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.keycloak.customizer") - && target instanceof KeycloakComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.keycloak", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentConverter.java b/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentConverter.java index 548498c4b4d7..91d8b22e2b4b 100644 --- a/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentConverter.java +++ b/components-starter/camel-keycloak-starter/src/main/java/org/apache/camel/component/keycloak/springboot/KeycloakComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.keycloak.KeycloakConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.keycloak.KeycloakConfiguration.class); - case "org.keycloak.admin.client.Keycloak": return applicationContext.getBean(ref, org.keycloak.admin.client.Keycloak.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.keycloak"); } } \ No newline at end of file diff --git a/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentAutoConfiguration.java b/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentAutoConfiguration.java index ebff79d1ce51..4bc20e48f127 100644 --- a/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentAutoConfiguration.java +++ b/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKnativeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.knative.customizer") - && target instanceof KnativeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.knative", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentConverter.java b/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentConverter.java index 268570ec1043..d12c00b23332 100644 --- a/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentConverter.java +++ b/components-starter/camel-knative-starter/src/main/java/org/apache/camel/component/knative/springboot/KnativeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.knative.KnativeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.knative.KnativeConfiguration.class); - case "org.apache.camel.component.knative.spi.KnativeConsumerFactory": return applicationContext.getBean(ref, org.apache.camel.component.knative.spi.KnativeConsumerFactory.class); - case "org.apache.camel.component.knative.spi.KnativeEnvironment": return applicationContext.getBean(ref, org.apache.camel.component.knative.spi.KnativeEnvironment.class); - case "org.apache.camel.component.knative.spi.KnativeProducerFactory": return applicationContext.getBean(ref, org.apache.camel.component.knative.spi.KnativeProducerFactory.class); - case "org.apache.camel.component.knative.spi.KnativeSinkBinding": return applicationContext.getBean(ref, org.apache.camel.component.knative.spi.KnativeSinkBinding.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.knative"); } } \ No newline at end of file diff --git a/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentAutoConfiguration.java b/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentAutoConfiguration.java index 793bbbefd42e..687a3f1ce614 100644 --- a/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentAutoConfiguration.java +++ b/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKServeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kserve.customizer") - && target instanceof KServeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kserve", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentConverter.java b/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentConverter.java index 2f3fc74235d1..779dd2e910d6 100644 --- a/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentConverter.java +++ b/components-starter/camel-kserve-starter/src/main/java/org/apache/camel/component/kserve/springboot/KServeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.kserve.KServeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.kserve.KServeConfiguration.class); - case "io.grpc.ChannelCredentials": return applicationContext.getBean(ref, io.grpc.ChannelCredentials.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kserve"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentAutoConfiguration.java index f9819ec5f6e3..4396a3e19399 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesConfigMapsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-config-maps.customizer") - && target instanceof KubernetesConfigMapsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-config-maps", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentConverter.java index 62793d49b8f5..33641afc9474 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/config_maps/springboot/KubernetesConfigMapsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-config-maps"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentAutoConfiguration.java index 288cf6e5584f..7659c6849017 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesCronJobComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-cronjob.customizer") - && target instanceof KubernetesCronJobComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-cronjob", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentConverter.java index 82f08a3ddbed..052f127500ac 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/cronjob/springboot/KubernetesCronJobComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-cronjob"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentAutoConfiguration.java index 1bdb15b1eedd..5efebe2bb984 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesCustomResourcesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-custom-resources.customizer") - && target instanceof KubernetesCustomResourcesComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-custom-resources", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentConverter.java index 82b0affce4da..28298259a4c6 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/customresources/springboot/KubernetesCustomResourcesComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-custom-resources"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentAutoConfiguration.java index e531b2b412d9..173990aab4f2 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesDeploymentsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-deployments.customizer") - && target instanceof KubernetesDeploymentsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-deployments", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentConverter.java index c7194f9b8bed..4de69eff183a 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/deployments/springboot/KubernetesDeploymentsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-deployments"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentAutoConfiguration.java index 4fce97cca563..c61fa9b206dc 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesEventsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-events.customizer") - && target instanceof KubernetesEventsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-events", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentConverter.java index 44cddd876f82..aa22cd715f86 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/events/springboot/KubernetesEventsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-events"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentAutoConfiguration.java index 17b91fe3d9e6..488df927f0c0 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesHPAComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-hpa.customizer") - && target instanceof KubernetesHPAComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-hpa", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentConverter.java index 2f9a9eed0821..afbf44acb763 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/hpa/springboot/KubernetesHPAComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-hpa"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentAutoConfiguration.java index d2a5e098420f..781f8529ff12 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesJobComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-job.customizer") - && target instanceof KubernetesJobComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-job", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentConverter.java index 09a4b7967d57..4c0206e0d43d 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/job/springboot/KubernetesJobComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-job"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentAutoConfiguration.java index 129fd924c9db..009d3f25a9a2 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesNamespacesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-namespaces.customizer") - && target instanceof KubernetesNamespacesComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-namespaces", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentConverter.java index 223e4b0304b2..d0e4e5cd087e 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/namespaces/springboot/KubernetesNamespacesComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-namespaces"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentAutoConfiguration.java index 7aea23fdb082..d7c297d23d41 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesNodesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-nodes.customizer") - && target instanceof KubernetesNodesComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-nodes", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentConverter.java index b90133113ea4..2ec62916451d 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/nodes/springboot/KubernetesNodesComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-nodes"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentAutoConfiguration.java index 4be97245b9c8..baca6d05d6f0 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesPersistentVolumesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-persistent-volumes.customizer") - && target instanceof KubernetesPersistentVolumesComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-persistent-volumes", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentConverter.java index 487bf7959d86..d7cb57768f1f 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes/springboot/KubernetesPersistentVolumesComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-persistent-volumes"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentAutoConfiguration.java index b3f18702c9fe..ede5e5f976fb 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesPersistentVolumesClaimsComponent() return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-persistent-volumes-claims.customizer") - && target instanceof KubernetesPersistentVolumesClaimsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-persistent-volumes-claims", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentConverter.java index d9972bc970e3..e2f2e2c2d855 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/persistent_volumes_claims/springboot/KubernetesPersistentVolumesClaimsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-persistent-volumes-claims"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentAutoConfiguration.java index 8a20a3dd3610..be7587c662da 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesPodsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-pods.customizer") - && target instanceof KubernetesPodsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-pods", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentConverter.java index b1c7624f07fe..8d8422870f97 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/pods/springboot/KubernetesPodsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-pods"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentAutoConfiguration.java index 2894022f5f60..53359153a2c1 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesReplicationControllersComponent() return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-replication-controllers.customizer") - && target instanceof KubernetesReplicationControllersComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-replication-controllers", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentConverter.java index a1c805a7fc11..a7cafd4a78e7 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/replication_controllers/springboot/KubernetesReplicationControllersComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-replication-controllers"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentAutoConfiguration.java index 50b2cb645f19..f0d57fba9307 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesResourcesQuotaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-resources-quota.customizer") - && target instanceof KubernetesResourcesQuotaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-resources-quota", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentConverter.java index 74ce691102d2..30ebbddb0f28 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/resources_quota/springboot/KubernetesResourcesQuotaComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-resources-quota"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentAutoConfiguration.java index 6dd974aacd32..bd4763faed3c 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesSecretsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-secrets.customizer") - && target instanceof KubernetesSecretsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-secrets", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentConverter.java index 394e68e8567a..bc15dce52fa4 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/secrets/springboot/KubernetesSecretsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-secrets"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java index 89b7f882abea..c3030e025e50 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesServiceAccountsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-service-accounts.customizer") - && target instanceof KubernetesServiceAccountsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-service-accounts", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConverter.java index f8c845e6d0c4..a82ca2780b96 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/service_accounts/springboot/KubernetesServiceAccountsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-service-accounts"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentAutoConfiguration.java index 5deaca034ece..3d18f64300f4 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKubernetesServicesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kubernetes-services.customizer") - && target instanceof KubernetesServicesComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-services", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentConverter.java index 34fdd91a858b..30972dcf8889 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/kubernetes/services/springboot/KubernetesServicesComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kubernetes-services"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentAutoConfiguration.java index 69949cd45468..afa6f0cd5b19 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOpenshiftBuildConfigsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openshift-build-configs.customizer") - && target instanceof OpenshiftBuildConfigsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openshift-build-configs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentConverter.java index 32bc8214f3a2..a6201f2c7a44 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/build_configs/springboot/OpenshiftBuildConfigsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.openshift-build-configs"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentAutoConfiguration.java index 9d883edd02b1..698c1d132fd3 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOpenshiftBuildsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openshift-builds.customizer") - && target instanceof OpenshiftBuildsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openshift-builds", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentConverter.java index ccc7e3f7b865..bb26f865a7a1 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/builds/springboot/OpenshiftBuildsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.openshift-builds"); } } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentAutoConfiguration.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentAutoConfiguration.java index 1a4b158f902f..629ee4132172 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentAutoConfiguration.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOpenshiftDeploymentConfigsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openshift-deploymentconfigs.customizer") - && target instanceof OpenshiftDeploymentConfigsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openshift-deploymentconfigs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentConverter.java b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentConverter.java index edc706fe2b0f..08be1275dae8 100644 --- a/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentConverter.java +++ b/components-starter/camel-kubernetes-starter/src/main/java/org/apache/camel/component/openshift/deploymentconfigs/springboot/OpenshiftDeploymentConfigsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,17 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.fabric8.kubernetes.client.KubernetesClient": return applicationContext.getBean(ref, io.fabric8.kubernetes.client.KubernetesClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.openshift-deploymentconfigs"); } } \ No newline at end of file diff --git a/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentAutoConfiguration.java b/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentAutoConfiguration.java index 025973bc55ce..a27c213eb611 100644 --- a/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentAutoConfiguration.java +++ b/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKuduComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.kudu.customizer") - && target instanceof KuduComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kudu", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentConverter.java b/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentConverter.java index 656bdd8e17f6..6dd74b05fca0 100644 --- a/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentConverter.java +++ b/components-starter/camel-kudu-starter/src/main/java/org/apache/camel/component/kudu/springboot/KuduComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.kudu.client.KuduClient": return applicationContext.getBean(ref, org.apache.kudu.client.KuduClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.kudu"); } } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentAutoConfiguration.java b/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentAutoConfiguration.java index c096ec14cd9d..0c30b91c46f3 100644 --- a/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentAutoConfiguration.java +++ b/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLangChain4jAgentComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.langchain4j-agent.customizer") - && target instanceof LangChain4jAgentComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-agent", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentConverter.java b/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentConverter.java index 2f76c6b59356..21d2f7a9979b 100644 --- a/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentConverter.java +++ b/components-starter/camel-langchain4j-agent-starter/src/main/java/org/apache/camel/component/langchain4j/agent/springboot/LangChain4jAgentComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.langchain4j.agent.api.Agent": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.agent.api.Agent.class); - case "org.apache.camel.component.langchain4j.agent.api.AgentFactory": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.agent.api.AgentFactory.class); - case "org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.agent.LangChain4jAgentConfiguration.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.langchain4j-agent"); } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentAutoConfiguration.java b/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentAutoConfiguration.java index c02b7cfe4c8e..f4ddeb96a0ed 100644 --- a/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentAutoConfiguration.java +++ b/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLangChain4jChatComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.langchain4j-chat.customizer") - && target instanceof LangChain4jChatComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-chat", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConverter.java b/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConverter.java index 021f0610c0cd..74b54f4fa330 100644 --- a/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConverter.java +++ b/components-starter/camel-langchain4j-chat-starter/src/main/java/org/apache/camel/component/langchain4j/chat/springboot/LangChain4jChatComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.chat.LangChain4jChatConfiguration.class); - case "dev.langchain4j.model.chat.ChatModel": return applicationContext.getBean(ref, dev.langchain4j.model.chat.ChatModel.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.langchain4j-chat"); } } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentAutoConfiguration.java b/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentAutoConfiguration.java index 7f85ec0f74f7..340cc3f80ed1 100644 --- a/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentAutoConfiguration.java +++ b/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLangChain4jEmbeddingsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.langchain4j-embeddings.customizer") - && target instanceof LangChain4jEmbeddingsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-embeddings", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentConverter.java b/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentConverter.java index c592da14ae61..fc5c9142d3f9 100644 --- a/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentConverter.java +++ b/components-starter/camel-langchain4j-embeddings-starter/src/main/java/org/apache/camel/component/langchain4j/embeddings/springboot/LangChain4jEmbeddingsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,18 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.langchain4j.embeddings.LangChain4jEmbeddingsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.embeddings.LangChain4jEmbeddingsConfiguration.class); - case "dev.langchain4j.model.embedding.EmbeddingModel": return applicationContext.getBean(ref, dev.langchain4j.model.embedding.EmbeddingModel.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.langchain4j-embeddings"); } } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentAutoConfiguration.java b/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentAutoConfiguration.java index 51a253807a86..9d03f5e7535b 100644 --- a/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentAutoConfiguration.java +++ b/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLangChain4jEmbeddingStoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.langchain4j-embeddingstore.customizer") - && target instanceof LangChain4jEmbeddingStoreComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-embeddingstore", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentConverter.java b/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentConverter.java index 5e2cc8e8ef39..50d1298f5906 100644 --- a/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentConverter.java +++ b/components-starter/camel-langchain4j-embeddingstore-starter/src/main/java/org/apache/camel/component/langchain4j/embeddingstore/springboot/LangChain4jEmbeddingStoreComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,19 +52,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.langchain4j.embeddingstore.LangChain4jEmbeddingStoreConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.embeddingstore.LangChain4jEmbeddingStoreConfiguration.class); - case "dev.langchain4j.store.embedding.EmbeddingStore": return applicationContext.getBean(ref, dev.langchain4j.store.embedding.EmbeddingStore.class); - case "org.apache.camel.component.langchain4j.embeddingstore.EmbeddingStoreFactory": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.embeddingstore.EmbeddingStoreFactory.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.langchain4j-embeddingstore"); } \ No newline at end of file diff --git a/components-starter/camel-langchain4j-web-search-starter/src/main/java/org/apache/camel/component/langchain4j/web/search/springboot/LangChain4jWebSearchComponentAutoConfiguration.java b/components-starter/camel-langchain4j-web-search-starter/src/main/java/org/apache/camel/component/langchain4j/web/search/springboot/LangChain4jWebSearchComponentAutoConfiguration.java index 3c78369ed1c9..2df38ae53df9 100644 --- a/components-starter/camel-langchain4j-web-search-starter/src/main/java/org/apache/camel/component/langchain4j/web/search/springboot/LangChain4jWebSearchComponentAutoConfiguration.java +++ b/components-starter/camel-langchain4j-web-search-starter/src/main/java/org/apache/camel/component/langchain4j/web/search/springboot/LangChain4jWebSearchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLangChain4jWebSearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.langchain4j-web-search.customizer") - && target instanceof LangChain4jWebSearchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-web-search", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-language-starter/src/main/java/org/apache/camel/component/language/springboot/LanguageComponentAutoConfiguration.java b/components-starter/camel-language-starter/src/main/java/org/apache/camel/component/language/springboot/LanguageComponentAutoConfiguration.java index 723323f1b9b6..6b388cffb89e 100644 --- a/components-starter/camel-language-starter/src/main/java/org/apache/camel/component/language/springboot/LanguageComponentAutoConfiguration.java +++ b/components-starter/camel-language-starter/src/main/java/org/apache/camel/component/language/springboot/LanguageComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLanguageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.language.customizer") - && target instanceof LanguageComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.language", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ldap-starter/src/main/java/org/apache/camel/component/ldap/springboot/LdapComponentAutoConfiguration.java b/components-starter/camel-ldap-starter/src/main/java/org/apache/camel/component/ldap/springboot/LdapComponentAutoConfiguration.java index 1d3d5d0e49d4..608c9d49c067 100644 --- a/components-starter/camel-ldap-starter/src/main/java/org/apache/camel/component/ldap/springboot/LdapComponentAutoConfiguration.java +++ b/components-starter/camel-ldap-starter/src/main/java/org/apache/camel/component/ldap/springboot/LdapComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLdapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ldap.customizer") - && target instanceof LdapComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ldap", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ldif-starter/src/main/java/org/apache/camel/component/ldif/springboot/LdifComponentAutoConfiguration.java b/components-starter/camel-ldif-starter/src/main/java/org/apache/camel/component/ldif/springboot/LdifComponentAutoConfiguration.java index fb88a8458eea..3a542876b7a1 100644 --- a/components-starter/camel-ldif-starter/src/main/java/org/apache/camel/component/ldif/springboot/LdifComponentAutoConfiguration.java +++ b/components-starter/camel-ldif-starter/src/main/java/org/apache/camel/component/ldif/springboot/LdifComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLdifComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ldif.customizer") - && target instanceof LdifComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ldif", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentAutoConfiguration.java b/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentAutoConfiguration.java index 0afe6dbf98c0..bdcd68bfd848 100644 --- a/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentAutoConfiguration.java +++ b/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLogComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.log.customizer") - && target instanceof LogComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.log", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentConverter.java b/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentConverter.java index 314e17eeae06..d83f66e2a3de 100644 --- a/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentConverter.java +++ b/components-starter/camel-log-starter/src/main/java/org/apache/camel/component/log/springboot/LogComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.ExchangeFormatter": return applicationContext.getBean(ref, org.apache.camel.spi.ExchangeFormatter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.log"); } } \ No newline at end of file diff --git a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java index aae68d05d71c..6379818fd339 100644 --- a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java +++ b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLuceneComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.lucene.customizer") - && target instanceof LuceneComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.lucene", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConverter.java b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConverter.java index 5d2361feecb2..e2233a7a78e2 100644 --- a/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConverter.java +++ b/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.lucene.analysis.Analyzer": return applicationContext.getBean(ref, org.apache.lucene.analysis.Analyzer.class); - case "org.apache.camel.component.lucene.LuceneConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.lucene.LuceneConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.lucene"); } } \ No newline at end of file diff --git a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java index a86bd9cfa620..2e0dc176a0bb 100644 --- a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java +++ b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureLumberjackComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.lumberjack.customizer") - && target instanceof LumberjackComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.lumberjack", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConverter.java b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConverter.java index d992c2aef764..ba43789e8656 100644 --- a/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConverter.java +++ b/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.lumberjack"); } } \ No newline at end of file diff --git a/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java b/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java index 5bb7c4a90757..b7c8efa0b612 100644 --- a/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java +++ b/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureLZFDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.lzf.customizer") - && target instanceof LZFDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.lzf", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java index ab8e41f2b6ce..92ecd8289588 100644 --- a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java +++ b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMailComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mail.customizer") - && target instanceof MailComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mail", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConverter.java b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConverter.java index f363c32f443d..59e7ee5d5bcb 100644 --- a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConverter.java +++ b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -55,25 +56,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.mail.JavaMailSender": return applicationContext.getBean(ref, org.apache.camel.component.mail.JavaMailSender.class); - case "java.util.Properties": return applicationContext.getBean(ref, java.util.Properties.class); - case "org.apache.camel.component.mail.AttachmentsContentTransferEncodingResolver": return applicationContext.getBean(ref, org.apache.camel.component.mail.AttachmentsContentTransferEncodingResolver.class); - case "org.apache.camel.component.mail.MailAuthenticator": return applicationContext.getBean(ref, org.apache.camel.component.mail.MailAuthenticator.class); - case "org.apache.camel.component.mail.MailConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.mail.MailConfiguration.class); - case "org.apache.camel.component.mail.ContentTypeResolver": return applicationContext.getBean(ref, org.apache.camel.component.mail.ContentTypeResolver.class); - case "jakarta.mail.Session": return applicationContext.getBean(ref, jakarta.mail.Session.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mail"); } } \ No newline at end of file diff --git a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java index b47c0e5389ad..e953be1e1579 100644 --- a/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java +++ b/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureMimeMultipartDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.mime-multipart.customizer") - && target instanceof MimeMultipartDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.mime-multipart", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentAutoConfiguration.java b/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentAutoConfiguration.java index 90c5fdee9fce..1597ac37178a 100644 --- a/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentAutoConfiguration.java +++ b/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMapstructComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mapstruct.customizer") - && target instanceof MapstructComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mapstruct", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentConverter.java b/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentConverter.java index 17b672220124..8c8fdd27a43f 100644 --- a/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentConverter.java +++ b/components-starter/camel-mapstruct-starter/src/main/java/org/apache/camel/component/mapstruct/springboot/MapstructComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.mapstruct.MapStructMapperFinder": return applicationContext.getBean(ref, org.apache.camel.component.mapstruct.MapStructMapperFinder.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mapstruct"); } } \ No newline at end of file diff --git a/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentAutoConfiguration.java b/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentAutoConfiguration.java index 6ad09489fcca..966f2baba65c 100644 --- a/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentAutoConfiguration.java +++ b/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMasterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.master.customizer") - && target instanceof MasterComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.master", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentConverter.java b/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentConverter.java index 61ea7c6010fb..a01df36b8a7d 100644 --- a/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentConverter.java +++ b/components-starter/camel-master-starter/src/main/java/org/apache/camel/component/master/springboot/MasterComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.cluster.CamelClusterService": return applicationContext.getBean(ref, org.apache.camel.cluster.CamelClusterService.class); - case "org.apache.camel.cluster.CamelClusterService.Selector": return applicationContext.getBean(ref, org.apache.camel.cluster.CamelClusterService.Selector.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.master"); } } \ No newline at end of file diff --git a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java index f0792321c18d..782d0dd71c44 100644 --- a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java +++ b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMetricsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.metrics.customizer") - && target instanceof MetricsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.metrics", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConverter.java b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConverter.java index 79637a9a6c97..7cb03f03e063 100644 --- a/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConverter.java +++ b/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.codahale.metrics.MetricRegistry": return applicationContext.getBean(ref, com.codahale.metrics.MetricRegistry.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.metrics"); } } \ No newline at end of file diff --git a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentAutoConfiguration.java b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentAutoConfiguration.java index 6c680835c209..f478c12a02d1 100644 --- a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentAutoConfiguration.java +++ b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMicrometerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.micrometer.customizer") - && target instanceof MicrometerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.micrometer", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentConverter.java b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentConverter.java index d9e7caa77e17..4be61a8abf69 100644 --- a/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentConverter.java +++ b/components-starter/camel-micrometer-starter/src/main/java/org/apache/camel/component/micrometer/springboot/MicrometerComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.micrometer.core.instrument.MeterRegistry": return applicationContext.getBean(ref, io.micrometer.core.instrument.MeterRegistry.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.micrometer"); } } \ No newline at end of file diff --git a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentAutoConfiguration.java b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentAutoConfiguration.java index 4307163b1790..0f63e1656151 100644 --- a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentAutoConfiguration.java +++ b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMiloBrowseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.milo-browse.customizer") - && target instanceof MiloBrowseComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milo-browse", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentConverter.java b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentConverter.java index 95994d812c9e..af82678f77b7 100644 --- a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentConverter.java +++ b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/browse/springboot/MiloBrowseComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.milo.client.MiloClientConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.milo.client.MiloClientConfiguration.class); - case "org.apache.camel.component.milo.client.MiloClientConnectionManager": return applicationContext.getBean(ref, org.apache.camel.component.milo.client.MiloClientConnectionManager.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.milo-browse"); } } \ No newline at end of file diff --git a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java index 9df20c58a6ba..cfe6ab7bc0e8 100644 --- a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java +++ b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMiloClientComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.milo-client.customizer") - && target instanceof MiloClientComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milo-client", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConverter.java b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConverter.java index 71dc687bff07..92047d9b0431 100644 --- a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConverter.java +++ b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.milo.client.MiloClientConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.milo.client.MiloClientConfiguration.class); - case "org.apache.camel.component.milo.client.MiloClientConnectionManager": return applicationContext.getBean(ref, org.apache.camel.component.milo.client.MiloClientConnectionManager.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.milo-client"); } } \ No newline at end of file diff --git a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java index a329ac4574b5..936b062bdc28 100644 --- a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java +++ b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMiloServerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.milo-server.customizer") - && target instanceof MiloServerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milo-server", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConverter.java b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConverter.java index b00ae174760d..7fe700e8bb08 100644 --- a/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConverter.java +++ b/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo": return applicationContext.getBean(ref, org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo.class); - case "java.security.cert.X509Certificate": return applicationContext.getBean(ref, java.security.cert.X509Certificate.class); - case "org.eclipse.milo.opcua.stack.core.security.CertificateManager": return applicationContext.getBean(ref, org.eclipse.milo.opcua.stack.core.security.CertificateManager.class); - case "org.eclipse.milo.opcua.stack.core.security.CertificateValidator": return applicationContext.getBean(ref, org.eclipse.milo.opcua.stack.core.security.CertificateValidator.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.milo-server"); } } \ No newline at end of file diff --git a/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentAutoConfiguration.java b/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentAutoConfiguration.java index 50974c8773bc..892da93d7833 100644 --- a/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentAutoConfiguration.java +++ b/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMilvusComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.milvus.customizer") - && target instanceof MilvusComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milvus", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentConverter.java b/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentConverter.java index 5144081f6988..cc13cfb6f251 100644 --- a/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentConverter.java +++ b/components-starter/camel-milvus-starter/src/main/java/org/apache/camel/component/milvus/springboot/MilvusComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.milvus.MilvusConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.milvus.MilvusConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.milvus"); } } \ No newline at end of file diff --git a/components-starter/camel-mina-sftp-starter/src/main/java/org/apache/camel/component/file/remote/mina/springboot/MinaSftpComponentAutoConfiguration.java b/components-starter/camel-mina-sftp-starter/src/main/java/org/apache/camel/component/file/remote/mina/springboot/MinaSftpComponentAutoConfiguration.java index 01a977ab5bff..525e70354299 100644 --- a/components-starter/camel-mina-sftp-starter/src/main/java/org/apache/camel/component/file/remote/mina/springboot/MinaSftpComponentAutoConfiguration.java +++ b/components-starter/camel-mina-sftp-starter/src/main/java/org/apache/camel/component/file/remote/mina/springboot/MinaSftpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMinaSftpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mina-sftp.customizer") - && target instanceof MinaSftpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mina-sftp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentAutoConfiguration.java b/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentAutoConfiguration.java index fc46a94e0c5d..0bbafc6b62cb 100644 --- a/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentAutoConfiguration.java +++ b/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMinaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mina.customizer") - && target instanceof MinaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mina", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentConverter.java b/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentConverter.java index acae3613bf25..f16484717362 100644 --- a/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentConverter.java +++ b/components-starter/camel-mina-starter/src/main/java/org/apache/camel/component/mina/springboot/MinaComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.mina.MinaConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.mina.MinaConfiguration.class); - case "org.apache.mina.filter.codec.ProtocolCodecFactory": return applicationContext.getBean(ref, org.apache.mina.filter.codec.ProtocolCodecFactory.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mina"); } } \ No newline at end of file diff --git a/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentAutoConfiguration.java b/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentAutoConfiguration.java index caa55721433e..9a2474447e58 100644 --- a/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentAutoConfiguration.java +++ b/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMinioComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.minio.customizer") - && target instanceof MinioComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.minio", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentConverter.java b/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentConverter.java index a58c59dbaeb8..ea41c2908b9a 100644 --- a/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentConverter.java +++ b/components-starter/camel-minio-starter/src/main/java/org/apache/camel/component/minio/springboot/MinioComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.minio.MinioConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.minio.MinioConfiguration.class); - case "io.minio.MinioClient": return applicationContext.getBean(ref, io.minio.MinioClient.class); - case "okhttp3.OkHttpClient": return applicationContext.getBean(ref, okhttp3.OkHttpClient.class); - case "io.minio.ServerSideEncryption": return applicationContext.getBean(ref, io.minio.ServerSideEncryption.class); - case "io.minio.ServerSideEncryptionCustomerKey": return applicationContext.getBean(ref, io.minio.ServerSideEncryptionCustomerKey.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.minio"); } \ No newline at end of file diff --git a/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java b/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java index 2ddc07f625b0..c2115b80b097 100644 --- a/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java +++ b/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMllpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mllp.customizer") - && target instanceof MllpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mllp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConverter.java b/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConverter.java index a28589b6085a..e2e75f7ea73c 100644 --- a/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConverter.java +++ b/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.mllp.MllpConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.mllp.MllpConfiguration.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mllp"); } } \ No newline at end of file diff --git a/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java b/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java index 94944716f415..9c5b38059d15 100644 --- a/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java +++ b/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMockComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mock.customizer") - && target instanceof MockComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mock", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConverter.java b/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConverter.java index aba5b44b948f..e07feb904765 100644 --- a/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConverter.java +++ b/components-starter/camel-mock-starter/src/main/java/org/apache/camel/component/mock/springboot/MockComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.ExchangeFormatter": return applicationContext.getBean(ref, org.apache.camel.spi.ExchangeFormatter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mock"); } } \ No newline at end of file diff --git a/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java b/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java index 1bcd7b4df5ac..385c20391f8d 100644 --- a/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java +++ b/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGridFsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mongodb-gridfs.customizer") - && target instanceof GridFsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mongodb-gridfs", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java b/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java index e864dc0d3699..e96bb5e3ec07 100644 --- a/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java +++ b/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMongoDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mongodb.customizer") - && target instanceof MongoDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mongodb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConverter.java b/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConverter.java index 084c01954811..1d750aec0fd9 100644 --- a/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConverter.java +++ b/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.mongodb.client.MongoClient": return applicationContext.getBean(ref, com.mongodb.client.MongoClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mongodb"); } } \ No newline at end of file diff --git a/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java b/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java index 72546d5769ab..ca452e0deeb8 100644 --- a/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java +++ b/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMustacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mustache.customizer") - && target instanceof MustacheComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mustache", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConverter.java b/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConverter.java index 83dd29e1e0cd..15566866b49c 100644 --- a/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConverter.java +++ b/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.github.mustachejava.MustacheFactory": return applicationContext.getBean(ref, com.github.mustachejava.MustacheFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mustache"); } } \ No newline at end of file diff --git a/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java b/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java index 1bc81c66ba64..8ddb8a53443f 100644 --- a/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java +++ b/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMvelComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mvel.customizer") - && target instanceof MvelComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mvel", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java b/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java index 0e0692888f83..442fdc529d23 100644 --- a/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java +++ b/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureMvelLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.mvel.customizer") - && target instanceof MvelLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.mvel", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentAutoConfiguration.java b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentAutoConfiguration.java index 75ef5a12e7f9..564a076cc0cf 100644 --- a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentAutoConfiguration.java +++ b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMyBatisBeanComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mybatis-bean.customizer") - && target instanceof MyBatisBeanComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mybatis-bean", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentConverter.java b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentConverter.java index 5ff4a9303041..d43bdd0f7e71 100644 --- a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentConverter.java +++ b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisBeanComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ibatis.session.SqlSessionFactory": return applicationContext.getBean(ref, org.apache.ibatis.session.SqlSessionFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mybatis-bean"); } } \ No newline at end of file diff --git a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentAutoConfiguration.java b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentAutoConfiguration.java index e5c0416e6520..cbae9db76423 100644 --- a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentAutoConfiguration.java +++ b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMyBatisComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.mybatis.customizer") - && target instanceof MyBatisComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mybatis", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentConverter.java b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentConverter.java index 72f90cda475c..47e0a4176a55 100644 --- a/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentConverter.java +++ b/components-starter/camel-mybatis-starter/src/main/java/org/apache/camel/component/mybatis/springboot/MyBatisComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.ibatis.session.SqlSessionFactory": return applicationContext.getBean(ref, org.apache.ibatis.session.SqlSessionFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.mybatis"); } } \ No newline at end of file diff --git a/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentAutoConfiguration.java b/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentAutoConfiguration.java index 083ae476c935..bd6e6a05d602 100644 --- a/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentAutoConfiguration.java +++ b/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNatsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.nats.customizer") - && target instanceof NatsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.nats", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentConverter.java b/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentConverter.java index ec8d204b300e..4d52b559a2d3 100644 --- a/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentConverter.java +++ b/components-starter/camel-nats-starter/src/main/java/org/apache/camel/component/nats/springboot/NatsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.nats.NatsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.nats.NatsConfiguration.class); - case "io.nats.client.api.ConsumerConfiguration": return applicationContext.getBean(ref, io.nats.client.api.ConsumerConfiguration.class); - case "io.nats.client.Connection": return applicationContext.getBean(ref, io.nats.client.Connection.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.nats"); } } \ No newline at end of file diff --git a/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentAutoConfiguration.java b/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentAutoConfiguration.java index 06e25879a4a5..6c66b28b44cb 100644 --- a/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentAutoConfiguration.java +++ b/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNeo4jComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.neo4j.customizer") - && target instanceof Neo4jComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.neo4j", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentConverter.java b/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentConverter.java index 04dd24be2fd9..593307ad74f0 100644 --- a/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentConverter.java +++ b/components-starter/camel-neo4j-starter/src/main/java/org/apache/camel/component/neo4j/springboot/Neo4jComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.neo4j.Neo4jConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.neo4j.Neo4jConfiguration.class); - case "org.neo4j.driver.Driver": return applicationContext.getBean(ref, org.neo4j.driver.Driver.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.neo4j"); } } \ No newline at end of file diff --git a/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentAutoConfiguration.java b/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentAutoConfiguration.java index c5c0f80a94c6..6bd07fa10fab 100644 --- a/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentAutoConfiguration.java +++ b/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNettyHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.netty-http.customizer") - && target instanceof NettyHttpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.netty-http", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentConverter.java b/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentConverter.java index bf87b2de62c2..e91e8877472a 100644 --- a/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentConverter.java +++ b/components-starter/camel-netty-http-starter/src/main/java/org/apache/camel/component/netty/http/springboot/NettyHttpComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -59,29 +60,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.netty.NettyConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.netty.NettyConfiguration.class); - case "io.netty.channel.EventLoopGroup": return applicationContext.getBean(ref, io.netty.channel.EventLoopGroup.class); - case "io.netty.util.concurrent.EventExecutorGroup": return applicationContext.getBean(ref, io.netty.util.concurrent.EventExecutorGroup.class); - case "org.apache.camel.component.netty.NettyServerBootstrapFactory": return applicationContext.getBean(ref, org.apache.camel.component.netty.NettyServerBootstrapFactory.class); - case "org.apache.camel.component.netty.ServerInitializerFactory": return applicationContext.getBean(ref, org.apache.camel.component.netty.ServerInitializerFactory.class); - case "org.apache.camel.component.netty.ClientInitializerFactory": return applicationContext.getBean(ref, org.apache.camel.component.netty.ClientInitializerFactory.class); - case "org.apache.camel.component.netty.NettyCamelStateCorrelationManager": return applicationContext.getBean(ref, org.apache.camel.component.netty.NettyCamelStateCorrelationManager.class); - case "io.netty.channel.group.ChannelGroup": return applicationContext.getBean(ref, io.netty.channel.group.ChannelGroup.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.component.netty.http.NettyHttpBinding": return applicationContext.getBean(ref, org.apache.camel.component.netty.http.NettyHttpBinding.class); - case "org.apache.camel.component.netty.http.NettyHttpSecurityConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.netty.http.NettyHttpSecurityConfiguration.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - case "io.netty.handler.ssl.SslHandler": return applicationContext.getBean(ref, io.netty.handler.ssl.SslHandler.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.netty-http"); } } \ No newline at end of file diff --git a/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentAutoConfiguration.java b/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentAutoConfiguration.java index ffa80dc8d27c..6d1d2f29f917 100644 --- a/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentAutoConfiguration.java +++ b/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNettyComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.netty.customizer") - && target instanceof NettyComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.netty", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConverter.java b/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConverter.java index 19e7c847189c..2dcdd4e24f31 100644 --- a/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConverter.java +++ b/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -56,26 +57,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.netty.NettyConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.netty.NettyConfiguration.class); - case "io.netty.channel.EventLoopGroup": return applicationContext.getBean(ref, io.netty.channel.EventLoopGroup.class); - case "io.netty.util.concurrent.EventExecutorGroup": return applicationContext.getBean(ref, io.netty.util.concurrent.EventExecutorGroup.class); - case "org.apache.camel.component.netty.NettyServerBootstrapFactory": return applicationContext.getBean(ref, org.apache.camel.component.netty.NettyServerBootstrapFactory.class); - case "org.apache.camel.component.netty.ServerInitializerFactory": return applicationContext.getBean(ref, org.apache.camel.component.netty.ServerInitializerFactory.class); - case "org.apache.camel.component.netty.ClientInitializerFactory": return applicationContext.getBean(ref, org.apache.camel.component.netty.ClientInitializerFactory.class); - case "org.apache.camel.component.netty.NettyCamelStateCorrelationManager": return applicationContext.getBean(ref, org.apache.camel.component.netty.NettyCamelStateCorrelationManager.class); - case "io.netty.channel.group.ChannelGroup": return applicationContext.getBean(ref, io.netty.channel.group.ChannelGroup.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - case "io.netty.handler.ssl.SslHandler": return applicationContext.getBean(ref, io.netty.handler.ssl.SslHandler.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.netty"); } } \ No newline at end of file diff --git a/components-starter/camel-oaipmh-starter/src/main/java/org/apache/camel/oaipmh/component/springboot/OAIPMHComponentAutoConfiguration.java b/components-starter/camel-oaipmh-starter/src/main/java/org/apache/camel/oaipmh/component/springboot/OAIPMHComponentAutoConfiguration.java index 41dc6f4cac6b..6db4593708f6 100644 --- a/components-starter/camel-oaipmh-starter/src/main/java/org/apache/camel/oaipmh/component/springboot/OAIPMHComponentAutoConfiguration.java +++ b/components-starter/camel-oaipmh-starter/src/main/java/org/apache/camel/oaipmh/component/springboot/OAIPMHComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOAIPMHComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.oaipmh.customizer") - && target instanceof OAIPMHComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.oaipmh", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ocsf-starter/src/main/java/org/apache/camel/dataformat/ocsf/springboot/OcsfDataFormatAutoConfiguration.java b/components-starter/camel-ocsf-starter/src/main/java/org/apache/camel/dataformat/ocsf/springboot/OcsfDataFormatAutoConfiguration.java index 3488c1e8e708..72a0e47976c1 100644 --- a/components-starter/camel-ocsf-starter/src/main/java/org/apache/camel/dataformat/ocsf/springboot/OcsfDataFormatAutoConfiguration.java +++ b/components-starter/camel-ocsf-starter/src/main/java/org/apache/camel/dataformat/ocsf/springboot/OcsfDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureOcsfDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.ocsf.customizer") - && target instanceof OcsfDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.ocsf", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ognl-starter/src/main/java/org/apache/camel/language/ognl/springboot/OgnlLanguageAutoConfiguration.java b/components-starter/camel-ognl-starter/src/main/java/org/apache/camel/language/ognl/springboot/OgnlLanguageAutoConfiguration.java index e41d3946d2a6..b5aa5581c486 100644 --- a/components-starter/camel-ognl-starter/src/main/java/org/apache/camel/language/ognl/springboot/OgnlLanguageAutoConfiguration.java +++ b/components-starter/camel-ognl-starter/src/main/java/org/apache/camel/language/ognl/springboot/OgnlLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureOgnlLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.ognl.customizer") - && target instanceof OgnlLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.ognl", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentAutoConfiguration.java b/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentAutoConfiguration.java index cfcbc490b678..bfaf40ab7692 100644 --- a/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentAutoConfiguration.java +++ b/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOlingo2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.olingo2.customizer") - && target instanceof Olingo2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.olingo2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentConverter.java b/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentConverter.java index cdf465925fc5..3d04f758ced8 100644 --- a/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentConverter.java +++ b/components-starter/camel-olingo2-starter/src/main/java/org/apache/camel/component/olingo2/springboot/Olingo2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -53,23 +54,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.olingo2.Olingo2Configuration": return applicationContext.getBean(ref, org.apache.camel.component.olingo2.Olingo2Configuration.class); - case "org.apache.olingo.odata2.api.ep.EntityProviderReadProperties": return applicationContext.getBean(ref, org.apache.olingo.odata2.api.ep.EntityProviderReadProperties.class); - case "org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties": return applicationContext.getBean(ref, org.apache.olingo.odata2.api.ep.EntityProviderWriteProperties.class); - case "org.apache.http.HttpHost": return applicationContext.getBean(ref, org.apache.http.HttpHost.class); - case "org.apache.http.impl.nio.client.HttpAsyncClientBuilder": return applicationContext.getBean(ref, org.apache.http.impl.nio.client.HttpAsyncClientBuilder.class); - case "org.apache.http.impl.client.HttpClientBuilder": return applicationContext.getBean(ref, org.apache.http.impl.client.HttpClientBuilder.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.olingo2"); } } \ No newline at end of file diff --git a/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentAutoConfiguration.java b/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentAutoConfiguration.java index b2e564a78db4..06d338cc9527 100644 --- a/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentAutoConfiguration.java +++ b/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOlingo4Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.olingo4.customizer") - && target instanceof Olingo4Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.olingo4", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentConverter.java b/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentConverter.java index ea8f00ea193f..1074e75b2ca5 100644 --- a/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentConverter.java +++ b/components-starter/camel-olingo4-starter/src/main/java/org/apache/camel/component/olingo4/springboot/Olingo4ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.olingo4.Olingo4Configuration": return applicationContext.getBean(ref, org.apache.camel.component.olingo4.Olingo4Configuration.class); - case "org.apache.http.HttpHost": return applicationContext.getBean(ref, org.apache.http.HttpHost.class); - case "org.apache.http.impl.nio.client.HttpAsyncClientBuilder": return applicationContext.getBean(ref, org.apache.http.impl.nio.client.HttpAsyncClientBuilder.class); - case "org.apache.http.impl.client.HttpClientBuilder": return applicationContext.getBean(ref, org.apache.http.impl.client.HttpClientBuilder.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.olingo4"); } } \ No newline at end of file diff --git a/components-starter/camel-once-starter/src/main/java/org/apache/camel/component/once/springboot/OnceComponentAutoConfiguration.java b/components-starter/camel-once-starter/src/main/java/org/apache/camel/component/once/springboot/OnceComponentAutoConfiguration.java index dc6700c79235..9b06aadcbda4 100644 --- a/components-starter/camel-once-starter/src/main/java/org/apache/camel/component/once/springboot/OnceComponentAutoConfiguration.java +++ b/components-starter/camel-once-starter/src/main/java/org/apache/camel/component/once/springboot/OnceComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOnceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.once.customizer") - && target instanceof OnceComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.once", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-openai-starter/src/main/java/org/apache/camel/component/openai/springboot/OpenAIComponentAutoConfiguration.java b/components-starter/camel-openai-starter/src/main/java/org/apache/camel/component/openai/springboot/OpenAIComponentAutoConfiguration.java index 635adb577021..7e4f8c0f15e7 100644 --- a/components-starter/camel-openai-starter/src/main/java/org/apache/camel/component/openai/springboot/OpenAIComponentAutoConfiguration.java +++ b/components-starter/camel-openai-starter/src/main/java/org/apache/camel/component/openai/springboot/OpenAIComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOpenAIComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openai.customizer") - && target instanceof OpenAIComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openai", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentAutoConfiguration.java b/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentAutoConfiguration.java index a145e523ea88..e05737e0aa6e 100644 --- a/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentAutoConfiguration.java +++ b/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOpensearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.opensearch.customizer") - && target instanceof OpensearchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.opensearch", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentConverter.java b/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentConverter.java index 37b3a7697baa..011a0b1817ba 100644 --- a/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentConverter.java +++ b/components-starter/camel-opensearch-starter/src/main/java/org/apache/camel/component/opensearch/springboot/OpensearchComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.opensearch.client.RestClient": return applicationContext.getBean(ref, org.opensearch.client.RestClient.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.opensearch"); } \ No newline at end of file diff --git a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/cinder/springboot/CinderComponentAutoConfiguration.java b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/cinder/springboot/CinderComponentAutoConfiguration.java index 14a96d42640e..1d63aa46543f 100644 --- a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/cinder/springboot/CinderComponentAutoConfiguration.java +++ b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/cinder/springboot/CinderComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureCinderComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openstack-cinder.customizer") - && target instanceof CinderComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-cinder", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/glance/springboot/GlanceComponentAutoConfiguration.java b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/glance/springboot/GlanceComponentAutoConfiguration.java index f9b2a47475b0..7dae404c3f8b 100644 --- a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/glance/springboot/GlanceComponentAutoConfiguration.java +++ b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/glance/springboot/GlanceComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureGlanceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openstack-glance.customizer") - && target instanceof GlanceComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-glance", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/keystone/springboot/KeystoneComponentAutoConfiguration.java b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/keystone/springboot/KeystoneComponentAutoConfiguration.java index 75ab1a0bcd38..cd5960469889 100644 --- a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/keystone/springboot/KeystoneComponentAutoConfiguration.java +++ b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/keystone/springboot/KeystoneComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureKeystoneComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openstack-keystone.customizer") - && target instanceof KeystoneComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-keystone", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/neutron/springboot/NeutronComponentAutoConfiguration.java b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/neutron/springboot/NeutronComponentAutoConfiguration.java index a39a9f996ac8..e102521242e7 100644 --- a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/neutron/springboot/NeutronComponentAutoConfiguration.java +++ b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/neutron/springboot/NeutronComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNeutronComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openstack-neutron.customizer") - && target instanceof NeutronComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-neutron", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/nova/springboot/NovaComponentAutoConfiguration.java b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/nova/springboot/NovaComponentAutoConfiguration.java index fd21d9774cdd..a4039f28b4b8 100644 --- a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/nova/springboot/NovaComponentAutoConfiguration.java +++ b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/nova/springboot/NovaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNovaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openstack-nova.customizer") - && target instanceof NovaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-nova", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/swift/springboot/SwiftComponentAutoConfiguration.java b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/swift/springboot/SwiftComponentAutoConfiguration.java index 84e2dd64bc41..664f79a85d50 100644 --- a/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/swift/springboot/SwiftComponentAutoConfiguration.java +++ b/components-starter/camel-openstack-starter/src/main/java/org/apache/camel/component/openstack/swift/springboot/SwiftComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSwiftComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.openstack-swift.customizer") - && target instanceof SwiftComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-swift", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentAutoConfiguration.java b/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentAutoConfiguration.java index 92f979f9f4f2..74bb30cb82bf 100644 --- a/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentAutoConfiguration.java +++ b/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOpenTelemetryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.opentelemetry-metrics.customizer") - && target instanceof OpenTelemetryComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.opentelemetry-metrics", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentConverter.java b/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentConverter.java index 8e99d46022ae..5232b006ce64 100644 --- a/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentConverter.java +++ b/components-starter/camel-opentelemetry-metrics-starter/src/main/java/org/apache/camel/opentelemetry/metrics/springboot/OpenTelemetryComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.opentelemetry.api.metrics.Meter": return applicationContext.getBean(ref, io.opentelemetry.api.metrics.Meter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.opentelemetry-metrics"); } } \ No newline at end of file diff --git a/components-starter/camel-optaplanner-starter/src/main/java/org/apache/camel/component/optaplanner/springboot/OptaPlannerComponentAutoConfiguration.java b/components-starter/camel-optaplanner-starter/src/main/java/org/apache/camel/component/optaplanner/springboot/OptaPlannerComponentAutoConfiguration.java index ce6ddea26939..430a7a7d54b5 100644 --- a/components-starter/camel-optaplanner-starter/src/main/java/org/apache/camel/component/optaplanner/springboot/OptaPlannerComponentAutoConfiguration.java +++ b/components-starter/camel-optaplanner-starter/src/main/java/org/apache/camel/component/optaplanner/springboot/OptaPlannerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureOptaPlannerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.optaplanner.customizer") - && target instanceof OptaPlannerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.optaplanner", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentAutoConfiguration.java b/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentAutoConfiguration.java index 21279bfd93f6..f50956ef296a 100644 --- a/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentAutoConfiguration.java +++ b/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePahoMqtt5Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.paho-mqtt5.customizer") - && target instanceof PahoMqtt5Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.paho-mqtt5", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentConverter.java b/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentConverter.java index 46012ff4656f..7c3c33b4bec4 100644 --- a/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentConverter.java +++ b/components-starter/camel-paho-mqtt5-starter/src/main/java/org/apache/camel/component/paho/mqtt5/springboot/PahoMqtt5ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.paho.mqtt5.PahoMqtt5Configuration": return applicationContext.getBean(ref, org.apache.camel.component.paho.mqtt5.PahoMqtt5Configuration.class); - case "org.eclipse.paho.mqttv5.common.packet.MqttProperties": return applicationContext.getBean(ref, org.eclipse.paho.mqttv5.common.packet.MqttProperties.class); - case "org.eclipse.paho.mqttv5.client.MqttClient": return applicationContext.getBean(ref, org.eclipse.paho.mqttv5.client.MqttClient.class); - case "javax.net.SocketFactory": return applicationContext.getBean(ref, javax.net.SocketFactory.class); - case "java.util.Properties": return applicationContext.getBean(ref, java.util.Properties.class); - case "javax.net.ssl.HostnameVerifier": return applicationContext.getBean(ref, javax.net.ssl.HostnameVerifier.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.paho-mqtt5"); } } \ No newline at end of file diff --git a/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentAutoConfiguration.java b/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentAutoConfiguration.java index a2ef658a4c8b..f3dd3c83c245 100644 --- a/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentAutoConfiguration.java +++ b/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePahoComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.paho.customizer") - && target instanceof PahoComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.paho", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentConverter.java b/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentConverter.java index b27cf037986c..0ec58660b147 100644 --- a/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentConverter.java +++ b/components-starter/camel-paho-starter/src/main/java/org/apache/camel/component/paho/springboot/PahoComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.paho.PahoConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.paho.PahoConfiguration.class); - case "org.eclipse.paho.client.mqttv3.MqttClient": return applicationContext.getBean(ref, org.eclipse.paho.client.mqttv3.MqttClient.class); - case "java.util.Properties": return applicationContext.getBean(ref, java.util.Properties.class); - case "javax.net.SocketFactory": return applicationContext.getBean(ref, javax.net.SocketFactory.class); - case "javax.net.ssl.HostnameVerifier": return applicationContext.getBean(ref, javax.net.ssl.HostnameVerifier.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.paho"); } } \ No newline at end of file diff --git a/components-starter/camel-parquet-avro-starter/src/main/java/org/apache/camel/dataformat/parquet/avro/springboot/ParquetAvroDataFormatAutoConfiguration.java b/components-starter/camel-parquet-avro-starter/src/main/java/org/apache/camel/dataformat/parquet/avro/springboot/ParquetAvroDataFormatAutoConfiguration.java index 3f2f385ec649..08bfff9ad1f7 100644 --- a/components-starter/camel-parquet-avro-starter/src/main/java/org/apache/camel/dataformat/parquet/avro/springboot/ParquetAvroDataFormatAutoConfiguration.java +++ b/components-starter/camel-parquet-avro-starter/src/main/java/org/apache/camel/dataformat/parquet/avro/springboot/ParquetAvroDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureParquetAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.parquet-avro.customizer") - && target instanceof ParquetAvroDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.parquet-avro", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pdf-starter/src/main/java/org/apache/camel/component/pdf/springboot/PdfComponentAutoConfiguration.java b/components-starter/camel-pdf-starter/src/main/java/org/apache/camel/component/pdf/springboot/PdfComponentAutoConfiguration.java index 1e33a2be65aa..5dc4bdd546e4 100644 --- a/components-starter/camel-pdf-starter/src/main/java/org/apache/camel/component/pdf/springboot/PdfComponentAutoConfiguration.java +++ b/components-starter/camel-pdf-starter/src/main/java/org/apache/camel/component/pdf/springboot/PdfComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePdfComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pdf.customizer") - && target instanceof PdfComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pdf", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pg-replication-slot-starter/src/main/java/org/apache/camel/component/pg/replication/slot/springboot/PgReplicationSlotComponentAutoConfiguration.java b/components-starter/camel-pg-replication-slot-starter/src/main/java/org/apache/camel/component/pg/replication/slot/springboot/PgReplicationSlotComponentAutoConfiguration.java index e198c1e7a791..1b68e7364ad4 100644 --- a/components-starter/camel-pg-replication-slot-starter/src/main/java/org/apache/camel/component/pg/replication/slot/springboot/PgReplicationSlotComponentAutoConfiguration.java +++ b/components-starter/camel-pg-replication-slot-starter/src/main/java/org/apache/camel/component/pg/replication/slot/springboot/PgReplicationSlotComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePgReplicationSlotComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pg-replication-slot.customizer") - && target instanceof PgReplicationSlotComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pg-replication-slot", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pgevent-starter/src/main/java/org/apache/camel/component/pgevent/springboot/PgEventComponentAutoConfiguration.java b/components-starter/camel-pgevent-starter/src/main/java/org/apache/camel/component/pgevent/springboot/PgEventComponentAutoConfiguration.java index 23a53a0d72d1..2648f84e3baf 100644 --- a/components-starter/camel-pgevent-starter/src/main/java/org/apache/camel/component/pgevent/springboot/PgEventComponentAutoConfiguration.java +++ b/components-starter/camel-pgevent-starter/src/main/java/org/apache/camel/component/pgevent/springboot/PgEventComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePgEventComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pgevent.customizer") - && target instanceof PgEventComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pgevent", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentAutoConfiguration.java b/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentAutoConfiguration.java index dd376e8c3618..5a5bb7d66faa 100644 --- a/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentAutoConfiguration.java +++ b/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePineconeVectorDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pinecone.customizer") - && target instanceof PineconeVectorDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pinecone", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentConverter.java b/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentConverter.java index 226425737da4..2cad5a2887df 100644 --- a/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentConverter.java +++ b/components-starter/camel-pinecone-starter/src/main/java/org/apache/camel/component/pinecone/springboot/PineconeVectorDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.pinecone.PineconeVectorDbConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.pinecone.PineconeVectorDbConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.pinecone"); } } \ No newline at end of file diff --git a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentAutoConfiguration.java b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentAutoConfiguration.java index 36fc0bcb4dbc..54aafe92e900 100644 --- a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentAutoConfiguration.java +++ b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePlatformHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.platform-http.customizer") - && target instanceof PlatformHttpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.platform-http", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConverter.java b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConverter.java index ca33b19f6985..2554814a8a52 100644 --- a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConverter.java +++ b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/PlatformHttpComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.platform.http.spi.PlatformHttpEngine": return applicationContext.getBean(ref, org.apache.camel.component.platform.http.spi.PlatformHttpEngine.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.platform-http"); } } \ No newline at end of file diff --git a/components-starter/camel-plc4x-starter/src/main/java/org/apache/camel/component/plc4x/springboot/Plc4XComponentAutoConfiguration.java b/components-starter/camel-plc4x-starter/src/main/java/org/apache/camel/component/plc4x/springboot/Plc4XComponentAutoConfiguration.java index 5928cf77ba7b..a9485c26b2f9 100644 --- a/components-starter/camel-plc4x-starter/src/main/java/org/apache/camel/component/plc4x/springboot/Plc4XComponentAutoConfiguration.java +++ b/components-starter/camel-plc4x-starter/src/main/java/org/apache/camel/component/plc4x/springboot/Plc4XComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePlc4XComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.plc4x.customizer") - && target instanceof Plc4XComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.plc4x", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatAutoConfiguration.java b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatAutoConfiguration.java index b643fc555851..b6db9ce630e4 100644 --- a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatAutoConfiguration.java +++ b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configurePQCDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.pqc.customizer") - && target instanceof PQCDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.pqc", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatConverter.java b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatConverter.java index d5dbac8dcfcc..36813e2de405 100644 --- a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatConverter.java +++ b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/dataformat/springboot/PQCDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "java.security.KeyPair": return applicationContext.getBean(ref, java.security.KeyPair.class); - case "javax.crypto.KeyGenerator": return applicationContext.getBean(ref, javax.crypto.KeyGenerator.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.pqc"); } } \ No newline at end of file diff --git a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentAutoConfiguration.java b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentAutoConfiguration.java index 6c856ada1540..7bf5d0411810 100644 --- a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentAutoConfiguration.java +++ b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePQCComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pqc.customizer") - && target instanceof PQCComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pqc", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentConverter.java b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentConverter.java index c0d62cafeb29..23fa22d9f8bf 100644 --- a/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentConverter.java +++ b/components-starter/camel-pqc-starter/src/main/java/org/apache/camel/component/pqc/springboot/PQCComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.pqc.PQCConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.pqc.PQCConfiguration.class); - case "javax.crypto.KeyGenerator": return applicationContext.getBean(ref, javax.crypto.KeyGenerator.class); - case "java.security.KeyPair": return applicationContext.getBean(ref, java.security.KeyPair.class); - case "java.security.KeyStore": return applicationContext.getBean(ref, java.security.KeyStore.class); - case "java.security.Signature": return applicationContext.getBean(ref, java.security.Signature.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.pqc"); } \ No newline at end of file diff --git a/components-starter/camel-printer-starter/src/main/java/org/apache/camel/component/printer/springboot/PrinterComponentAutoConfiguration.java b/components-starter/camel-printer-starter/src/main/java/org/apache/camel/component/printer/springboot/PrinterComponentAutoConfiguration.java index 42da685e66de..f38c04a7ee02 100644 --- a/components-starter/camel-printer-starter/src/main/java/org/apache/camel/component/printer/springboot/PrinterComponentAutoConfiguration.java +++ b/components-starter/camel-printer-starter/src/main/java/org/apache/camel/component/printer/springboot/PrinterComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePrinterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.lpr.customizer") - && target instanceof PrinterComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.lpr", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java b/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java index 395f7ba97e31..d005db121a65 100644 --- a/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java +++ b/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureProtobufDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.protobuf.customizer") - && target instanceof ProtobufDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.protobuf", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentAutoConfiguration.java b/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentAutoConfiguration.java index 59c4297c9d7c..d9ff68e8aee5 100644 --- a/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentAutoConfiguration.java +++ b/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePubNubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pubnub.customizer") - && target instanceof PubNubComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pubnub", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentConverter.java b/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentConverter.java index 82ccf739c249..bc51ebdcf8fa 100644 --- a/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentConverter.java +++ b/components-starter/camel-pubnub-starter/src/main/java/org/apache/camel/component/pubnub/springboot/PubNubComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.pubnub.PubNubConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.pubnub.PubNubConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.pubnub"); } } \ No newline at end of file diff --git a/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentAutoConfiguration.java b/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentAutoConfiguration.java index 58134892d1d7..1c15e9a14825 100644 --- a/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentAutoConfiguration.java +++ b/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configurePulsarComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.pulsar.customizer") - && target instanceof PulsarComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pulsar", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentConverter.java b/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentConverter.java index 8e681d08097e..7196db469d4b 100644 --- a/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentConverter.java +++ b/components-starter/camel-pulsar-starter/src/main/java/org/apache/camel/component/pulsar/springboot/PulsarComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.pulsar.PulsarConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.pulsar.PulsarConfiguration.class); - case "org.apache.pulsar.client.api.RedeliveryBackoff": return applicationContext.getBean(ref, org.apache.pulsar.client.api.RedeliveryBackoff.class); - case "org.apache.camel.component.pulsar.PulsarMessageReceiptFactory": return applicationContext.getBean(ref, org.apache.camel.component.pulsar.PulsarMessageReceiptFactory.class); - case "org.apache.pulsar.client.api.MessageRouter": return applicationContext.getBean(ref, org.apache.pulsar.client.api.MessageRouter.class); - case "org.apache.camel.component.pulsar.utils.AutoConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.pulsar.utils.AutoConfiguration.class); - case "org.apache.pulsar.client.api.PulsarClient": return applicationContext.getBean(ref, org.apache.pulsar.client.api.PulsarClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.pulsar"); } } \ No newline at end of file diff --git a/components-starter/camel-python-starter/src/main/java/org/apache/camel/language/python/springboot/PythonLanguageAutoConfiguration.java b/components-starter/camel-python-starter/src/main/java/org/apache/camel/language/python/springboot/PythonLanguageAutoConfiguration.java index 823382600e50..8c82e946c300 100644 --- a/components-starter/camel-python-starter/src/main/java/org/apache/camel/language/python/springboot/PythonLanguageAutoConfiguration.java +++ b/components-starter/camel-python-starter/src/main/java/org/apache/camel/language/python/springboot/PythonLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configurePythonLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.python.customizer") - && target instanceof PythonLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.python", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentAutoConfiguration.java b/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentAutoConfiguration.java index 213acf0c4e84..12acfaa19de4 100644 --- a/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentAutoConfiguration.java +++ b/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureQdrantComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.qdrant.customizer") - && target instanceof QdrantComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.qdrant", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentConverter.java b/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentConverter.java index 0d5209a610d6..66721ef5e8b2 100644 --- a/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentConverter.java +++ b/components-starter/camel-qdrant-starter/src/main/java/org/apache/camel/component/qdrant/springboot/QdrantComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.qdrant.QdrantConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.qdrant.QdrantConfiguration.class); - case "io.qdrant.client.grpc.Common.Filter": return applicationContext.getBean(ref, io.qdrant.client.grpc.Common.Filter.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.qdrant"); } } \ No newline at end of file diff --git a/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentAutoConfiguration.java b/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentAutoConfiguration.java index 13260271de7d..c9b7a9222445 100644 --- a/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentAutoConfiguration.java +++ b/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureQuartzComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.quartz.customizer") - && target instanceof QuartzComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.quartz", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentConverter.java b/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentConverter.java index 92f433a8bc0d..ae83ad6e59b7 100644 --- a/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentConverter.java +++ b/components-starter/camel-quartz-starter/src/main/java/org/apache/camel/component/quartz/springboot/QuartzComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.quartz.Scheduler": return applicationContext.getBean(ref, org.quartz.Scheduler.class); - case "org.quartz.SchedulerFactory": return applicationContext.getBean(ref, org.quartz.SchedulerFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.quartz"); } } \ No newline at end of file diff --git a/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentAutoConfiguration.java b/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentAutoConfiguration.java index c7b8d7150bcc..e755fd516d3c 100644 --- a/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentAutoConfiguration.java +++ b/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureQuickfixjComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.quickfix.customizer") - && target instanceof QuickfixjComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.quickfix", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentConverter.java b/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentConverter.java index fdcaad556e24..c40b13ec2116 100644 --- a/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentConverter.java +++ b/components-starter/camel-quickfix-starter/src/main/java/org/apache/camel/component/quickfixj/springboot/QuickfixjComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "quickfix.LogFactory": return applicationContext.getBean(ref, quickfix.LogFactory.class); - case "quickfix.MessageFactory": return applicationContext.getBean(ref, quickfix.MessageFactory.class); - case "quickfix.MessageStoreFactory": return applicationContext.getBean(ref, quickfix.MessageStoreFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.quickfix"); } } \ No newline at end of file diff --git a/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentAutoConfiguration.java b/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentAutoConfiguration.java index a968bc4d91d1..32abf896d4dc 100644 --- a/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentAutoConfiguration.java +++ b/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureReactiveStreamsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.reactive-streams.customizer") - && target instanceof ReactiveStreamsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.reactive-streams", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentConverter.java b/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentConverter.java index 68ccb9332721..dd762a06d6a2 100644 --- a/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentConverter.java +++ b/components-starter/camel-reactive-streams-starter/src/main/java/org/apache/camel/component/reactive/streams/springboot/ReactiveStreamsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.reactive.streams.engine.ReactiveStreamsEngineConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.reactive.streams.engine.ReactiveStreamsEngineConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.reactive-streams"); } } \ No newline at end of file diff --git a/components-starter/camel-ref-starter/src/main/java/org/apache/camel/component/ref/springboot/RefComponentAutoConfiguration.java b/components-starter/camel-ref-starter/src/main/java/org/apache/camel/component/ref/springboot/RefComponentAutoConfiguration.java index a7c277773aef..4ad9e31c6be2 100644 --- a/components-starter/camel-ref-starter/src/main/java/org/apache/camel/component/ref/springboot/RefComponentAutoConfiguration.java +++ b/components-starter/camel-ref-starter/src/main/java/org/apache/camel/component/ref/springboot/RefComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRefComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ref.customizer") - && target instanceof RefComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ref", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentAutoConfiguration.java b/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentAutoConfiguration.java index 234be4d99113..7c280a3f275b 100644 --- a/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentAutoConfiguration.java +++ b/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRestOpenApiComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.rest-openapi.customizer") - && target instanceof RestOpenApiComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest-openapi", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentConverter.java b/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentConverter.java index ffa32d9113fd..083950790967 100644 --- a/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentConverter.java +++ b/components-starter/camel-rest-openapi-starter/src/main/java/org/apache/camel/component/rest/openapi/springboot/RestOpenApiComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.rest.openapi.RestOpenapiProcessorStrategy": return applicationContext.getBean(ref, org.apache.camel.component.rest.openapi.RestOpenapiProcessorStrategy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.rest-openapi"); } } \ No newline at end of file diff --git a/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestApiComponentAutoConfiguration.java b/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestApiComponentAutoConfiguration.java index eddfd474148f..9efc1315512d 100644 --- a/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestApiComponentAutoConfiguration.java +++ b/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestApiComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRestApiComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.rest-api.customizer") - && target instanceof RestApiComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest-api", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentAutoConfiguration.java b/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentAutoConfiguration.java index 7454a002cd04..b5b5026d67f7 100644 --- a/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentAutoConfiguration.java +++ b/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRestComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.rest.customizer") - && target instanceof RestComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConverter.java b/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConverter.java index ce8e9c62ef42..09ed2e665cfd 100644 --- a/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConverter.java +++ b/components-starter/camel-rest-starter/src/main/java/org/apache/camel/component/rest/springboot/RestComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.rest"); } } \ No newline at end of file diff --git a/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentAutoConfiguration.java b/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentAutoConfiguration.java index e3924372d92c..af1af998f26a 100644 --- a/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentAutoConfiguration.java +++ b/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRobotFrameworkComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.robotframework.customizer") - && target instanceof RobotFrameworkComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.robotframework", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentConverter.java b/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentConverter.java index 72a52d13af04..225fb4648a4f 100644 --- a/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentConverter.java +++ b/components-starter/camel-robotframework-starter/src/main/java/org/apache/camel/component/robotframework/springboot/RobotFrameworkComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.robotframework.RobotFrameworkCamelConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.robotframework.RobotFrameworkCamelConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.robotframework"); } } \ No newline at end of file diff --git a/components-starter/camel-rocketmq-starter/src/main/java/org/apache/camel/component/rocketmq/springboot/RocketMQComponentAutoConfiguration.java b/components-starter/camel-rocketmq-starter/src/main/java/org/apache/camel/component/rocketmq/springboot/RocketMQComponentAutoConfiguration.java index d8b8113503b6..cec0b33f08dd 100644 --- a/components-starter/camel-rocketmq-starter/src/main/java/org/apache/camel/component/rocketmq/springboot/RocketMQComponentAutoConfiguration.java +++ b/components-starter/camel-rocketmq-starter/src/main/java/org/apache/camel/component/rocketmq/springboot/RocketMQComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRocketMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.rocketmq.customizer") - && target instanceof RocketMQComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rocketmq", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-rss-starter/src/main/java/org/apache/camel/component/rss/springboot/RssComponentAutoConfiguration.java b/components-starter/camel-rss-starter/src/main/java/org/apache/camel/component/rss/springboot/RssComponentAutoConfiguration.java index 16562ce15dbd..4a971cb2e69e 100644 --- a/components-starter/camel-rss-starter/src/main/java/org/apache/camel/component/rss/springboot/RssComponentAutoConfiguration.java +++ b/components-starter/camel-rss-starter/src/main/java/org/apache/camel/component/rss/springboot/RssComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRssComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.rss.customizer") - && target instanceof RssComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rss", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java b/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java index 9dce8260e850..ec94d8fd4eb4 100644 --- a/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java +++ b/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureRssDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.rss.customizer") - && target instanceof RssDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.rss", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-saga-starter/src/main/java/org/apache/camel/component/saga/springboot/SagaComponentAutoConfiguration.java b/components-starter/camel-saga-starter/src/main/java/org/apache/camel/component/saga/springboot/SagaComponentAutoConfiguration.java index a72ea9c13afe..684dd0bd59f6 100644 --- a/components-starter/camel-saga-starter/src/main/java/org/apache/camel/component/saga/springboot/SagaComponentAutoConfiguration.java +++ b/components-starter/camel-saga-starter/src/main/java/org/apache/camel/component/saga/springboot/SagaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSagaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.saga.customizer") - && target instanceof SagaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.saga", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentAutoConfiguration.java b/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentAutoConfiguration.java index 9e937be90f85..4800a57cf84d 100644 --- a/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentAutoConfiguration.java +++ b/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSalesforceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.salesforce.customizer") - && target instanceof SalesforceComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.salesforce", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentConverter.java b/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentConverter.java index accfd9b9d4ff..33436395e8da 100644 --- a/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentConverter.java +++ b/components-starter/camel-salesforce-starter/src/main/java/org/apache/camel/component/salesforce/springboot/SalesforceComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -54,24 +55,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.salesforce.SalesforceHttpClient": return applicationContext.getBean(ref, org.apache.camel.component.salesforce.SalesforceHttpClient.class); - case "com.fasterxml.jackson.databind.ObjectMapper": return applicationContext.getBean(ref, com.fasterxml.jackson.databind.ObjectMapper.class); - case "org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata": return applicationContext.getBean(ref, org.apache.camel.component.salesforce.api.dto.analytics.reports.ReportMetadata.class); - case "org.apache.camel.component.salesforce.SalesforceEndpointConfig": return applicationContext.getBean(ref, org.apache.camel.component.salesforce.SalesforceEndpointConfig.class); - case "java.util.concurrent.ExecutorService": return applicationContext.getBean(ref, java.util.concurrent.ExecutorService.class); - case "org.apache.camel.support.jsse.KeyStoreParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.KeyStoreParameters.class); - case "org.apache.camel.component.salesforce.SalesforceLoginConfig": return applicationContext.getBean(ref, org.apache.camel.component.salesforce.SalesforceLoginConfig.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.salesforce"); } } \ No newline at end of file diff --git a/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentAutoConfiguration.java b/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentAutoConfiguration.java index c211a93dd46a..81434b35bbb8 100644 --- a/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentAutoConfiguration.java +++ b/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureNetWeaverComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.sap-netweaver.customizer") - && target instanceof NetWeaverComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sap-netweaver", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java b/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java index a31ae5b751c9..486966c57bb9 100644 --- a/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java +++ b/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXQueryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xquery.customizer") - && target instanceof XQueryComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xquery", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConverter.java b/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConverter.java index d6fed974a6dc..a5f4ed42afd3 100644 --- a/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConverter.java +++ b/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "net.sf.saxon.Configuration": return applicationContext.getBean(ref, net.sf.saxon.Configuration.class); - case "net.sf.saxon.lib.ModuleURIResolver": return applicationContext.getBean(ref, net.sf.saxon.lib.ModuleURIResolver.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.xquery"); } } \ No newline at end of file diff --git a/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java b/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java index ee7cb4b366bd..f82d83b4186a 100644 --- a/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java +++ b/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureXQueryLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.xquery.customizer") - && target instanceof XQueryLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.xquery", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-scheduler-starter/src/main/java/org/apache/camel/component/scheduler/springboot/SchedulerComponentAutoConfiguration.java b/components-starter/camel-scheduler-starter/src/main/java/org/apache/camel/component/scheduler/springboot/SchedulerComponentAutoConfiguration.java index 6ba79dd49e4c..9d6030d12f4c 100644 --- a/components-starter/camel-scheduler-starter/src/main/java/org/apache/camel/component/scheduler/springboot/SchedulerComponentAutoConfiguration.java +++ b/components-starter/camel-scheduler-starter/src/main/java/org/apache/camel/component/scheduler/springboot/SchedulerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSchedulerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.scheduler.customizer") - && target instanceof SchedulerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.scheduler", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java b/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java index 8b8736869385..a537e7b0bf01 100644 --- a/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java +++ b/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSchematronComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.schematron.customizer") - && target instanceof SchematronComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.schematron", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentAutoConfiguration.java b/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentAutoConfiguration.java index 5474ceb0f37f..98c93378d731 100644 --- a/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentAutoConfiguration.java +++ b/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSedaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.seda.customizer") - && target instanceof SedaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.seda", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConverter.java b/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConverter.java index e947ce6bd4e0..d67334e27b69 100644 --- a/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConverter.java +++ b/components-starter/camel-seda-starter/src/main/java/org/apache/camel/component/seda/springboot/SedaComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.seda.BlockingQueueFactory": return applicationContext.getBean(ref, org.apache.camel.component.seda.BlockingQueueFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.seda"); } } \ No newline at end of file diff --git a/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java b/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java index c7a514217359..f2a8eae06762 100644 --- a/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java +++ b/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureServiceNowComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.servicenow.customizer") - && target instanceof ServiceNowComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.servicenow", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConverter.java b/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConverter.java index 1509051d9e33..04b72d010cd5 100644 --- a/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConverter.java +++ b/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.servicenow.ServiceNowConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.servicenow.ServiceNowConfiguration.class); - case "org.apache.cxf.transports.http.configuration.HTTPClientPolicy": return applicationContext.getBean(ref, org.apache.cxf.transports.http.configuration.HTTPClientPolicy.class); - case "com.fasterxml.jackson.databind.ObjectMapper": return applicationContext.getBean(ref, com.fasterxml.jackson.databind.ObjectMapper.class); - case "org.apache.cxf.configuration.security.ProxyAuthorizationPolicy": return applicationContext.getBean(ref, org.apache.cxf.configuration.security.ProxyAuthorizationPolicy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.servicenow"); } } \ No newline at end of file diff --git a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java index 003bf59f10a1..1a1fa55218e8 100644 --- a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java +++ b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureServletComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.servlet.customizer") - && target instanceof ServletComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.servlet", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConverter.java b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConverter.java index 4fe3227e4f30..aa70c522e53f 100644 --- a/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConverter.java +++ b/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.http.common.HttpRegistry": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpRegistry.class); - case "org.apache.camel.http.common.HttpBinding": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpBinding.class); - case "org.apache.camel.http.common.HttpConfiguration": return applicationContext.getBean(ref, org.apache.camel.http.common.HttpConfiguration.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.servlet"); } } \ No newline at end of file diff --git a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentAutoConfiguration.java b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentAutoConfiguration.java index d131076461aa..d6be7f2a35c3 100644 --- a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentAutoConfiguration.java +++ b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSjmsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.sjms.customizer") - && target instanceof SjmsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sjms", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConverter.java b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConverter.java index 40b1ab34ac35..a594b77c3a11 100644 --- a/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConverter.java +++ b/components-starter/camel-sjms-starter/src/main/java/org/apache/camel/component/sjms/springboot/SjmsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.jms.ConnectionFactory": return applicationContext.getBean(ref, jakarta.jms.ConnectionFactory.class); - case "org.apache.camel.component.sjms.jms.DestinationCreationStrategy": return applicationContext.getBean(ref, org.apache.camel.component.sjms.jms.DestinationCreationStrategy.class); - case "jakarta.jms.ExceptionListener": return applicationContext.getBean(ref, jakarta.jms.ExceptionListener.class); - case "org.apache.camel.component.sjms.jms.JmsKeyFormatStrategy": return applicationContext.getBean(ref, org.apache.camel.component.sjms.jms.JmsKeyFormatStrategy.class); - case "org.apache.camel.component.sjms.jms.MessageCreatedStrategy": return applicationContext.getBean(ref, org.apache.camel.component.sjms.jms.MessageCreatedStrategy.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.sjms"); } } \ No newline at end of file diff --git a/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java b/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java index 60de1157e7bf..c84cbc1c05a8 100644 --- a/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java +++ b/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSjms2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.sjms2.customizer") - && target instanceof Sjms2Component; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sjms2", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentConverter.java b/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentConverter.java index 6a4c9b3a67b8..2b4ec2a5722a 100644 --- a/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentConverter.java +++ b/components-starter/camel-sjms2-starter/src/main/java/org/apache/camel/component/sjms2/springboot/Sjms2ComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "jakarta.jms.ConnectionFactory": return applicationContext.getBean(ref, jakarta.jms.ConnectionFactory.class); - case "org.apache.camel.component.sjms.jms.DestinationCreationStrategy": return applicationContext.getBean(ref, org.apache.camel.component.sjms.jms.DestinationCreationStrategy.class); - case "jakarta.jms.ExceptionListener": return applicationContext.getBean(ref, jakarta.jms.ExceptionListener.class); - case "org.apache.camel.component.sjms.jms.JmsKeyFormatStrategy": return applicationContext.getBean(ref, org.apache.camel.component.sjms.jms.JmsKeyFormatStrategy.class); - case "org.apache.camel.component.sjms.jms.MessageCreatedStrategy": return applicationContext.getBean(ref, org.apache.camel.component.sjms.jms.MessageCreatedStrategy.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.sjms2"); } } \ No newline at end of file diff --git a/components-starter/camel-slack-starter/src/main/java/org/apache/camel/component/slack/springboot/SlackComponentAutoConfiguration.java b/components-starter/camel-slack-starter/src/main/java/org/apache/camel/component/slack/springboot/SlackComponentAutoConfiguration.java index 0b31235e753d..e0b6f3a3e039 100644 --- a/components-starter/camel-slack-starter/src/main/java/org/apache/camel/component/slack/springboot/SlackComponentAutoConfiguration.java +++ b/components-starter/camel-slack-starter/src/main/java/org/apache/camel/component/slack/springboot/SlackComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSlackComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.slack.customizer") - && target instanceof SlackComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.slack", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-smb-starter/src/main/java/org/apache/camel/component/smb/springboot/SmbComponentAutoConfiguration.java b/components-starter/camel-smb-starter/src/main/java/org/apache/camel/component/smb/springboot/SmbComponentAutoConfiguration.java index 2fb7266efaf5..0f09a5d8515a 100644 --- a/components-starter/camel-smb-starter/src/main/java/org/apache/camel/component/smb/springboot/SmbComponentAutoConfiguration.java +++ b/components-starter/camel-smb-starter/src/main/java/org/apache/camel/component/smb/springboot/SmbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSmbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.smb.customizer") - && target instanceof SmbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.smb", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentAutoConfiguration.java b/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentAutoConfiguration.java index dc5976ae22c7..cfb92286eb89 100644 --- a/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentAutoConfiguration.java +++ b/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSmooksComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.smooks.customizer") - && target instanceof SmooksComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.smooks", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentConverter.java b/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentConverter.java index f7076332bd7b..1ed7e059551a 100644 --- a/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentConverter.java +++ b/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/component/smooks/springboot/SmooksComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.smooks.SmooksFactory": return applicationContext.getBean(ref, org.smooks.SmooksFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.smooks"); } } \ No newline at end of file diff --git a/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/dataformat/smooks/springboot/SmooksDataFormatAutoConfiguration.java b/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/dataformat/smooks/springboot/SmooksDataFormatAutoConfiguration.java index 962564659118..3064b86dd9a5 100644 --- a/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/dataformat/smooks/springboot/SmooksDataFormatAutoConfiguration.java +++ b/components-starter/camel-smooks-starter/src/main/java/org/apache/camel/dataformat/smooks/springboot/SmooksDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureSmooksDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.smooks.customizer") - && target instanceof SmooksDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.smooks", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentAutoConfiguration.java b/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentAutoConfiguration.java index b199ee06a610..ee8a40473da6 100644 --- a/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentAutoConfiguration.java +++ b/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSmppComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.smpp.customizer") - && target instanceof SmppComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.smpp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConverter.java b/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConverter.java index 910806dba622..8f9a8fb72bb6 100644 --- a/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConverter.java +++ b/components-starter/camel-smpp-starter/src/main/java/org/apache/camel/component/smpp/springboot/SmppComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.smpp.SmppConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.smpp.SmppConfiguration.class); - case "org.jsmpp.session.SessionStateListener": return applicationContext.getBean(ref, org.jsmpp.session.SessionStateListener.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.smpp"); } } \ No newline at end of file diff --git a/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java b/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java index 4ac05f9fff09..14cda11ebfb4 100644 --- a/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java +++ b/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureSnakeYAMLDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.snake-yaml.customizer") - && target instanceof SnakeYAMLDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.snake-yaml", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-snmp-starter/src/main/java/org/apache/camel/component/snmp/springboot/SnmpComponentAutoConfiguration.java b/components-starter/camel-snmp-starter/src/main/java/org/apache/camel/component/snmp/springboot/SnmpComponentAutoConfiguration.java index a8b79f4a61dd..8b1273341492 100644 --- a/components-starter/camel-snmp-starter/src/main/java/org/apache/camel/component/snmp/springboot/SnmpComponentAutoConfiguration.java +++ b/components-starter/camel-snmp-starter/src/main/java/org/apache/camel/component/snmp/springboot/SnmpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSnmpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.snmp.customizer") - && target instanceof SnmpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.snmp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatAutoConfiguration.java b/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatAutoConfiguration.java index bddf85ab04f6..ee0f211b440d 100644 --- a/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatAutoConfiguration.java +++ b/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureSoapDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.soap.customizer") - && target instanceof SoapDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.soap", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatConverter.java b/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatConverter.java index 1cdab9aef405..4d78a7765387 100644 --- a/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatConverter.java +++ b/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.dataformat.soap.name.ElementNameStrategy": return applicationContext.getBean(ref, org.apache.camel.dataformat.soap.name.ElementNameStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.soap"); } } \ No newline at end of file diff --git a/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentAutoConfiguration.java b/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentAutoConfiguration.java index 36ca325b137c..24b2f463dfda 100644 --- a/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentAutoConfiguration.java +++ b/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSolrComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.solr.customizer") - && target instanceof SolrComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.solr", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentConverter.java b/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentConverter.java index 51c1fd14f7a3..7bc5218bbc67 100644 --- a/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentConverter.java +++ b/components-starter/camel-solr-starter/src/main/java/org/apache/camel/component/solr/springboot/SolrComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.solr.client.solrj.SolrClient": return applicationContext.getBean(ref, org.apache.solr.client.solrj.SolrClient.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.solr"); } \ No newline at end of file diff --git a/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentAutoConfiguration.java b/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentAutoConfiguration.java index 51206771aa14..395841073570 100644 --- a/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentAutoConfiguration.java +++ b/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSplunkHECComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.splunk-hec.customizer") - && target instanceof SplunkHECComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.splunk-hec", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentConverter.java b/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentConverter.java index 0be9c7f202d4..52d4d9cfff39 100644 --- a/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentConverter.java +++ b/components-starter/camel-splunk-hec-starter/src/main/java/org/apache/camel/component/splunkhec/springboot/SplunkHECComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.splunk-hec"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentAutoConfiguration.java b/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentAutoConfiguration.java index 5014818a0a5f..b191f5d316b6 100644 --- a/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentAutoConfiguration.java +++ b/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringAiChatComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-ai-chat.customizer") - && target instanceof SpringAiChatComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-chat", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentConverter.java b/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentConverter.java index 210ab1207364..da8855861818 100644 --- a/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentConverter.java +++ b/components-starter/camel-spring-ai-chat-starter/src/main/java/org/apache/camel/component/springai/chat/springboot/SpringAiChatComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.springframework.ai.chat.model.ChatModel": return applicationContext.getBean(ref, org.springframework.ai.chat.model.ChatModel.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-ai-chat"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentAutoConfiguration.java b/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentAutoConfiguration.java index ba33861cf371..68ceb188583f 100644 --- a/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentAutoConfiguration.java +++ b/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringAiEmbeddingsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-ai-embeddings.customizer") - && target instanceof SpringAiEmbeddingsComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-embeddings", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentConverter.java b/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentConverter.java index 6303586d4a67..0c061fd843c6 100644 --- a/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentConverter.java +++ b/components-starter/camel-spring-ai-embeddings-starter/src/main/java/org/apache/camel/component/springai/embeddings/springboot/SpringAiEmbeddingsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.springai.embeddings.SpringAiEmbeddingsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.springai.embeddings.SpringAiEmbeddingsConfiguration.class); - case "org.springframework.ai.embedding.EmbeddingModel": return applicationContext.getBean(ref, org.springframework.ai.embedding.EmbeddingModel.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-ai-embeddings"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentAutoConfiguration.java b/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentAutoConfiguration.java index f1be5ec96b94..607b7730c582 100644 --- a/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentAutoConfiguration.java +++ b/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringAiVectorStoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-ai-vector-store.customizer") - && target instanceof SpringAiVectorStoreComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-vector-store", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentConverter.java b/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentConverter.java index a857a1834702..d01b686c76dc 100644 --- a/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentConverter.java +++ b/components-starter/camel-spring-ai-vector-store-starter/src/main/java/org/apache/camel/component/springai/vectorstore/springboot/SpringAiVectorStoreComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,18 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.springai.vectorstore.SpringAiVectorStoreConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.springai.vectorstore.SpringAiVectorStoreConfiguration.class); - case "org.springframework.ai.vectorstore.VectorStore": return applicationContext.getBean(ref, org.springframework.ai.vectorstore.VectorStore.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-ai-vector-store"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java index 11bae8334167..87a77d675cc8 100644 --- a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java +++ b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringBatchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-batch.customizer") - && target instanceof SpringBatchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-batch", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConverter.java b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConverter.java index 2450774bb670..75f56d3ebdd0 100644 --- a/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConverter.java +++ b/components-starter/camel-spring-batch-starter/src/main/java/org/apache/camel/component/spring/batch/springboot/SpringBatchComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.springframework.batch.core.launch.JobLauncher": return applicationContext.getBean(ref, org.springframework.batch.core.launch.JobLauncher.class); - case "org.springframework.batch.core.configuration.JobRegistry": return applicationContext.getBean(ref, org.springframework.batch.core.configuration.JobRegistry.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-batch"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentAutoConfiguration.java b/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentAutoConfiguration.java index 04631bd99d0a..eb8eb69439d5 100644 --- a/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentAutoConfiguration.java +++ b/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringJdbcComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-jdbc.customizer") - && target instanceof SpringJdbcComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-jdbc", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentConverter.java b/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentConverter.java index dfcf16feabaa..a01da59d7fca 100644 --- a/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentConverter.java +++ b/components-starter/camel-spring-jdbc-starter/src/main/java/org/apache/camel/component/spring/jdbc/springboot/SpringJdbcComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.sql.DataSource": return applicationContext.getBean(ref, javax.sql.DataSource.class); - case "org.apache.camel.component.jdbc.ConnectionStrategy": return applicationContext.getBean(ref, org.apache.camel.component.jdbc.ConnectionStrategy.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-jdbc"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-ldap-starter/src/main/java/org/apache/camel/component/springldap/springboot/SpringLdapComponentAutoConfiguration.java b/components-starter/camel-spring-ldap-starter/src/main/java/org/apache/camel/component/springldap/springboot/SpringLdapComponentAutoConfiguration.java index 21cd33803590..733ea9df023f 100644 --- a/components-starter/camel-spring-ldap-starter/src/main/java/org/apache/camel/component/springldap/springboot/SpringLdapComponentAutoConfiguration.java +++ b/components-starter/camel-spring-ldap-starter/src/main/java/org/apache/camel/component/springldap/springboot/SpringLdapComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringLdapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-ldap.customizer") - && target instanceof SpringLdapComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ldap", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentAutoConfiguration.java b/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentAutoConfiguration.java index 89df16b05b4b..7b2456b706e3 100644 --- a/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentAutoConfiguration.java +++ b/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringRabbitMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-rabbitmq.customizer") - && target instanceof SpringRabbitMQComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-rabbitmq", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentConverter.java b/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentConverter.java index 29cbc848399f..fb329561e349 100644 --- a/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentConverter.java +++ b/components-starter/camel-spring-rabbitmq-starter/src/main/java/org/apache/camel/component/springrabbit/springboot/SpringRabbitMQComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -54,24 +55,5 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.springframework.amqp.core.AmqpAdmin": return applicationContext.getBean(ref, org.springframework.amqp.core.AmqpAdmin.class); - case "org.springframework.amqp.rabbit.connection.ConnectionFactory": return applicationContext.getBean(ref, org.springframework.amqp.rabbit.connection.ConnectionFactory.class); - case "org.springframework.util.ErrorHandler": return applicationContext.getBean(ref, org.springframework.util.ErrorHandler.class); - case "org.apache.camel.component.springrabbit.ListenerContainerFactory": return applicationContext.getBean(ref, org.apache.camel.component.springrabbit.ListenerContainerFactory.class); - case "org.springframework.retry.interceptor.RetryOperationsInterceptor": return applicationContext.getBean(ref, org.springframework.retry.interceptor.RetryOperationsInterceptor.class); - case "org.springframework.amqp.support.converter.MessageConverter": return applicationContext.getBean(ref, org.springframework.amqp.support.converter.MessageConverter.class); - case "org.apache.camel.component.springrabbit.MessagePropertiesConverter": return applicationContext.getBean(ref, org.apache.camel.component.springrabbit.MessagePropertiesConverter.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - } - return null; - } + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-rabbitmq"); } \ No newline at end of file diff --git a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java index 7515f677d69e..a4e8b8429c76 100644 --- a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java +++ b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureRedisComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-redis.customizer") - && target instanceof RedisComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-redis", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java index bc9269d4dea3..b52443a766f4 100644 --- a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java +++ b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.springframework.data.redis.core.RedisTemplate": return applicationContext.getBean(ref, org.springframework.data.redis.core.RedisTemplate.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-redis"); } } \ No newline at end of file diff --git a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java index f3728f378a2e..2cf73b5cdb9e 100644 --- a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java +++ b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/component/event/springboot/EventComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureEventComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-event.customizer") - && target instanceof EventComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-event", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/language/spel/springboot/SpelLanguageAutoConfiguration.java b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/language/spel/springboot/SpelLanguageAutoConfiguration.java index 1f6faa459447..f6748e947ab9 100644 --- a/components-starter/camel-spring-starter/src/main/java/org/apache/camel/language/spel/springboot/SpelLanguageAutoConfiguration.java +++ b/components-starter/camel-spring-starter/src/main/java/org/apache/camel/language/spel/springboot/SpelLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureSpelLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.spel.customizer") - && target instanceof SpelLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.spel", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-spring-ws-starter/src/main/java/org/apache/camel/component/spring/ws/springboot/SpringWebserviceComponentAutoConfiguration.java b/components-starter/camel-spring-ws-starter/src/main/java/org/apache/camel/component/spring/ws/springboot/SpringWebserviceComponentAutoConfiguration.java index 36f143e61410..c2e6b8b0a7f7 100644 --- a/components-starter/camel-spring-ws-starter/src/main/java/org/apache/camel/component/spring/ws/springboot/SpringWebserviceComponentAutoConfiguration.java +++ b/components-starter/camel-spring-ws-starter/src/main/java/org/apache/camel/component/spring/ws/springboot/SpringWebserviceComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSpringWebserviceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.spring-ws.customizer") - && target instanceof SpringWebserviceComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ws", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java index a7f8bf0c85ab..b6720836a52a 100644 --- a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java +++ b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSqlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.sql.customizer") - && target instanceof SqlComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sql", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentConverter.java b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentConverter.java index 7f125d62490c..07ecebbc1034 100644 --- a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentConverter.java +++ b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/springboot/SqlComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.sql.DataSource": return applicationContext.getBean(ref, javax.sql.DataSource.class); - case "org.apache.camel.component.sql.RowMapperFactory": return applicationContext.getBean(ref, org.apache.camel.component.sql.RowMapperFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.sql"); } } \ No newline at end of file diff --git a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java index b9ea4f0e4a25..162f99b715bd 100644 --- a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java +++ b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSqlStoredComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.sql-stored.customizer") - && target instanceof SqlStoredComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sql-stored", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentConverter.java b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentConverter.java index 3b8401849045..9400ec1bea75 100644 --- a/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentConverter.java +++ b/components-starter/camel-sql-starter/src/main/java/org/apache/camel/component/sql/stored/springboot/SqlStoredComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.sql.DataSource": return applicationContext.getBean(ref, javax.sql.DataSource.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.sql-stored"); } } \ No newline at end of file diff --git a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java index b1c73eccb162..63d46f7490c8 100644 --- a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java +++ b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureSshComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.ssh.customizer") - && target instanceof SshComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ssh", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConverter.java b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConverter.java index 07e18c1fe896..063f5376aec6 100644 --- a/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConverter.java +++ b/components-starter/camel-ssh-starter/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.sshd.client.ClientBuilder": return applicationContext.getBean(ref, org.apache.sshd.client.ClientBuilder.class); - case "org.apache.camel.component.ssh.SshConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ssh.SshConfiguration.class); - case "org.apache.sshd.common.keyprovider.KeyPairProvider": return applicationContext.getBean(ref, org.apache.sshd.common.keyprovider.KeyPairProvider.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ssh"); } } \ No newline at end of file diff --git a/components-starter/camel-stax-starter/src/main/java/org/apache/camel/component/stax/springboot/StAXComponentAutoConfiguration.java b/components-starter/camel-stax-starter/src/main/java/org/apache/camel/component/stax/springboot/StAXComponentAutoConfiguration.java index 989410b0ea31..c61af0f4d0eb 100644 --- a/components-starter/camel-stax-starter/src/main/java/org/apache/camel/component/stax/springboot/StAXComponentAutoConfiguration.java +++ b/components-starter/camel-stax-starter/src/main/java/org/apache/camel/component/stax/springboot/StAXComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStAXComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.stax.customizer") - && target instanceof StAXComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stax", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stax-starter/src/main/java/org/apache/camel/language/xtokenizer/springboot/XMLTokenizeLanguageAutoConfiguration.java b/components-starter/camel-stax-starter/src/main/java/org/apache/camel/language/xtokenizer/springboot/XMLTokenizeLanguageAutoConfiguration.java index 827b5c1be2d3..ff25de5ad421 100644 --- a/components-starter/camel-stax-starter/src/main/java/org/apache/camel/language/xtokenizer/springboot/XMLTokenizeLanguageAutoConfiguration.java +++ b/components-starter/camel-stax-starter/src/main/java/org/apache/camel/language/xtokenizer/springboot/XMLTokenizeLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureXMLTokenizeLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.xtokenize.customizer") - && target instanceof XMLTokenizeLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.xtokenize", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentAutoConfiguration.java b/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentAutoConfiguration.java index 331b303f97ef..19c764ec8015 100644 --- a/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentAutoConfiguration.java +++ b/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStitchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.stitch.customizer") - && target instanceof StitchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stitch", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentConverter.java b/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentConverter.java index 6d038af069ec..62c3d97944d6 100644 --- a/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentConverter.java +++ b/components-starter/camel-stitch-starter/src/main/java/org/apache/camel/component/stitch/springboot/StitchComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -51,21 +52,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.stitch.StitchConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.stitch.StitchConfiguration.class); - case "org.apache.camel.component.stitch.client.models.StitchSchema": return applicationContext.getBean(ref, org.apache.camel.component.stitch.client.models.StitchSchema.class); - case "reactor.netty.resources.ConnectionProvider": return applicationContext.getBean(ref, reactor.netty.resources.ConnectionProvider.class); - case "reactor.netty.http.client.HttpClient": return applicationContext.getBean(ref, reactor.netty.http.client.HttpClient.class); - case "org.apache.camel.component.stitch.client.StitchClient": return applicationContext.getBean(ref, org.apache.camel.component.stitch.client.StitchClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.stitch"); } } \ No newline at end of file diff --git a/components-starter/camel-stream-starter/src/main/java/org/apache/camel/component/stream/springboot/StreamComponentAutoConfiguration.java b/components-starter/camel-stream-starter/src/main/java/org/apache/camel/component/stream/springboot/StreamComponentAutoConfiguration.java index a6f6f109f5cf..41f554828f69 100644 --- a/components-starter/camel-stream-starter/src/main/java/org/apache/camel/component/stream/springboot/StreamComponentAutoConfiguration.java +++ b/components-starter/camel-stream-starter/src/main/java/org/apache/camel/component/stream/springboot/StreamComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.stream.customizer") - && target instanceof StreamComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stream", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java b/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java index 3fa0f1dc8370..8fb7ca2811ae 100644 --- a/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java +++ b/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStringTemplateComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.string-template.customizer") - && target instanceof StringTemplateComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.string-template", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stripe-starter/src/main/java/org/apache/camel/component/stripe/springboot/StripeComponentAutoConfiguration.java b/components-starter/camel-stripe-starter/src/main/java/org/apache/camel/component/stripe/springboot/StripeComponentAutoConfiguration.java index d36bb243edef..7fad2eb9ddee 100644 --- a/components-starter/camel-stripe-starter/src/main/java/org/apache/camel/component/stripe/springboot/StripeComponentAutoConfiguration.java +++ b/components-starter/camel-stripe-starter/src/main/java/org/apache/camel/component/stripe/springboot/StripeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStripeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.stripe.customizer") - && target instanceof StripeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stripe", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentAutoConfiguration.java b/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentAutoConfiguration.java index d7ae3fb56f2f..45fffe37d436 100644 --- a/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentAutoConfiguration.java +++ b/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureStubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.stub.customizer") - && target instanceof StubComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stub", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConverter.java b/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConverter.java index 06ae73b05d5e..94c3d5ca4dd3 100644 --- a/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConverter.java +++ b/components-starter/camel-stub-starter/src/main/java/org/apache/camel/component/stub/springboot/StubComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.seda.BlockingQueueFactory": return applicationContext.getBean(ref, org.apache.camel.component.seda.BlockingQueueFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.stub"); } } \ No newline at end of file diff --git a/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mt/springboot/SwiftMtDataFormatAutoConfiguration.java b/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mt/springboot/SwiftMtDataFormatAutoConfiguration.java index b56f419d0fed..71700095753d 100644 --- a/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mt/springboot/SwiftMtDataFormatAutoConfiguration.java +++ b/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mt/springboot/SwiftMtDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureSwiftMtDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.swift-mt.customizer") - && target instanceof SwiftMtDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.swift-mt", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatAutoConfiguration.java b/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatAutoConfiguration.java index 8b1fac55791e..2d496ae29a53 100644 --- a/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatAutoConfiguration.java +++ b/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureSwiftMxDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.swift-mx.customizer") - && target instanceof SwiftMxDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.swift-mx", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatConverter.java b/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatConverter.java index 2d1780ca2c6a..47ceb9da48f2 100644 --- a/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatConverter.java +++ b/components-starter/camel-swift-starter/src/main/java/org/apache/camel/dataformat/swift/mx/springboot/SwiftMxDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "com.prowidesoftware.swift.model.MxId": return applicationContext.getBean(ref, com.prowidesoftware.swift.model.MxId.class); - case "com.prowidesoftware.swift.model.mx.MxReadConfiguration": return applicationContext.getBean(ref, com.prowidesoftware.swift.model.mx.MxReadConfiguration.class); - case "com.prowidesoftware.swift.model.mx.MxWriteConfiguration": return applicationContext.getBean(ref, com.prowidesoftware.swift.model.mx.MxWriteConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.swift-mx"); } } \ No newline at end of file diff --git a/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java b/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java index 393cbb918dcc..ac3fb0c08d6d 100644 --- a/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java +++ b/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureSyslogDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.syslog.customizer") - && target instanceof SyslogDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.syslog", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentAutoConfiguration.java b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentAutoConfiguration.java index fb0b3020675d..a426beab9e35 100644 --- a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentAutoConfiguration.java +++ b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTahuEdgeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.tahu-edge.customizer") - && target instanceof TahuEdgeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tahu-edge", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentConverter.java b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentConverter.java index e123208f8674..4454a6d3e494 100644 --- a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentConverter.java +++ b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuEdgeComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.tahu.TahuConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.tahu.TahuConfiguration.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.tahu-edge"); } } \ No newline at end of file diff --git a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentAutoConfiguration.java b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentAutoConfiguration.java index e98ca3c50c61..b8fce652a691 100644 --- a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentAutoConfiguration.java +++ b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTahuHostComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.tahu-host.customizer") - && target instanceof TahuHostComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tahu-host", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentConverter.java b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentConverter.java index 982f67b98215..761358b60029 100644 --- a/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentConverter.java +++ b/components-starter/camel-tahu-starter/src/main/java/org/apache/camel/component/tahu/springboot/TahuHostComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.tahu.TahuConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.tahu.TahuConfiguration.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.tahu-host"); } } \ No newline at end of file diff --git a/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java b/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java index f7883e8ed463..f2d5b1c2d585 100644 --- a/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java +++ b/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureTarFileDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.tar-file.customizer") - && target instanceof TarFileDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.tar-file", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java b/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java index b5f6e9a29123..e64926a170a0 100644 --- a/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java +++ b/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTelegramComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.telegram.customizer") - && target instanceof TelegramComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.telegram", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConverter.java b/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConverter.java index f1c0f2777b3d..3ba65eef38e3 100644 --- a/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConverter.java +++ b/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "java.net.http.HttpClient": return applicationContext.getBean(ref, java.net.http.HttpClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.telegram"); } } \ No newline at end of file diff --git a/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentAutoConfiguration.java b/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentAutoConfiguration.java index 81f6841cd974..33f729796017 100644 --- a/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentAutoConfiguration.java +++ b/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTensorFlowServingComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.tensorflow-serving.customizer") - && target instanceof TensorFlowServingComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tensorflow-serving", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentConverter.java b/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentConverter.java index 210a10cd83db..38c19003c07e 100644 --- a/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentConverter.java +++ b/components-starter/camel-tensorflow-serving-starter/src/main/java/org/apache/camel/component/tensorflow/serving/springboot/TensorFlowServingComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.tensorflow.serving.TensorFlowServingConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.tensorflow.serving.TensorFlowServingConfiguration.class); - case "io.grpc.ChannelCredentials": return applicationContext.getBean(ref, io.grpc.ChannelCredentials.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.tensorflow-serving"); } } \ No newline at end of file diff --git a/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/component/thrift/springboot/ThriftComponentAutoConfiguration.java b/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/component/thrift/springboot/ThriftComponentAutoConfiguration.java index 6c60f36de88e..7a3a8ed696cf 100644 --- a/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/component/thrift/springboot/ThriftComponentAutoConfiguration.java +++ b/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/component/thrift/springboot/ThriftComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureThriftComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.thrift.customizer") - && target instanceof ThriftComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.thrift", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/dataformat/thrift/springboot/ThriftDataFormatAutoConfiguration.java b/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/dataformat/thrift/springboot/ThriftDataFormatAutoConfiguration.java index a7034265579d..daf49e69a1a5 100644 --- a/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/dataformat/thrift/springboot/ThriftDataFormatAutoConfiguration.java +++ b/components-starter/camel-thrift-starter/src/main/java/org/apache/camel/dataformat/thrift/springboot/ThriftDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureThriftDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.thrift.customizer") - && target instanceof ThriftDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.thrift", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-thymeleaf-starter/src/main/java/org/apache/camel/component/thymeleaf/springboot/ThymeleafComponentAutoConfiguration.java b/components-starter/camel-thymeleaf-starter/src/main/java/org/apache/camel/component/thymeleaf/springboot/ThymeleafComponentAutoConfiguration.java index 70ebee319dee..3085ddc5a346 100644 --- a/components-starter/camel-thymeleaf-starter/src/main/java/org/apache/camel/component/thymeleaf/springboot/ThymeleafComponentAutoConfiguration.java +++ b/components-starter/camel-thymeleaf-starter/src/main/java/org/apache/camel/component/thymeleaf/springboot/ThymeleafComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureThymeleafComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.thymeleaf.customizer") - && target instanceof ThymeleafComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.thymeleaf", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java b/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java index e33f71b24175..d045537fca34 100644 --- a/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java +++ b/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTikaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.tika.customizer") - && target instanceof TikaComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tika", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-timer-starter/src/main/java/org/apache/camel/component/timer/springboot/TimerComponentAutoConfiguration.java b/components-starter/camel-timer-starter/src/main/java/org/apache/camel/component/timer/springboot/TimerComponentAutoConfiguration.java index 91215a46e2c7..ce1070ce2589 100644 --- a/components-starter/camel-timer-starter/src/main/java/org/apache/camel/component/timer/springboot/TimerComponentAutoConfiguration.java +++ b/components-starter/camel-timer-starter/src/main/java/org/apache/camel/component/timer/springboot/TimerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTimerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.timer.customizer") - && target instanceof TimerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.timer", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentAutoConfiguration.java b/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentAutoConfiguration.java index 602c6a663e95..c017cf67935c 100644 --- a/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentAutoConfiguration.java +++ b/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTwilioComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.twilio.customizer") - && target instanceof TwilioComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twilio", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentConverter.java b/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentConverter.java index 16c6aa6aae76..faff41b622b9 100644 --- a/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentConverter.java +++ b/components-starter/camel-twilio-starter/src/main/java/org/apache/camel/component/twilio/springboot/TwilioComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.twilio.TwilioConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.twilio.TwilioConfiguration.class); - case "com.twilio.http.TwilioRestClient": return applicationContext.getBean(ref, com.twilio.http.TwilioRestClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.twilio"); } } \ No newline at end of file diff --git a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/directmessage/springboot/TwitterDirectMessageComponentAutoConfiguration.java b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/directmessage/springboot/TwitterDirectMessageComponentAutoConfiguration.java index 0e4b0a39f1f4..f75801d9a6ae 100644 --- a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/directmessage/springboot/TwitterDirectMessageComponentAutoConfiguration.java +++ b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/directmessage/springboot/TwitterDirectMessageComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTwitterDirectMessageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.twitter-directmessage.customizer") - && target instanceof TwitterDirectMessageComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twitter-directmessage", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java index 29aa6e9f6b87..a71dbfc6ce93 100644 --- a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java +++ b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/search/springboot/TwitterSearchComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTwitterSearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.twitter-search.customizer") - && target instanceof TwitterSearchComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twitter-search", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java index 4e0676065847..c3c0afa34996 100644 --- a/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java +++ b/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/timeline/springboot/TwitterTimelineComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureTwitterTimelineComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.twitter-timeline.customizer") - && target instanceof TwitterTimelineComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twitter-timeline", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentAutoConfiguration.java b/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentAutoConfiguration.java index 060317c3222d..6c98b9b1a0a6 100644 --- a/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentAutoConfiguration.java +++ b/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureUndertowComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.undertow.customizer") - && target instanceof UndertowComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.undertow", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConverter.java b/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConverter.java index db68cf5f9e75..2426aefe6105 100644 --- a/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConverter.java +++ b/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.undertow.UndertowHostOptions": return applicationContext.getBean(ref, org.apache.camel.component.undertow.UndertowHostOptions.class); - case "org.apache.camel.component.undertow.UndertowHttpBinding": return applicationContext.getBean(ref, org.apache.camel.component.undertow.UndertowHttpBinding.class); - case "org.apache.camel.component.undertow.spi.UndertowSecurityProvider": return applicationContext.getBean(ref, org.apache.camel.component.undertow.spi.UndertowSecurityProvider.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.undertow"); } } \ No newline at end of file diff --git a/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java b/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java index 434348d2a84c..43d5dc984cfa 100644 --- a/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java +++ b/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureUniVocityCsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.univocity-csv.customizer") - && target instanceof UniVocityCsvDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.univocity-csv", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedDataFormatAutoConfiguration.java b/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedDataFormatAutoConfiguration.java index 2477269e1bf5..4cd3a235a326 100644 --- a/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedDataFormatAutoConfiguration.java +++ b/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureUniVocityFixedDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.univocity-fixed.customizer") - && target instanceof UniVocityFixedDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.univocity-fixed", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java b/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java index a6e2a69d1197..376036659e0a 100644 --- a/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java +++ b/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureUniVocityTsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.univocity-tsv.customizer") - && target instanceof UniVocityTsvDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.univocity-tsv", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentAutoConfiguration.java b/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentAutoConfiguration.java index 5a503a322743..4141cb1cdeab 100644 --- a/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentAutoConfiguration.java +++ b/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureValidatorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.validator.customizer") - && target instanceof ValidatorComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.validator", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentConverter.java b/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentConverter.java index 97a791837f0a..bc3df88e2405 100644 --- a/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentConverter.java +++ b/components-starter/camel-validator-starter/src/main/java/org/apache/camel/component/validator/springboot/ValidatorComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.validator.ValidatorResourceResolverFactory": return applicationContext.getBean(ref, org.apache.camel.component.validator.ValidatorResourceResolverFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.validator"); } } \ No newline at end of file diff --git a/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentAutoConfiguration.java b/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentAutoConfiguration.java index 2266de0c033b..34f5ce2f6fa8 100644 --- a/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentAutoConfiguration.java +++ b/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureVelocityComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.velocity.customizer") - && target instanceof VelocityComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.velocity", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConverter.java b/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConverter.java index 047158f0686f..0f6ffc6e3812 100644 --- a/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConverter.java +++ b/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.velocity.app.VelocityEngine": return applicationContext.getBean(ref, org.apache.velocity.app.VelocityEngine.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.velocity"); } } \ No newline at end of file diff --git a/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentAutoConfiguration.java b/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentAutoConfiguration.java index 54f4e02829be..7c3e5aed5f0d 100644 --- a/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentAutoConfiguration.java +++ b/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureVertxHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.vertx-http.customizer") - && target instanceof VertxHttpComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.vertx-http", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentConverter.java b/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentConverter.java index 0f5e6e86f965..37511d408907 100644 --- a/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentConverter.java +++ b/components-starter/camel-vertx-http-starter/src/main/java/org/apache/camel/component/vertx/http/springboot/VertxHttpComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.vertx.core.Vertx": return applicationContext.getBean(ref, io.vertx.core.Vertx.class); - case "org.apache.camel.component.vertx.http.VertxHttpBinding": return applicationContext.getBean(ref, org.apache.camel.component.vertx.http.VertxHttpBinding.class); - case "io.vertx.core.VertxOptions": return applicationContext.getBean(ref, io.vertx.core.VertxOptions.class); - case "io.vertx.ext.web.client.WebClientOptions": return applicationContext.getBean(ref, io.vertx.ext.web.client.WebClientOptions.class); - case "org.apache.camel.spi.HeaderFilterStrategy": return applicationContext.getBean(ref, org.apache.camel.spi.HeaderFilterStrategy.class); - case "org.apache.camel.support.jsse.SSLContextParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.SSLContextParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.vertx-http"); } } \ No newline at end of file diff --git a/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentAutoConfiguration.java b/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentAutoConfiguration.java index fe4a486b3897..7b312f9c8860 100644 --- a/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentAutoConfiguration.java +++ b/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureVertxComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.vertx.customizer") - && target instanceof VertxComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.vertx", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConverter.java b/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConverter.java index e077e71cb97b..271cc50a099d 100644 --- a/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConverter.java +++ b/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.vertx.core.Vertx": return applicationContext.getBean(ref, io.vertx.core.Vertx.class); - case "io.vertx.core.VertxOptions": return applicationContext.getBean(ref, io.vertx.core.VertxOptions.class); - case "io.vertx.core.impl.VertxBuilder": return applicationContext.getBean(ref, io.vertx.core.impl.VertxBuilder.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.vertx"); } } \ No newline at end of file diff --git a/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentAutoConfiguration.java b/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentAutoConfiguration.java index 0b4e0dfa7b94..69979e627f24 100644 --- a/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentAutoConfiguration.java +++ b/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureVertxWebsocketComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.vertx-websocket.customizer") - && target instanceof VertxWebsocketComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.vertx-websocket", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentConverter.java b/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentConverter.java index 441984b8a335..fe7dc0f93d49 100644 --- a/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentConverter.java +++ b/components-starter/camel-vertx-websocket-starter/src/main/java/org/apache/camel/component/vertx/websocket/springboot/VertxWebsocketComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "io.vertx.ext.web.Router": return applicationContext.getBean(ref, io.vertx.ext.web.Router.class); - case "io.vertx.core.Vertx": return applicationContext.getBean(ref, io.vertx.core.Vertx.class); - case "io.vertx.core.VertxOptions": return applicationContext.getBean(ref, io.vertx.core.VertxOptions.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.vertx-websocket"); } } \ No newline at end of file diff --git a/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/component/wasm/springboot/WasmComponentAutoConfiguration.java b/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/component/wasm/springboot/WasmComponentAutoConfiguration.java index 13a9856edefb..c5ac50441783 100644 --- a/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/component/wasm/springboot/WasmComponentAutoConfiguration.java +++ b/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/component/wasm/springboot/WasmComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWasmComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.wasm.customizer") - && target instanceof WasmComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.wasm", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/language/wasm/springboot/WasmLanguageAutoConfiguration.java b/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/language/wasm/springboot/WasmLanguageAutoConfiguration.java index 14b6b4b6afd6..5035d58337b1 100644 --- a/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/language/wasm/springboot/WasmLanguageAutoConfiguration.java +++ b/components-starter/camel-wasm-starter/src/main/java/org/apache/camel/language/wasm/springboot/WasmLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureWasmLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.wasm.customizer") - && target instanceof WasmLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.wasm", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java b/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java index 5eff622cf230..5da90414d7a2 100644 --- a/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java +++ b/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWeatherComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.weather.customizer") - && target instanceof WeatherComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.weather", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentAutoConfiguration.java b/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentAutoConfiguration.java index 522fd46cbe3e..8dc2f691a29f 100644 --- a/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentAutoConfiguration.java +++ b/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWeaviateVectorDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.weaviate.customizer") - && target instanceof WeaviateVectorDbComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.weaviate", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentConverter.java b/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentConverter.java index db4617295690..41c45e339605 100644 --- a/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentConverter.java +++ b/components-starter/camel-weaviate-starter/src/main/java/org/apache/camel/component/weaviate/springboot/WeaviateVectorDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.weaviate.WeaviateVectorDbConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.weaviate"); } } \ No newline at end of file diff --git a/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentAutoConfiguration.java b/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentAutoConfiguration.java index 399fc131853a..55047184e09d 100644 --- a/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentAutoConfiguration.java +++ b/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWeb3jComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.web3j.customizer") - && target instanceof Web3jComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.web3j", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentConverter.java b/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentConverter.java index b7205acf72c6..a99ec14cdaff 100644 --- a/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentConverter.java +++ b/components-starter/camel-web3j-starter/src/main/java/org/apache/camel/component/web3j/springboot/Web3jComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.web3j.Web3jConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.web3j.Web3jConfiguration.class); - case "java.math.BigInteger": return applicationContext.getBean(ref, java.math.BigInteger.class); - case "org.web3j.protocol.Web3j": return applicationContext.getBean(ref, org.web3j.protocol.Web3j.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.web3j"); } } \ No newline at end of file diff --git a/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentAutoConfiguration.java b/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentAutoConfiguration.java index 838054974570..95ff5c534df8 100644 --- a/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentAutoConfiguration.java +++ b/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWebhookComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.webhook.customizer") - && target instanceof WebhookComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.webhook", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentConverter.java b/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentConverter.java index db7541d05a9d..439fde0a6b7e 100644 --- a/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentConverter.java +++ b/components-starter/camel-webhook-starter/src/main/java/org/apache/camel/component/webhook/springboot/WebhookComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.webhook.WebhookConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.webhook.WebhookConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.webhook"); } } \ No newline at end of file diff --git a/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentAutoConfiguration.java b/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentAutoConfiguration.java index 62b8aa10cf75..337711407899 100644 --- a/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentAutoConfiguration.java +++ b/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWhatsAppComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.whatsapp.customizer") - && target instanceof WhatsAppComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.whatsapp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentConverter.java b/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentConverter.java index 4b58d594f233..12e8585d3d5b 100644 --- a/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentConverter.java +++ b/components-starter/camel-whatsapp-starter/src/main/java/org/apache/camel/component/whatsapp/springboot/WhatsAppComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "java.net.http.HttpClient": return applicationContext.getBean(ref, java.net.http.HttpClient.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.whatsapp"); } } \ No newline at end of file diff --git a/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentAutoConfiguration.java b/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentAutoConfiguration.java index 506c8e492d06..489b8ed8bbab 100644 --- a/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentAutoConfiguration.java +++ b/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWordpressComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.wordpress.customizer") - && target instanceof WordpressComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.wordpress", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentConverter.java b/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentConverter.java index 41b3c9dfb72e..dec39a211924 100644 --- a/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentConverter.java +++ b/components-starter/camel-wordpress-starter/src/main/java/org/apache/camel/component/wordpress/springboot/WordpressComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.wordpress.WordpressConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.wordpress.WordpressConfiguration.class); - case "org.apache.camel.component.wordpress.api.model.SearchCriteria": return applicationContext.getBean(ref, org.apache.camel.component.wordpress.api.model.SearchCriteria.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.wordpress"); } } \ No newline at end of file diff --git a/components-starter/camel-workday-starter/src/main/java/org/apache/camel/component/workday/springboot/WorkdayComponentAutoConfiguration.java b/components-starter/camel-workday-starter/src/main/java/org/apache/camel/component/workday/springboot/WorkdayComponentAutoConfiguration.java index 45dcd2445c42..950b17edbad0 100644 --- a/components-starter/camel-workday-starter/src/main/java/org/apache/camel/component/workday/springboot/WorkdayComponentAutoConfiguration.java +++ b/components-starter/camel-workday-starter/src/main/java/org/apache/camel/component/workday/springboot/WorkdayComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureWorkdayComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.workday.customizer") - && target instanceof WorkdayComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.workday", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xchange-starter/src/main/java/org/apache/camel/component/xchange/springboot/XChangeComponentAutoConfiguration.java b/components-starter/camel-xchange-starter/src/main/java/org/apache/camel/component/xchange/springboot/XChangeComponentAutoConfiguration.java index 20f8b08bf7bb..56243f6e410b 100644 --- a/components-starter/camel-xchange-starter/src/main/java/org/apache/camel/component/xchange/springboot/XChangeComponentAutoConfiguration.java +++ b/components-starter/camel-xchange-starter/src/main/java/org/apache/camel/component/xchange/springboot/XChangeComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXChangeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xchange.customizer") - && target instanceof XChangeComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xchange", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentAutoConfiguration.java b/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentAutoConfiguration.java index 48bc3eacefdd..e56861b82ab4 100644 --- a/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentAutoConfiguration.java +++ b/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXJComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xj.customizer") - && target instanceof XJComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xj", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentConverter.java b/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentConverter.java index 82df4b8e72bf..21af83714c76 100644 --- a/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentConverter.java +++ b/components-starter/camel-xj-starter/src/main/java/org/apache/camel/component/xj/springboot/XJComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "net.sf.saxon.Configuration": return applicationContext.getBean(ref, net.sf.saxon.Configuration.class); - case "org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy": return applicationContext.getBean(ref, org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy.class); - case "javax.xml.transform.URIResolver": return applicationContext.getBean(ref, javax.xml.transform.URIResolver.class); - case "org.apache.camel.component.xslt.XsltUriResolverFactory": return applicationContext.getBean(ref, org.apache.camel.component.xslt.XsltUriResolverFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.xj"); } } \ No newline at end of file diff --git a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentAutoConfiguration.java b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentAutoConfiguration.java index 165695715392..91a195676850 100644 --- a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentAutoConfiguration.java +++ b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXmlSignerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xmlsecurity-sign.customizer") - && target instanceof XmlSignerComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xmlsecurity-sign", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentConverter.java b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentConverter.java index 4175d6bffc0a..0a12385f5158 100644 --- a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentConverter.java +++ b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignerComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.xml.crypto.AlgorithmMethod": return applicationContext.getBean(ref, javax.xml.crypto.AlgorithmMethod.class); - case "org.apache.camel.component.xmlsecurity.api.KeyAccessor": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.api.KeyAccessor.class); - case "javax.xml.crypto.dsig.spec.XPathFilterParameterSpec": return applicationContext.getBean(ref, javax.xml.crypto.dsig.spec.XPathFilterParameterSpec.class); - case "org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.api.XmlSignatureProperties.class); - case "org.apache.camel.component.xmlsecurity.processor.XmlSignerConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.processor.XmlSignerConfiguration.class); - case "javax.xml.crypto.URIDereferencer": return applicationContext.getBean(ref, javax.xml.crypto.URIDereferencer.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.xmlsecurity-sign"); } } \ No newline at end of file diff --git a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentAutoConfiguration.java b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentAutoConfiguration.java index ba7f55f3b3b7..cb4347af14df 100644 --- a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentAutoConfiguration.java +++ b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXmlVerifierComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xmlsecurity-verify.customizer") - && target instanceof XmlVerifierComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xmlsecurity-verify", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentConverter.java b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentConverter.java index f0655c918647..75e1ab66973f 100644 --- a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentConverter.java +++ b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlVerifierComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -52,22 +53,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "javax.xml.crypto.KeySelector": return applicationContext.getBean(ref, javax.xml.crypto.KeySelector.class); - case "org.apache.camel.component.xmlsecurity.api.ValidationFailedHandler": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.api.ValidationFailedHandler.class); - case "org.apache.camel.component.xmlsecurity.api.XmlSignature2Message": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.api.XmlSignature2Message.class); - case "org.apache.camel.component.xmlsecurity.api.XmlSignatureChecker": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.api.XmlSignatureChecker.class); - case "javax.xml.crypto.URIDereferencer": return applicationContext.getBean(ref, javax.xml.crypto.URIDereferencer.class); - case "org.apache.camel.component.xmlsecurity.processor.XmlVerifierConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.xmlsecurity.processor.XmlVerifierConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.xmlsecurity-verify"); } } \ No newline at end of file diff --git a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java index 2b427cecb282..36ad9c0690bd 100644 --- a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java +++ b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureXMLSecurityDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.xml-security.customizer") - && target instanceof XMLSecurityDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.xml-security", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatConverter.java b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatConverter.java index 92b79bb7c8b5..01c79d1ecd95 100644 --- a/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatConverter.java +++ b/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatConverter.java @@ -18,7 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; -import org.apache.camel.CamelContext; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.support.jsse.KeyStoreParameters": return applicationContext.getBean(ref, org.apache.camel.support.jsse.KeyStoreParameters.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.dataformat.xml-security"); } } \ No newline at end of file diff --git a/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java b/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java index 5a469e9c3a48..0f3895e8eeda 100644 --- a/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java +++ b/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXmppComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xmpp.customizer") - && target instanceof XmppComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xmpp", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xpath-starter/src/main/java/org/apache/camel/language/xpath/springboot/XPathLanguageAutoConfiguration.java b/components-starter/camel-xpath-starter/src/main/java/org/apache/camel/language/xpath/springboot/XPathLanguageAutoConfiguration.java index b2e05e4e88f7..282c14588483 100644 --- a/components-starter/camel-xpath-starter/src/main/java/org/apache/camel/language/xpath/springboot/XPathLanguageAutoConfiguration.java +++ b/components-starter/camel-xpath-starter/src/main/java/org/apache/camel/language/xpath/springboot/XPathLanguageAutoConfiguration.java @@ -63,16 +63,6 @@ public org.apache.camel.spi.LanguageCustomizer configureXPathLanguage() { return new LanguageCustomizer() { @Override public void configure(String name, Language target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Language target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.language.customizer", - "camel.language.xpath.customizer") - && target instanceof XPathLanguage; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.language.xpath", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentAutoConfiguration.java b/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentAutoConfiguration.java index 56a4883d1241..b119d110ec62 100644 --- a/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentAutoConfiguration.java +++ b/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXsltSaxonComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xslt-saxon.customizer") - && target instanceof XsltSaxonComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xslt-saxon", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentConverter.java b/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentConverter.java index cbb28d26cd2d..367278a578a6 100644 --- a/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentConverter.java +++ b/components-starter/camel-xslt-saxon-starter/src/main/java/org/apache/camel/component/xslt/saxon/springboot/XsltSaxonComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -50,20 +51,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "net.sf.saxon.Configuration": return applicationContext.getBean(ref, net.sf.saxon.Configuration.class); - case "org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy": return applicationContext.getBean(ref, org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy.class); - case "javax.xml.transform.URIResolver": return applicationContext.getBean(ref, javax.xml.transform.URIResolver.class); - case "org.apache.camel.component.xslt.XsltUriResolverFactory": return applicationContext.getBean(ref, org.apache.camel.component.xslt.XsltUriResolverFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.xslt-saxon"); } } \ No newline at end of file diff --git a/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentAutoConfiguration.java b/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentAutoConfiguration.java index 11735faa87cd..18bc674b8c4b 100644 --- a/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentAutoConfiguration.java +++ b/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureXsltComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.xslt.customizer") - && target instanceof XsltComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xslt", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentConverter.java b/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentConverter.java index 4b1d9e6bb575..c2af4dea8f0d 100644 --- a/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentConverter.java +++ b/components-starter/camel-xslt-starter/src/main/java/org/apache/camel/component/xslt/springboot/XsltComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -49,19 +50,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy": return applicationContext.getBean(ref, org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy.class); - case "javax.xml.transform.URIResolver": return applicationContext.getBean(ref, javax.xml.transform.URIResolver.class); - case "org.apache.camel.component.xslt.XsltUriResolverFactory": return applicationContext.getBean(ref, org.apache.camel.component.xslt.XsltUriResolverFactory.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.xslt"); } } \ No newline at end of file diff --git a/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentAutoConfiguration.java b/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentAutoConfiguration.java index e2c6befb07bc..6dc9d7be98bc 100644 --- a/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentAutoConfiguration.java +++ b/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureZendeskComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.zendesk.customizer") - && target instanceof ZendeskComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.zendesk", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConverter.java b/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConverter.java index ca77830d9306..dc9233fd620d 100644 --- a/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConverter.java +++ b/components-starter/camel-zendesk-starter/src/main/java/org/apache/camel/component/zendesk/springboot/ZendeskComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.zendesk.ZendeskConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.zendesk.ZendeskConfiguration.class); - case "org.zendesk.client.v2.Zendesk": return applicationContext.getBean(ref, org.zendesk.client.v2.Zendesk.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.zendesk"); } } \ No newline at end of file diff --git a/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/GzipDeflaterDataFormatAutoConfiguration.java b/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/GzipDeflaterDataFormatAutoConfiguration.java index 325f10fdf46e..1751b9a130a1 100644 --- a/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/GzipDeflaterDataFormatAutoConfiguration.java +++ b/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/GzipDeflaterDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureGzipDeflaterDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.gzip-deflater.customizer") - && target instanceof GzipDeflaterDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.gzip-deflater", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/ZipDeflaterDataFormatAutoConfiguration.java b/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/ZipDeflaterDataFormatAutoConfiguration.java index 898d8bfc6511..7ba3dad083d9 100644 --- a/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/ZipDeflaterDataFormatAutoConfiguration.java +++ b/components-starter/camel-zip-deflater-starter/src/main/java/org/apache/camel/dataformat/deflater/springboot/ZipDeflaterDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureZipDeflaterDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.zip-deflater.customizer") - && target instanceof ZipDeflaterDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.zip-deflater", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java b/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java index b7bc2b4dea0f..8df12e4550f3 100644 --- a/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java +++ b/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java @@ -63,16 +63,6 @@ public DataFormatCustomizer configureZipFileDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, DataFormat target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.dataformat.customizer", - "camel.dataformat.zip-file.customizer") - && target instanceof ZipFileDataFormat; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(camelContext, applicationContext, + "camel.dataformat.zip-file", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java b/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java index db648d726514..98e906095ea3 100644 --- a/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java +++ b/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureMasterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.zookeeper-master.customizer") - && target instanceof MasterComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.zookeeper-master", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConverter.java b/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConverter.java index fbde79d8353e..c3c2e4c49b0d 100644 --- a/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConverter.java +++ b/components-starter/camel-zookeeper-master-starter/src/main/java/org/apache/camel/component/zookeepermaster/springboot/MasterComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -48,18 +49,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.zookeepermaster.ContainerIdFactory": return applicationContext.getBean(ref, org.apache.camel.component.zookeepermaster.ContainerIdFactory.class); - case "org.apache.curator.framework.CuratorFramework": return applicationContext.getBean(ref, org.apache.curator.framework.CuratorFramework.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.zookeeper-master"); } } \ No newline at end of file diff --git a/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java b/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java index 957a6d143820..735ea344aceb 100644 --- a/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java +++ b/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java @@ -62,16 +62,6 @@ public ComponentCustomizer configureZooKeeperComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(camelContext, configuration, target); - } - @Override - public boolean isEnabled(String name, Component target) { - return HierarchicalPropertiesEvaluator.evaluate( - applicationContext, - "camel.component.customizer", - "camel.component.zookeeper.customizer") - && target instanceof ZooKeeperComponent; - } - }; - } + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.zookeeper", configuration, target); } \ No newline at end of file diff --git a/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConverter.java b/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConverter.java index 244622fd3e79..2c500345a7d0 100644 --- a/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConverter.java +++ b/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.camel.spring.boot.util.BeanReferenceHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; import org.springframework.context.ApplicationContext; @@ -47,17 +48,6 @@ public Object convert( Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - if (source == null) { - return null; - } - String ref = source.toString(); - if (!ref.startsWith("#")) { - return null; - } - ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); - switch (targetType.getName()) { - case "org.apache.camel.component.zookeeper.ZooKeeperConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.zookeeper.ZooKeeperConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.zookeeper"); } } \ No newline at end of file From 42dd1dfeba1c52525deb9190f577166b5dea3ea9 Mon Sep 17 00:00:00 2001 From: croway Date: Wed, 2 Sep 2026 19:02:05 +0200 Subject: [PATCH 3/3] CAMEL-24501: Scope the generated converters to Camel's own configuration binding Review follow-up on the previous commit. The generated converters are registered with @ConfigurationPropertiesBinding, so they take part in every @ConfigurationProperties binding in the application, not only in Camel's own. Failing closed unconditionally therefore turned an unrelated application property of a type a starter registers for, such as javax.net.ssl.HostnameVerifier, into a startup failure that talks about camel.component.*. BeanReferenceHelper now resolves the class being bound from TypeDescriptor.getSource(), which Spring Boot's binder fills with the setter's MethodParameter (or the Field for field access), and only applies the strict behaviour when that class is Camel's own: under org.apache.camel, or annotated with @ConfigurationProperties for a camel. prefix. Any other class keeps the behaviour it had before, and an unrecognised source counts as Camel's own so that Camel's own binding is never weakened. This is decided in convert() rather than in ConditionalGenericConverter.matches: GenericConversionService caches the converter it picked per source/target TypeDescriptor pair and TypeDescriptor.equals ignores the source, so matches is consulted once for the first class bound and the answer reused for every other class with a field of the same type. A conditional converter would therefore be order dependent, and in the bad order it would report a missing converter for a valid Camel property. Also from the review: - #type: now checks that the bean found by type is assignable to the option type, instead of leaving a ClassCastException for the binder to hit later. - camel.springboot.lenient-configuration-binding is read from the Spring Environment rather than from Camel's PropertiesComponent, and is declared in additional-spring-configuration-metadata.json so it shows up in IDE completion. - The mojo fails the build if a catalog option is ever named enabled or customizer, since the customizers strip those before binding. No component, data format or language declares one today. - The error message names the target class and points out that the option may be listed in the starter documentation, which is generated from the catalog rather than from that class, and so may never have taken effect. - isExplicitlyConfigured logs at WARN when it cannot decide, as returning false there downgrades a hard error to an ignored option. Co-Authored-By: Claude Opus 5 (cherry picked from commit e59029e01829e1353a7beb575ab5a1ab1504b762) --- .../httpstarter/ThirdPartyHttpProperties.java | 39 +++++++ ...HttpComponentBeanReferenceBindingTest.java | 34 ++++++ .../src/main/docs/spring-boot.json | 6 ++ .../spring/boot/util/BeanReferenceHelper.java | 77 ++++++++++++- .../boot/util/CamelPropertiesHelper.java | 39 ++++--- ...itional-spring-configuration-metadata.json | 6 ++ .../springboot/CamelPrefixedProperties.java | 38 +++++++ .../springboot/ThirdPartyProperties.java | 38 +++++++ .../boot/util/BeanReferenceHelperTest.java | 101 +++++++++++++++++- .../SpringBootAutoConfigurationMojo.java | 27 +++++ .../SpringBootAutoConfigurationMojoTest.java | 17 +++ 11 files changed, 398 insertions(+), 24 deletions(-) create mode 100644 components-starter/camel-http-starter/src/test/java/com/example/httpstarter/ThirdPartyHttpProperties.java create mode 100644 core/camel-spring-boot/src/test/java/com/example/springboot/CamelPrefixedProperties.java create mode 100644 core/camel-spring-boot/src/test/java/com/example/springboot/ThirdPartyProperties.java diff --git a/components-starter/camel-http-starter/src/test/java/com/example/httpstarter/ThirdPartyHttpProperties.java b/components-starter/camel-http-starter/src/test/java/com/example/httpstarter/ThirdPartyHttpProperties.java new file mode 100644 index 000000000000..2c62a4fcd575 --- /dev/null +++ b/components-starter/camel-http-starter/src/test/java/com/example/httpstarter/ThirdPartyHttpProperties.java @@ -0,0 +1,39 @@ +/** + * 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 com.example.httpstarter; + +import javax.net.ssl.HostnameVerifier; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Stands in for an application class that happens to have a field of a type HttpComponentConverter registers itself + * for. Deliberately outside the org.apache.camel packages. + */ +@ConfigurationProperties(prefix = "thirdparty.http") +public class ThirdPartyHttpProperties { + + private HostnameVerifier verifier; + + public HostnameVerifier getVerifier() { + return verifier; + } + + public void setVerifier(HostnameVerifier verifier) { + this.verifier = verifier; + } +} diff --git a/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java b/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java index cc2859adfddb..e351743589b7 100644 --- a/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java +++ b/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.http.springboot; +import com.example.httpstarter.ThirdPartyHttpProperties; import org.apache.camel.support.jsse.SSLContextParameters; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; @@ -25,6 +26,7 @@ import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertNull; /** * A complex (object) typed option such as {@code sslContextParameters} is configured with a reference to a bean in the @@ -79,6 +81,38 @@ void testUnresolvableValueIsReported() { }); } + @Test + void testThirdPartyPropertiesAreNotIntercepted() { + // HttpComponentConverter is registered with @ConfigurationPropertiesBinding and so takes part in every + // @ConfigurationProperties binding, not only in Camel's own. Adding the starter to the classpath must not + // make an unrelated property of the same type fail to bind. + new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(ThirdPartyConfiguration.class)) + .withUserConfiguration(HttpComponentConverter.class) + .withPropertyValues("thirdparty.http.verifier=someValue") + .run(context -> { + assertThat(context).hasNotFailed(); + assertNull(context.getBean(ThirdPartyHttpProperties.class).getVerifier()); + }); + } + + @Test + void testThirdPartyPropertiesStillResolveHashReferences() { + new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(ThirdPartyConfiguration.class)) + .withUserConfiguration(HttpComponentConverter.class) + .withPropertyValues("thirdparty.http.verifier=#bean:noSuchVerifier") + .run(context -> { + assertThat(context).hasFailed(); + assertThat(context.getStartupFailure()).hasStackTraceContaining("noSuchVerifier"); + }); + } + + @Configuration(proxyBeanMethods = false) + @EnableConfigurationProperties(ThirdPartyHttpProperties.class) + static class ThirdPartyConfiguration { + } + @Configuration(proxyBeanMethods = false) @EnableConfigurationProperties(HttpComponentConfiguration.class) static class TestConfiguration { diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json b/core/camel-spring-boot/src/main/docs/spring-boot.json index f339b37a2bf5..d022ac7cdd57 100644 --- a/core/camel-spring-boot/src/main/docs/spring-boot.json +++ b/core/camel-spring-boot/src/main/docs/spring-boot.json @@ -1391,6 +1391,12 @@ "description": "Route template configurations", "sourceType": "org.apache.camel.spring.boot.routetemplate.CamelRouteTemplateConfigurationProperties" }, + { + "name": "camel.springboot.lenient-configuration-binding", + "type": "java.lang.Boolean", + "description": "Whether a camel.component, camel.dataformat or camel.language option that cannot be set on the Camel component, data format or language it configures should be tolerated. When false (the default) an option the application configured explicitly and that cannot be set aborts startup, so a configured option can never be silently dropped. When true the option is logged at WARN and ignored.", + "defaultValue": false + }, { "name": "camel.ssl.cert-alias", "type": "java.lang.String", diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java index 63de31c97e5c..8c8aa810982d 100644 --- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java @@ -16,8 +16,12 @@ */ package org.apache.camel.spring.boot.util; +import java.lang.reflect.Field; import org.springframework.beans.BeansException; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.ApplicationContext; +import org.springframework.core.MethodParameter; +import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.convert.TypeDescriptor; import org.springframework.util.ClassUtils; @@ -37,6 +41,12 @@ * * A configured value that cannot be resolved is reported by throwing an {@link IllegalArgumentException}, so a typo in * a configuration file is not silently turned into a null value. + *

+ * The generated converters are registered with {@code @ConfigurationPropertiesBinding} and therefore take part in + * every {@code @ConfigurationProperties} binding in the application, not only in Camel's own. A binding whose target + * is not a Camel configuration class keeps the behaviour it had before Camel 4.23 - a value that is not a bean + * reference converts to null - so that adding a starter to the classpath cannot make an unrelated + * application property fail to bind. See {@link #isCamelConfigurationTarget(TypeDescriptor)}. */ public final class BeanReferenceHelper { @@ -45,6 +55,9 @@ public final class BeanReferenceHelper { private static final String CLASS_PREFIX = "#class:"; private static final String AUTOWIRED = "#autowired"; + private static final String CAMEL_PACKAGE = "org.apache.camel"; + private static final String CAMEL_PROPERTY_PREFIX = "camel."; + private BeanReferenceHelper() { } @@ -64,7 +77,8 @@ private BeanReferenceHelper() { * @return the resolved bean, or null if no value was configured * * @throws IllegalArgumentException - * if a value was configured but cannot be resolved to a bean of the target type + * if a Camel option was configured with a value that cannot be resolved to a bean + * of the target type */ public static Object resolveBeanReference(ApplicationContext applicationContext, Object source, TypeDescriptor targetType, String propertyPrefix) { @@ -76,6 +90,13 @@ public static Object resolveBeanReference(ApplicationContext applicationContext, return null; } Class type = targetType != null ? targetType.getObjectType() : Object.class; + if (!isCamelConfigurationTarget(targetType)) { + // this binding belongs to somebody else, so only resolve what has always been resolved here and + // leave the rest alone rather than imposing Camel's bean reference syntax on it + if (!value.startsWith("#")) { + return null; + } + } if (applicationContext == null) { throw new IllegalArgumentException( message(value, type, propertyPrefix, "there is no Spring application context available")); @@ -90,7 +111,13 @@ public static Object resolveBeanReference(ApplicationContext applicationContext, } if (value.startsWith(TYPE_PREFIX)) { String fqn = value.substring(TYPE_PREFIX.length()).trim(); - return applicationContext.getBean(ClassUtils.forName(fqn, applicationContext.getClassLoader())); + Object bean = applicationContext.getBean(ClassUtils.forName(fqn, applicationContext.getClassLoader())); + if (!type.isInstance(bean)) { + throw new IllegalArgumentException(message(value, type, propertyPrefix, + "the bean found by type is a [" + bean.getClass().getName() + + "] which is not assignable to the option type")); + } + return bean; } String id = value; if (id.startsWith(BEAN_PREFIX)) { @@ -107,6 +134,52 @@ public static Object resolveBeanReference(ApplicationContext applicationContext, } } + /** + * Whether the binding this conversion takes part in targets a Camel configuration class. + *

+ * Spring Boot's binder builds the target {@link TypeDescriptor} from the setter's {@link MethodParameter} (or from + * the {@link Field} for field access), so the class being bound is reachable through + * {@link TypeDescriptor#getSource()}. A class counts as Camel's own when it lives under + * org.apache.camel, or when it is annotated with {@link ConfigurationProperties} for a prefix starting + * with camel.. + *

+ * When the source does not identify a class this returns true, so that Camel's own binding is never + * weakened by a shape of the binder this does not recognise. + *

+ * Note that this cannot be done in {@code ConditionalGenericConverter.matches}: Spring's + * {@code GenericConversionService} caches the converter it picked per source/target {@code TypeDescriptor} pair, + * and {@code TypeDescriptor.equals} ignores the source, so {@code matches} is consulted once for the first class + * bound and the answer is then reused for every other class with a field of the same type. + */ + static boolean isCamelConfigurationTarget(TypeDescriptor targetType) { + Class owner = boundClass(targetType); + if (owner == null) { + return true; + } + if (owner.getName().startsWith(CAMEL_PACKAGE)) { + return true; + } + ConfigurationProperties annotation + = AnnotatedElementUtils.findMergedAnnotation(owner, ConfigurationProperties.class); + if (annotation != null) { + String prefix = !annotation.prefix().isEmpty() ? annotation.prefix() : annotation.value(); + return prefix.startsWith(CAMEL_PROPERTY_PREFIX); + } + return false; + } + + private static Class boundClass(TypeDescriptor targetType) { + Object source = targetType != null ? targetType.getSource() : null; + if (source instanceof MethodParameter methodParameter) { + Class containing = methodParameter.getContainingClass(); + return containing != null ? containing : methodParameter.getDeclaringClass(); + } + if (source instanceof Field field) { + return field.getDeclaringClass(); + } + return null; + } + private static String message(String value, Class type, String propertyPrefix, String reason) { StringBuilder sb = new StringBuilder(256); sb.append("Cannot resolve value [").append(value).append("] as a bean of type [").append(type.getName()) diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java index 66b1601fd29c..3bf909d09d84 100644 --- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/CamelPropertiesHelper.java @@ -22,13 +22,11 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Optional; import java.util.Set; import org.apache.camel.CamelContext; import org.apache.camel.Component; import org.apache.camel.PropertyBindingException; import org.apache.camel.spi.BeanIntrospection; -import org.apache.camel.spi.PropertiesComponent; import org.apache.camel.spi.PropertyConfigurer; import org.apache.camel.support.PluginHelper; import org.apache.camel.support.PropertyBindingSupport; @@ -105,7 +103,7 @@ public static void copyConfigurationProperties(CamelContext camelContext, Applic return; } - boolean lenient = isLenientBinding(camelContext); + boolean lenient = isLenientBinding(applicationContext); List failed = new ArrayList<>(); for (Map.Entry entry : properties.entrySet()) { String name = entry.getKey(); @@ -125,10 +123,12 @@ public static void copyConfigurationProperties(CamelContext camelContext, Applic } if (!failed.isEmpty()) { throw new IllegalArgumentException( - "Cannot configure " + failed + " as the bean class [" + ObjectHelper.classCanonicalName(target) - + "] has no suitable setter method, or it is not possible to lookup a bean with that id in the" - + " Spring Boot registry. Remove or correct the option, or set " - + LENIENT_CONFIGURATION_BINDING + "=true to ignore it."); + "Cannot configure " + failed + " on [" + ObjectHelper.classCanonicalName(target) + + "], which has no suitable setter method for it, and no bean with that id exists in the Spring" + + " Boot registry. The option may be listed in the documentation of the starter, as that is" + + " generated from the Camel catalog rather than from this class, in which case it has never" + + " taken effect. Correct or remove the option, or set " + + LENIENT_CONFIGURATION_BINDING + "=true to keep ignoring it."); } } @@ -156,26 +156,25 @@ private static boolean isExplicitlyConfigured(ApplicationContext applicationCont } } } catch (Exception e) { - LOG.debug("Cannot determine whether {}.{} was configured due to: {}", propertyPrefix, name, - e.getMessage()); + // returning false downgrades a hard error to an ignored option, so this must not stay quiet + LOG.warn("Cannot determine whether {} was configured due to: {}. Treating it as not configured.", + optionKey(propertyPrefix, name), e.getMessage(), e); } return false; } - private static boolean isLenientBinding(CamelContext camelContext) { + private static boolean isLenientBinding(ApplicationContext applicationContext) { + if (applicationContext == null) { + return false; + } try { - PropertiesComponent pc = camelContext.getPropertiesComponent(); - if (pc != null) { - Optional value = pc.resolveProperty(LENIENT_CONFIGURATION_BINDING); - if (value.isPresent()) { - return "true".equalsIgnoreCase(value.get().trim()); - } - } + return applicationContext.getEnvironment().getProperty(LENIENT_CONFIGURATION_BINDING, Boolean.class, + Boolean.FALSE); } catch (Exception e) { - LOG.debug("Cannot resolve {} due to: {}. Using strict configuration binding.", - LENIENT_CONFIGURATION_BINDING, e.getMessage()); + LOG.warn("Cannot resolve {} due to: {}. Using strict configuration binding.", + LENIENT_CONFIGURATION_BINDING, e.getMessage(), e); + return false; } - return false; } /** diff --git a/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index ab8399f40456..368eae83cb43 100644 --- a/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/core/camel-spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1,5 +1,11 @@ { "properties": [ + { + "name": "camel.springboot.lenient-configuration-binding", + "type": "java.lang.Boolean", + "description": "Whether a camel.component, camel.dataformat or camel.language option that cannot be set on the Camel component, data format or language it configures should be tolerated. When false (the default) an option the application configured explicitly and that cannot be set aborts startup, so a configured option can never be silently dropped. When true the option is logged at WARN and ignored.", + "defaultValue": false + }, { "name": "management.info.camel.enabled", "type": "java.lang.Boolean", diff --git a/core/camel-spring-boot/src/test/java/com/example/springboot/CamelPrefixedProperties.java b/core/camel-spring-boot/src/test/java/com/example/springboot/CamelPrefixedProperties.java new file mode 100644 index 000000000000..2f04bdcbb2e5 --- /dev/null +++ b/core/camel-spring-boot/src/test/java/com/example/springboot/CamelPrefixedProperties.java @@ -0,0 +1,38 @@ +/* + * 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 com.example.springboot; + +import javax.net.ssl.HostnameVerifier; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * A configuration class that binds camel.* properties without living in the org.apache.camel packages, as a starter + * outside this repository could. + */ +@ConfigurationProperties(prefix = "camel.example.thirdparty") +public class CamelPrefixedProperties { + + private HostnameVerifier verifier; + + public HostnameVerifier getVerifier() { + return verifier; + } + + public void setVerifier(HostnameVerifier verifier) { + this.verifier = verifier; + } +} diff --git a/core/camel-spring-boot/src/test/java/com/example/springboot/ThirdPartyProperties.java b/core/camel-spring-boot/src/test/java/com/example/springboot/ThirdPartyProperties.java new file mode 100644 index 000000000000..f62df2bbb997 --- /dev/null +++ b/core/camel-spring-boot/src/test/java/com/example/springboot/ThirdPartyProperties.java @@ -0,0 +1,38 @@ +/* + * 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 com.example.springboot; + +import javax.net.ssl.HostnameVerifier; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Stands in for an application or third party {@code @ConfigurationProperties} class that happens to have a field of a + * type one of the generated Camel converters registers itself for. Deliberately outside the org.apache.camel packages. + */ +@ConfigurationProperties(prefix = "thirdparty.example") +public class ThirdPartyProperties { + + private HostnameVerifier verifier; + + public HostnameVerifier getVerifier() { + return verifier; + } + + public void setVerifier(HostnameVerifier verifier) { + this.verifier = verifier; + } +} diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java index ac8b807c82ad..9773db941fed 100644 --- a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java +++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/util/BeanReferenceHelperTest.java @@ -16,15 +16,21 @@ */ package org.apache.camel.spring.boot.util; +import java.lang.reflect.Method; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; +import com.example.springboot.CamelPrefixedProperties; +import com.example.springboot.ThirdPartyProperties; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.MethodParameter; import org.springframework.core.convert.TypeDescriptor; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -49,6 +55,11 @@ MyOption myOption() { return new MyOption(); } + @Bean(name = "myVerifier") + HostnameVerifier myVerifier() { + return (String hostname, SSLSession session) -> true; + } + @Bean(name = "myOtherOption") MyOtherOption myOtherOption() { return new MyOtherOption(); @@ -154,7 +165,93 @@ public void testMessageMentionsTheTargetType() { IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> BeanReferenceHelper.resolveBeanReference(applicationContext, "nope", TypeDescriptor.valueOf(MyOtherOption.class), PREFIX)); - assertEquals(true, e.getMessage().contains(MyOtherOption.class.getName())); + assertTrue(e.getMessage().contains(MyOtherOption.class.getName()), e.getMessage()); + } + + @Test + public void testTypeOfAnUnrelatedBeanFailsClosed() { + // #type: resolves a single bean of the named type, which need not be assignable to the option + IllegalArgumentException e = assertThrows(IllegalArgumentException.class, + () -> resolve("#type:" + MyOtherOption.class.getName())); + assertTrue(e.getMessage().contains("not assignable to the option type"), e.getMessage()); + assertTrue(e.getMessage().contains(MyOtherOption.class.getName()), e.getMessage()); + } + + // ************************************* + // The generated converters are registered with @ConfigurationPropertiesBinding and so take part in every + // @ConfigurationProperties binding in the application, not only in Camel's own. + // ************************************* + + private static TypeDescriptor verifierOf(Class owner) throws Exception { + Method setter = owner.getMethod("setVerifier", HostnameVerifier.class); + return new TypeDescriptor(new MethodParameter(setter, 0)); + } + + @Test + public void testTargetInCamelPackageIsCamelsOwn() throws Exception { + assertTrue(BeanReferenceHelper.isCamelConfigurationTarget(verifierOf(CamelStyleProperties.class))); + } + + @Test + public void testTargetWithCamelPrefixIsCamelsOwn() throws Exception { + assertTrue(BeanReferenceHelper.isCamelConfigurationTarget(verifierOf(CamelPrefixedProperties.class))); + } + + @Test + public void testThirdPartyTargetIsNotCamelsOwn() throws Exception { + assertFalse(BeanReferenceHelper.isCamelConfigurationTarget(verifierOf(ThirdPartyProperties.class))); + } + + @Test + public void testUnknownTargetIsTreatedAsCamelsOwn() { + // a TypeDescriptor that does not carry the bound class must never weaken Camel's own binding + assertTrue(BeanReferenceHelper.isCamelConfigurationTarget(TypeDescriptor.valueOf(HostnameVerifier.class))); + assertTrue(BeanReferenceHelper.isCamelConfigurationTarget(null)); + } + + @Test + public void testThirdPartyBindingIsNotIntercepted() throws Exception { + // this is what a third party class with a field of a type a starter registers for used to get, and + // adding a starter to the classpath must not turn it into a startup failure + assertNull(BeanReferenceHelper.resolveBeanReference(applicationContext, "someValue", + verifierOf(ThirdPartyProperties.class), PREFIX)); + } + + @Test + public void testThirdPartyBindingStillResolvesHashReferences() throws Exception { + assertSame(applicationContext.getBean("myVerifier"), BeanReferenceHelper + .resolveBeanReference(applicationContext, "#bean:myVerifier", verifierOf(ThirdPartyProperties.class), + PREFIX)); + } + + @Test + public void testCamelBindingResolvesHashReferences() throws Exception { + assertSame(applicationContext.getBean("myVerifier"), BeanReferenceHelper + .resolveBeanReference(applicationContext, "#bean:myVerifier", verifierOf(CamelStyleProperties.class), + PREFIX)); + } + + @Test + public void testCamelBindingResolvesPlainBeanIds() throws Exception { + assertSame(applicationContext.getBean("myVerifier"), BeanReferenceHelper + .resolveBeanReference(applicationContext, "myVerifier", verifierOf(CamelStyleProperties.class), + PREFIX)); + } + + /** + * Stands in for a generated {@code *ComponentConfiguration}, which always lives under org.apache.camel. + */ + public static class CamelStyleProperties { + + private HostnameVerifier verifier; + + public HostnameVerifier getVerifier() { + return verifier; + } + + public void setVerifier(HostnameVerifier verifier) { + this.verifier = verifier; + } } } diff --git a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java index 7bcbf36bc62a..886023531143 100644 --- a/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java +++ b/tooling/camel-spring-boot-generator-maven-plugin/src/main/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojo.java @@ -89,6 +89,12 @@ public class SpringBootAutoConfigurationMojo extends AbstractSpringBootGenerator */ private static final boolean DELETE_FILES_ON_MAIN_ARTIFACTS = false; + /** + * Option names owned by the Spring Boot auto configuration layer, see + * {@code CamelPropertiesHelper.copyConfigurationProperties}. + */ + private static final Set RESERVED_OPTION_NAMES = Set.of("enabled", "customizer"); + private static final Map PRIMITIVEMAP; private static final Map PRIMITIVE_CLASSES; @@ -698,6 +704,8 @@ private void createComponentConfigurationSource(String packageName, ComponentMod for (ComponentOptionModel option : model.getComponentOptions()) { + checkReservedOptionName("component", model.getScheme(), option.getName()); + if (skipComponentOption(model, option)) { // some component options should be skipped continue; @@ -1117,6 +1125,7 @@ private void createDataFormatConfigurationSource(String packageName, DataFormatM .setStringValue("prefix", prefix); for (DataFormatOptionModel option : model.getOptions()) { + checkReservedOptionName("data format", model.getName(), option.getName()); // skip option with name id in data format as we do not need that if ("id".equals(option.getName())) { continue; @@ -1221,6 +1230,7 @@ private void createLanguageConfigurationSource(String packageName, LanguageModel .setStringValue("prefix", prefix); for (LanguageOptionModel option : model.getOptions()) { + checkReservedOptionName("language", model.getName(), option.getName()); // skip option with name id, or expression in language as we do not // need that and skip resultType as they are not global options if ("id".equals(option.getName()) || "expression".equals(option.getName()) @@ -1430,6 +1440,23 @@ private void createComponentConverterSource(String packageName, ComponentModel m writeComponentSpringFactorySource(packageName, name); } + /** + * The generated customizers strip the options owned by the Spring Boot auto configuration layer itself before + * binding the configuration onto the Camel target, because they are not options on that target. No Camel + * component, data format or language declares an option with one of these names today, and this check makes sure + * that a catalog option carrying one of them can never be dropped silently by that stripping. + */ + static void checkReservedOptionName(String kind, String name, String optionName) + throws MojoFailureException { + if (RESERVED_OPTION_NAMES.contains(optionName.toLowerCase(Locale.US))) { + throw new MojoFailureException( + "The " + kind + " " + name + " declares an option named " + optionName + + ", which collides with the Spring Boot auto configuration layer. Such an option is removed" + + " before the configuration is copied onto the Camel target, so it would never take effect." + + " Rename the option, or teach CamelPropertiesHelper to tell the two apart."); + } + } + private static String componentPropertyPrefix(ComponentModel model, String overrideComponentName) { return ("camel.component." + camelCaseToDash(overrideComponentName != null ? overrideComponentName : model.getScheme())) diff --git a/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java b/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java index bfa5ed05506a..1ec84cf4f018 100644 --- a/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java +++ b/tooling/camel-spring-boot-generator-maven-plugin/src/test/java/org/apache/camel/springboot/maven/SpringBootAutoConfigurationMojoTest.java @@ -16,10 +16,13 @@ */ package org.apache.camel.springboot.maven; +import org.apache.maven.plugin.MojoFailureException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.Assertions.assertThatThrownBy; /** * Tests for the code that {@link SpringBootAutoConfigurationMojo} generates into the starters. @@ -78,4 +81,18 @@ void testLanguageBodyBindsStrictly() { assertThat(body).doesNotContain("CamelPropertiesHelper.copyProperties("); } + @Test + @DisplayName("A catalog option named enabled or customizer fails the build") + void testReservedOptionNamesAreRejected() { + assertThatThrownBy(() -> SpringBootAutoConfigurationMojo.checkReservedOptionName("component", "foo", "enabled")) + .isInstanceOf(MojoFailureException.class) + .hasMessageContaining("enabled") + .hasMessageContaining("would never take effect"); + assertThatThrownBy( + () -> SpringBootAutoConfigurationMojo.checkReservedOptionName("data format", "foo", "Customizer")) + .isInstanceOf(MojoFailureException.class); + assertThatCode(() -> SpringBootAutoConfigurationMojo.checkReservedOptionName("language", "foo", "trim")) + .doesNotThrowAnyException(); + } + }