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 7a7eb5c52da3..a2d486717269 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureActiveMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.activemq", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8f57a5d88d34..e46331a3e8ff 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureActiveMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.activemq6", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentAutoConfiguration.java b/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentAutoConfiguration.java index 6e91e4a85cc2..2f33b1205be1 100644 --- a/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentAutoConfiguration.java +++ b/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureAiToolComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ai-tool", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentConverter.java b/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentConverter.java index 3d2bbb0832eb..0ee40aad4e0e 100644 --- a/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentConverter.java +++ b/components-starter/camel-ai-tool-starter/src/main/java/org/apache/camel/component/ai/tool/springboot/AiToolComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.ai.tool.AiToolConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.ai.tool.AiToolConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.ai-tool"); } } \ 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 4c086f522ab1..6b6e62c0d895 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAMQPComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.amqp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d1da768efe0e..74077592fb51 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureArangoDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.arangodb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5d40ee128039..71f9470dc0e2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.as2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5dfc79c13ece..96394e02f60c 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,7 +63,8 @@ public DataFormatCustomizer configureASN1DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.asn1", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 bfe033d814d6..b88c766b3a74 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAsteriskComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.asterisk", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fcc7ba5c5276..18445759878c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWebsocketComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.atmosphere-websocket", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 be813ae7297e..40f2d997331c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAtomComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.atom", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fc590555ae0a..913d66322ad2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAvroComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.avro", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 cb0be5ed8122..b30a5b4bf0ba 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,7 +63,8 @@ public DataFormatCustomizer configureAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.avro", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 bb0ee8b52ffa..45f2deb0fa99 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBedrockAgentComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-bedrock-agent", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ef9ee51cac3d..511b5331143c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBedrockAgentRuntimeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-bedrock-agent-runtime", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 10e2d7c5fd8e..63bb1e355d18 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; @@ -51,19 +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.bedrock.agentruntime.BedrockAgentRuntimeConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.aws2.bedrock.agentruntime.BedrockAgentRuntimeConfiguration.class); - case "software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeAsyncClient": return applicationContext.getBean(ref, software.amazon.awssdk.services.bedrockagentruntime.BedrockAgentRuntimeAsyncClient.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 ce8a0a42793b..d03b0b51e739 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBedrockComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-bedrock", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8998ea06e029..d68d2111c98d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCloudtrailComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-cloudtrail", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 dd605543b1c3..260b78cf16a6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAWSConfigComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-config", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8e1e9bc9e03b..a15a81c5d4ec 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureParameterStoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-parameter-store", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8a441178501c..0a789bca4b22 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSecretsManagerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-secrets-manager", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a51a260f527f..d6125c5b9286 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSecurityHubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws-security-hub", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 084f1b59b972..f35b962f2248 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAthena2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-athena", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6970a06e0ecf..d7873996cc49 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureComprehend2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-comprehend", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3e45cef6101e..7ac53ad1371e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCw2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-cw", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1a7d6e8578be..03d13ad0615d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDdb2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ddb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 feb679de1570..6b419f80ca07 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDdb2StreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ddbstream", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5ed9a9120494..40636e2ab822 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAWS2EC2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ec2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 958dbd9e19c8..263f2fab0eda 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureECS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ecs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 42eb44982163..b3609a276d71 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureEKS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-eks", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 29071cde83f0..c5342d1ec247 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureEventbridgeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-eventbridge", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e2c43c08e7a7..da76505f340a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIAM2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-iam", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 33a9b19e65c5..ae6babcc4037 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKinesisFirehose2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-kinesis-firehose", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0ce2455cdfd6..8ad2949e1f4f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKinesis2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-kinesis", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 02a4b0663734..f7a358f42306 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKMS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-kms", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 425efc25b9ac..a231b30e0c66 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLambda2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-lambda", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 eb048df87049..f852cf72a8aa 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMQ2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-mq", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bef1d688284f..8b1130efb5eb 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMSK2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-msk", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 968c8c7c85c4..2cd2f11a2624 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePolly2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-polly", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1c685ca48b5e..549b33247064 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRedshiftData2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-redshift-data", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e11872edc4a3..c698321f34c0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRekognition2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-rekognition", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 efdc353e4f31..d630ffbcfbab 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAWS2S3Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-s3", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c5b4c0535447..74848c73475e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureAWS2S3VectorsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-s3-vectors", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e6dce5f342be..7fa0e413625f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSes2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-ses", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9c79881f1207..04cad57db61f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSns2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-sns", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 609b4dd19d8a..fe786cea14d2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSqs2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-sqs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 922645b158a8..7199858d12aa 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStepFunctions2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-step-functions", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1e2776d7bc2a..a596a311c9dc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSTS2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-sts", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 94a3839bf587..2c186ecde77b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTextract2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-textract", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6b6a05d63a26..a2637571a334 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTimestream2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-timestream", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8e3424df4ee0..799dd156f7bc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTranscribe2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-transcribe", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8338d66e1070..f7cb0ac83bcd 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTranslate2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.aws2-translate", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9ffc5965e7f2..0fb97badfdf0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCosmosDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-cosmosdb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 814a984342a1..83718542103d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureEventGridComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-eventgrid", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b04549016aef..ecaefd7da4c3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureEventHubsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-eventhubs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 29894820a70e..045aec2d988c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFilesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-files", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentAutoConfiguration.java b/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentAutoConfiguration.java index 354782333487..5a63c0b77de3 100644 --- a/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentAutoConfiguration.java +++ b/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureFunctionsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-functions", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentConverter.java b/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentConverter.java index d7f9c2de2017..d6e5575a29ea 100644 --- a/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentConverter.java +++ b/components-starter/camel-azure-functions-starter/src/main/java/org/apache/camel/component/azure/functions/springboot/FunctionsComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.functions.FunctionsConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.azure.functions.FunctionsConfiguration.class); - case "com.azure.resourcemanager.appservice.AppServiceManager": return applicationContext.getBean(ref, com.azure.resourcemanager.appservice.AppServiceManager.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-functions"); } } \ 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 4d5195ef2764..b15312210fa2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKeyVaultComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-key-vault", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1bdc69904ead..aaf4b2492b77 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureServiceBusComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-servicebus", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bb44dd834001..05034b27a8b3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBlobComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-storage-blob", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1ac9c0ad9508..6fd8524ec0d7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDataLakeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-storage-datalake", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c934f3e39972..9e68c24e516e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureQueueComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.azure-storage-queue", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 666335386fb2..e4aa65d6fbc7 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,7 +63,8 @@ public DataFormatCustomizer configureBarcodeDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.barcode", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 c1c110da4542..dbca175fa4d0 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,7 +63,8 @@ public DataFormatCustomizer configureBase64DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.base64", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 63e23013f606..f0be9cffaee6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBeanComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.bean", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 230e169c1b21..d5c4fd71ebe0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureClassComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.class", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0d28e1c4f59c..da8ba21c0eeb 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureBeanLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.bean", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 82b956341fb0..1503d5dad14e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBeanValidatorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.bean-validator", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 23bb53dc529a..93bdbc561105 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,7 +63,8 @@ public DataFormatCustomizer configureBeanIODataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.beanio", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 8e0b8f3e4d69..5b3bf99a2cbc 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,7 +63,8 @@ public DataFormatCustomizer configureBindyCsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.bindy-csv", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 8621e0affb63..b5e556ba3bea 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,7 +63,8 @@ public DataFormatCustomizer configureBindyFixedLengthDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.bindy-fixed", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 768f36c85627..ba3b5c14e51b 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,7 +63,8 @@ public DataFormatCustomizer configureBindyKeyValuePairDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.bindy-kvp", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 8d4e7ed430f6..fb16712a0095 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBonitaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.bonita", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0d0cb0154d73..e3a824b85853 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBoxComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.box", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9bdd56c2f706..556a1ee1fd0b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBraintreeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.braintree", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d3f2312ed014..e53dc68f8621 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureBrowseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.browse", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d49ca36639b2..6a6f69170b0d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCaffeineCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.caffeine-cache", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6becc04c2fc1..888c648280c7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCaffeineLoadCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.caffeine-loadcache", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8858566d8c06..0b252f446ea9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCassandraComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cql", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 df6e817172bf..be4c80d8c54f 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,7 +63,8 @@ public DataFormatCustomizer configureCBORDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.cbor", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 50967bdddcd4..cc0f02787d77 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureChatScriptComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.chatscript", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 95e97426b403..a349a4e06bf9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureChunkComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.chunk", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentAutoConfiguration.java b/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentAutoConfiguration.java index e6286aa22f8c..850717a801dc 100644 --- a/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentAutoConfiguration.java +++ b/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureClickHouseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.clickhouse", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentConverter.java b/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentConverter.java index 96e3eafaa24c..40aed24205e3 100644 --- a/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentConverter.java +++ b/components-starter/camel-clickhouse-starter/src/main/java/org/apache/camel/component/clickhouse/springboot/ClickHouseComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.clickhouse.client.api.Client": return applicationContext.getBean(ref, com.clickhouse.client.api.Client.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.clickhouse"); } } \ 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 dc1d066652e1..a54320c4bcf3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureClickUpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.clickup", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f543f15e31bf..d658fc178958 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCMComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cm-sms", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c21e20ddc240..3ea1acc19c18 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCoAPComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.coap", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 40585bdf3cf2..9021309dbf36 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCometdComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cometd", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f1b1eee82295..00edd9bbdd7d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureConsulComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.consul", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e4f65ce6f936..ae825f8111b4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureControlBusComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.controlbus", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 dafb13f138d2..0bdf363b6299 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureConstantLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.constant", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 f9d8dae67a4b..d6d31df153c2 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureHeaderLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.header", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 e4f03af15468..58af27f053ec 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureExchangePropertyLanguage @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.exchange-property", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 8e85223b3c4e..04ebc51ae1a9 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureRefLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.ref", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 60af862ac29b..791b776bf8d6 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureFileLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.file", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 ce660f54fdf0..975bee1cee1e 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureSimpleLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.simple", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 d33e5b4d0411..989a1fb6898e 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureTokenizeLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.tokenize", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 239e563aad7d..0fed7a8562a2 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureVariableLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.variable", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 63ff5f7041a0..fd5aeb3e555c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCouchbaseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.couchbase", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 21092c23c046..7c1427a566e1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCouchDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.couchdb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 358902e027ea..27257d47516e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCronComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cron", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4fe1118c7e13..0d65b6da1506 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,7 +63,8 @@ public DataFormatCustomizer configurePGPDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.pgp", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 b10899b120f5..319f8e8001d8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDigitalSignatureComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.crypto", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 036d02f9e765..cf1a47963d78 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,7 +63,8 @@ public DataFormatCustomizer configureCryptoDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.crypto", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 f6d43d28495e..398523b3df23 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,7 +63,8 @@ public DataFormatCustomizer configureCsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.csv", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 62f70537090c..22787dcbebd5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCxfRsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cxfrs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 25226276b2ff..ee18f339bd10 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCxfComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cxf", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d1eea2502c3f..c59e5953594b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCyberArkVaultComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.cyberark-vault", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 257316487413..07a478b432b8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDaprComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dapr", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c36f7d27a488..ab8d198c85be 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDataFormatComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dataformat", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 574e24f3b529..c9d91414c7e7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDataSetComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dataset", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fcec3abb6cb9..02cc9776279e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDataSetTestComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dataset-test", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0dbb2e4e3c55..e41d1e3d6c0d 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureDatasonnetLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.datasonnet", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 7fec86442d12..4b71808528b3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDebeziumDb2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-db2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c5ca050ea3e2..fb04b89935a2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDebeziumMongodbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-mongodb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 be20eb32f169..931e99c030b6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDebeziumMySqlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-mysql", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 902e08d7f09b..e4cb42bad9a9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDebeziumOracleComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-oracle", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e31bdd9d6771..5e4d678beedc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDebeziumPostgresComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-postgres", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 09a22bf691ef..7cb7943d87a8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDebeziumSqlserverComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.debezium-sqlserver", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0a7c36b6d1e8..7a80ab988e18 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDfdlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dfdl", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a2811aec8db9..26217304a433 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,7 +63,8 @@ public DataFormatCustomizer configureDfdlDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.dfdl", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 2e7658b74e74..25844983c4e0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDhis2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dhis2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 808a381a60df..1045e8903290 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDirectComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.direct", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2e212f8141cf..d213adb6d36d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDisruptorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.disruptor", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 cf65b8202071..d3ef10f20acc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDisruptorVmComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.disruptor-vm", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 05ffc243de28..0c17dd287e49 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDJLComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.djl", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e0ab829c237b..ce9d6fcc1814 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDnsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dns", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7fc30120406d..6b3504b2260f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDockerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.docker", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 778c9355eb4c..e28724abfcda 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDoclingComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.docling", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a1c70cec36f3..101209ec1e15 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDrillComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.drill", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1d55aa99c394..b1e59361cea0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDropboxComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dropbox", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentAutoConfiguration.java b/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentAutoConfiguration.java index 9198847f95c3..e9082c9c2bd7 100644 --- a/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentAutoConfiguration.java +++ b/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureDuckDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.duckdb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentConverter.java b/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentConverter.java index 660a41382204..32787cb6ffb6 100644 --- a/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentConverter.java +++ b/components-starter/camel-duckdb-starter/src/main/java/org/apache/camel/component/duckdb/springboot/DuckDbComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.duckdb"); } } \ 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 4b181f49f213..6519c16ca613 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDynamicRouterControlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dynamic-router-control", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 56b8bf54d0f3..721ddbefb16e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDynamicRouterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.dynamic-router", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7b5f764a8bae..11ae4f8f691d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureEhcacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ehcache", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2ff8abaa9d9a..e713e9916c9f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureElasticsearchRestClientComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.elasticsearch-rest-client", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5772d6d6f816..1439874f7ffe 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; @@ -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.elasticsearch.client.RestClient": return applicationContext.getBean(ref, org.elasticsearch.client.RestClient.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.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 4e26316a279a..6d004941c8ed 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureElasticsearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.elasticsearch", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bc1877633745..0b16efd49cbd 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; @@ -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.elasticsearch.client.RestClient": return applicationContext.getBean(ref, org.elasticsearch.client.RestClient.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.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 19994477c1a9..bd4a43e5d3f7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureExecComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.exec", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentConverter.java b/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentConverter.java index d5d6ab5b1f3c..7e03b680887a 100644 --- a/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentConverter.java +++ b/components-starter/camel-exec-starter/src/main/java/org/apache/camel/component/exec/springboot/ExecComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.exec.ExecBinding": return applicationContext.getBean(ref, org.apache.camel.component.exec.ExecBinding.class); - case "org.apache.camel.component.exec.ExecCommandExecutor": return applicationContext.getBean(ref, org.apache.camel.component.exec.ExecCommandExecutor.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.exec"); } } \ 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 6b04873e2d05..e3b26e0b3ba4 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,7 +63,8 @@ public DataFormatCustomizer configureFastjsonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.fastjson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 325d5ed59b85..709518fda936 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFhirComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.fhir", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4e56dfbde6cb..5653da34a8c5 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,7 +63,8 @@ public DataFormatCustomizer configureFhirJsonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.fhir-json", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 b805b7e8e3e1..f56bc0f6315d 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,7 +63,8 @@ public DataFormatCustomizer configureFhirXmlDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.fhir-xml", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 270e477bd2aa..1e726dec367c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFileComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.file", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2c1e48ab4758..51a87c04e2ca 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFileWatchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.file-watch", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8bdac27cddc2..c8c85773d3d9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFlatpackComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.flatpack", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3a313549dc01..3f9661b62197 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,7 +63,8 @@ public DataFormatCustomizer configureFlatpackDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.flatpack", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 941f89aafda8..5969ae3c7045 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFlinkComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.flink", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e7ca8fc419f1..e2d8631cb5c9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFlowableComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.flowable", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1656b268d351..380094ca2afc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFopComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.fop", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0c4030ea0f57..ab271a1f6075 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,7 +63,8 @@ public DataFormatCustomizer configureForyDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.fory", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 e356659366d9..dbe8bdc3de3d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFreemarkerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.freemarker", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 545f1d7d5a0c..e03cc26b1c17 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFtpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ftp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 df3fe68c7f75..3bf2bb0d0f57 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFtpsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ftps", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f7c420051096..2202e0d8ca11 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSftpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sftp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 26ee86901d82..63803bf9e4e4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGeoCoderComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.geocoder", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0ddebf0c3d6c..d6b97640f6a1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGitComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.git", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0583b0ef1d43..097f21e56f0c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGitHub2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.github2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1d6897ee3e25..6f564e8a5183 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleBigQueryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-bigquery", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2b4013c50da9..28628e6f89f6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleBigQuerySQLComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-bigquery-sql", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 394e5045b9b9..93d7c6ceaab5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCalendarComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-calendar", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 85a8c6af5811..881d34152ff1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCalendarStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-calendar-stream", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7ab491bd8d86..0568471da167 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleDriveComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-drive", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentAutoConfiguration.java b/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentAutoConfiguration.java index e6ed53702dfc..6457c7893d43 100644 --- a/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentAutoConfiguration.java +++ b/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleFirestoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-firestore", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentConverter.java b/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentConverter.java index 20152c162867..8d8859e37110 100644 --- a/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentConverter.java +++ b/components-starter/camel-google-firestore-starter/src/main/java/org/apache/camel/component/google/firestore/springboot/GoogleFirestoreComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.firestore.GoogleFirestoreConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.google.firestore.GoogleFirestoreConfiguration.class); - case "com.google.cloud.firestore.Firestore": return applicationContext.getBean(ref, com.google.cloud.firestore.Firestore.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.google-firestore"); } } \ 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 93880683bd42..d6db58673d41 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCloudFunctionsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-functions", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c1aa7269f87d..ba726e53e0b8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleMailComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-mail", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2c03f46832b3..291429b31fc1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleMailStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-mail-stream", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 39c9a2351895..47dee22232b9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGooglePubsubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-pubsub", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ea74a102eab1..e7b767df5824 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleSecretManagerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-secret-manager", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 32f368f55a8b..9eb5687e4a7c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleSheetsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-sheets", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a7980dafdf2a..d40598e2d4b5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleSheetsStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-sheets-stream", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-speech-to-text-starter/src/main/java/org/apache/camel/component/google/speechtotext/springboot/GoogleCloudSpeechToTextComponentAutoConfiguration.java b/components-starter/camel-google-speech-to-text-starter/src/main/java/org/apache/camel/component/google/speechtotext/springboot/GoogleCloudSpeechToTextComponentAutoConfiguration.java index b0e016b2e2fb..9631783557f9 100644 --- a/components-starter/camel-google-speech-to-text-starter/src/main/java/org/apache/camel/component/google/speechtotext/springboot/GoogleCloudSpeechToTextComponentAutoConfiguration.java +++ b/components-starter/camel-google-speech-to-text-starter/src/main/java/org/apache/camel/component/google/speechtotext/springboot/GoogleCloudSpeechToTextComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCloudSpeechToTextComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-speech-to-text", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 554fa4a15190..15887de463bc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCloudStorageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-storage", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-text-to-speech-starter/src/main/java/org/apache/camel/component/google/texttospeech/springboot/GoogleCloudTextToSpeechComponentAutoConfiguration.java b/components-starter/camel-google-text-to-speech-starter/src/main/java/org/apache/camel/component/google/texttospeech/springboot/GoogleCloudTextToSpeechComponentAutoConfiguration.java index 2c6da6c1a71f..3bd5987bdcae 100644 --- a/components-starter/camel-google-text-to-speech-starter/src/main/java/org/apache/camel/component/google/texttospeech/springboot/GoogleCloudTextToSpeechComponentAutoConfiguration.java +++ b/components-starter/camel-google-text-to-speech-starter/src/main/java/org/apache/camel/component/google/texttospeech/springboot/GoogleCloudTextToSpeechComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCloudTextToSpeechComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-text-to-speech", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8344682789df..a251c1ec0b76 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleVertexAIComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-vertexai", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-google-vision-starter/src/main/java/org/apache/camel/component/google/vision/springboot/GoogleCloudVisionComponentAutoConfiguration.java b/components-starter/camel-google-vision-starter/src/main/java/org/apache/camel/component/google/vision/springboot/GoogleCloudVisionComponentAutoConfiguration.java index 436e8d52cd94..69c05afde285 100644 --- a/components-starter/camel-google-vision-starter/src/main/java/org/apache/camel/component/google/vision/springboot/GoogleCloudVisionComponentAutoConfiguration.java +++ b/components-starter/camel-google-vision-starter/src/main/java/org/apache/camel/component/google/vision/springboot/GoogleCloudVisionComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureGoogleCloudVisionComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.google-vision", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 dacb508844da..e9406bb0ab50 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGraphqlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.graphql", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2f0a9a654713..ed5713c4d8ae 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,7 +63,8 @@ public DataFormatCustomizer configureGrokDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.grok", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { diff --git a/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/json/springboot/GroovyJSonlDataFormatAutoConfiguration.java b/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/json/springboot/GroovyJSonlDataFormatAutoConfiguration.java index 4679c916be44..faf95ee4a6da 100644 --- a/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/json/springboot/GroovyJSonlDataFormatAutoConfiguration.java +++ b/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/json/springboot/GroovyJSonlDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureGroovyJSonlDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.groovy-json", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { diff --git a/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/xml/springboot/GroovyXmlDataFormatAutoConfiguration.java b/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/xml/springboot/GroovyXmlDataFormatAutoConfiguration.java index 47ada2f3aa67..b870bfdf69b4 100644 --- a/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/xml/springboot/GroovyXmlDataFormatAutoConfiguration.java +++ b/components-starter/camel-groovy-starter/src/main/java/org/apache/camel/groovy/xml/springboot/GroovyXmlDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureGroovyXmlDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.groovy-xml", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 ba25db3d460d..403df5ec50c8 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureGroovyLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.groovy", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 65f3a3366254..16461edc7da3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGrpcComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.grpc", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1be4eb449338..a175bbb40d76 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,7 +63,8 @@ public DataFormatCustomizer configureGsonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.gson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 eb4956446b54..308d576f48c4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHashicorpVaultComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hashicorp-vault", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0bfca7f8d9b7..8c07f0187007 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastAtomicnumberComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-atomicvalue", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b1c7058f81e2..1ba74fb78ed9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastInstanceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-instance", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 06dc6ca97ad7..167bf5e91422 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastListComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-list", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 76ad53213a06..b04b47ca1805 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastMapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-map", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2c6349712a80..c6a05c23814e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastMultimapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-multimap", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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/pncounter/springboot/HazelcastPNCounterComponentAutoConfiguration.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentAutoConfiguration.java index b48c801f74a0..3ed94a767381 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentAutoConfiguration.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastPNCounterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-pncounter", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentConverter.java b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentConverter.java index cee84accf1f5..616391fc30ec 100644 --- a/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentConverter.java +++ b/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/pncounter/springboot/HazelcastPNCounterComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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-pncounter"); } } \ 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 04df91ca31e7..d51eaac6cc70 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastQueueComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-queue", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b585ad8d1615..0b35ec4421d1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastReplicatedmapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-replicatedmap", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4ebab346f245..6614f7a94855 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastRingbufferComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-ringbuffer", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5e27b8558da5..004750745f06 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastSedaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-seda", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 facb3f184e5f..772187af7b5e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastSetComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-set", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 552ef6bed095..9ea057079d9b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHazelcastTopicComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hazelcast-topic", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentAutoConfiguration.java b/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentAutoConfiguration.java index 9869266c9bb5..8cd8a37bc82b 100644 --- a/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentAutoConfiguration.java +++ b/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureHiveMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hivemq", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentConverter.java b/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentConverter.java index c61c40ea305f..60d71caf98c6 100644 --- a/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentConverter.java +++ b/components-starter/camel-hivemq-starter/src/main/java/org/apache/camel/component/hivemq/springboot/HiveMQComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.hivemq.HiveMQConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.hivemq.HiveMQConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.hivemq"); } } \ 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 74832849dafb..d59cf09f5447 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,7 +63,8 @@ public DataFormatCustomizer configureHL7DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.hl7", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 2e859f6002cd..4f0583b937c0 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureHl7TerserLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.hl7terser", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 03bd2f5132a0..5864be261eab 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.http", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-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 new file mode 100644 index 000000000000..e351743589b7 --- /dev/null +++ b/components-starter/camel-http-starter/src/test/java/org/apache/camel/component/http/springboot/HttpComponentBeanReferenceBindingTest.java @@ -0,0 +1,126 @@ +/* + * 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 com.example.httpstarter.ThirdPartyHttpProperties; +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; +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 + * 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"); + }); + } + + @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 { + + @Bean(name = "mySslContextParameters") + SSLContextParameters mySslContextParameters() { + return new SSLContextParameters(); + } + } + +} 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 5189729966c5..42676d39929f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureDMSComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-dms", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ae53c813d9c9..468cab4a72ff 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFaceRecognitionComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-frs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 67d700e15ec9..9b5266309e08 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureFunctionGraphComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-functiongraph", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8b54bc66b357..ee08de90d55f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIAMComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-iam", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c71b009712a1..964ea56be0f5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureImageRecognitionComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-imagerecognition", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 29b481ab06bc..a8b504035557 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOBSComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-obs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 66b04a66049b..30ea10217276 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSimpleNotificationComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.hwcloud-smn", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentAutoConfiguration.java b/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentAutoConfiguration.java index 29c4e700ed8d..7a9f6eb38315 100644 --- a/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentAutoConfiguration.java +++ b/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureHuggingFaceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.huggingface", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentConverter.java b/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentConverter.java index 22c166676209..5456b4297ad8 100644 --- a/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentConverter.java +++ b/components-starter/camel-huggingface-starter/src/main/java/org/apache/camel/component/huggingface/springboot/HuggingFaceComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.huggingface.HuggingFaceConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.huggingface.HuggingFaceConfiguration.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.huggingface"); } } \ 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 5ac0103ddcab..e66d9d040f7c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIBMCOSComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-cos", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7dde420dd1b0..25e21a7c7d59 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIBMSecretsManagerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-secrets-manager", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 cbb5cb9b2d0c..4fcddb46b313 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWatsonDiscoveryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-discovery", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 124f92ac6815..9e405bb03a74 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWatsonLanguageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-language", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1f2fe473b5b3..eb15aa7ebabc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWatsonSpeechToTextComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-speech-to-text", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6b1f4e525e3f..6dc83b0894f3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWatsonTextToSpeechComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watson-text-to-speech", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 728f04655209..9ac6352fd04d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWatsonxAiComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ibm-watsonx-ai", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5f2e6573b3f2..c4653b0da2f2 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,7 +63,8 @@ public DataFormatCustomizer configureICalDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.ical", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 f810c061bcb9..9b6f6e593da9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIggyComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.iggy", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c41688415025..f3445d3e45bc 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; @@ -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.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); - 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.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 27106605c42a..b5c222c2ddc9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-cache", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bd20566ad7f5..10f6a46d856b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteComputeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-compute", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e8b39f8f23ea..6ad2331a853a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteEventsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-events", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1dc395a616a1..813f8a1eccad 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteIdGenComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-idgen", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 090dac6a2fa9..c507b8ad308e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteMessagingComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-messaging", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a5441f6b469d..6288dec54013 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteQueueComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-queue", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3d0e8488ce53..b2e575cab2b6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureIgniteSetComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ignite-set", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e4ebafb59e2b..9f648392b9a6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureInfinispanEmbeddedComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.infinispan-embedded", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 744229c717af..7c1fd2d58cf9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureInfinispanRemoteComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.infinispan", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ea225e263488..fbb674c71dc4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureInfluxDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.influxdb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7054fac0c37c..3cc4a29d952c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureInfluxDb2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.influxdb2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 620beba27956..e81a6bf0b1a4 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,7 +63,8 @@ public DataFormatCustomizer configureIso8583DataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.iso8583", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 d521029e641c..e972791282fb 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,7 +63,8 @@ public DataFormatCustomizer configureJacksonAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.avro-jackson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 4bb41ccca015..3f35ea5a4f5f 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,7 +63,8 @@ public DataFormatCustomizer configureJacksonProtobufDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.protobuf-jackson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 9aff6812216f..e09c30a7545f 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,7 +63,8 @@ public DataFormatCustomizer configureJacksonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.jackson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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-jackson3-avro-starter/src/main/java/org/apache/camel/component/jackson3/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java b/components-starter/camel-jackson3-avro-starter/src/main/java/org/apache/camel/component/jackson3/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java index be1976938a6b..3c18f08b642c 100644 --- a/components-starter/camel-jackson3-avro-starter/src/main/java/org/apache/camel/component/jackson3/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson3-avro-starter/src/main/java/org/apache/camel/component/jackson3/avro/springboot/JacksonAvroDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureJacksonAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.avro-jackson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { diff --git a/components-starter/camel-jackson3-protobuf-starter/src/main/java/org/apache/camel/component/jackson3/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java b/components-starter/camel-jackson3-protobuf-starter/src/main/java/org/apache/camel/component/jackson3/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java index ce38d269076e..b60d3541bf7c 100644 --- a/components-starter/camel-jackson3-protobuf-starter/src/main/java/org/apache/camel/component/jackson3/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson3-protobuf-starter/src/main/java/org/apache/camel/component/jackson3/protobuf/springboot/JacksonProtobufDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureJacksonProtobufDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.protobuf-jackson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { diff --git a/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatAutoConfiguration.java b/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatAutoConfiguration.java index 4d47ebce875c..df04ddd5a71e 100644 --- a/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureJacksonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.jackson", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { diff --git a/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatConverter.java b/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatConverter.java index 4acd12c8ed78..e01965aae3f6 100644 --- a/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/springboot/JacksonDataFormatConverter.java +++ b/components-starter/camel-jackson3-starter/src/main/java/org/apache/camel/component/jackson3/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.jackson3.SchemaResolver": return applicationContext.getBean(ref, org.apache.camel.component.jackson3.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-jackson3xml-starter/src/main/java/org/apache/camel/component/jackson3xml/springboot/JacksonXMLDataFormatAutoConfiguration.java b/components-starter/camel-jackson3xml-starter/src/main/java/org/apache/camel/component/jackson3xml/springboot/JacksonXMLDataFormatAutoConfiguration.java index 59ab5b92b8e8..beecd35770ee 100644 --- a/components-starter/camel-jackson3xml-starter/src/main/java/org/apache/camel/component/jackson3xml/springboot/JacksonXMLDataFormatAutoConfiguration.java +++ b/components-starter/camel-jackson3xml-starter/src/main/java/org/apache/camel/component/jackson3xml/springboot/JacksonXMLDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureJacksonXMLDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.jackson-xml", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 a87e211e3158..d468809a8f7e 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,7 +63,8 @@ public DataFormatCustomizer configureJacksonXMLDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.jackson-xml", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { diff --git a/components-starter/camel-jactl-starter/src/main/java/org/apache/camel/language/jactl/springboot/JactlLanguageAutoConfiguration.java b/components-starter/camel-jactl-starter/src/main/java/org/apache/camel/language/jactl/springboot/JactlLanguageAutoConfiguration.java index b33b5f30bb9c..bfbacf163cf4 100644 --- a/components-starter/camel-jactl-starter/src/main/java/org/apache/camel/language/jactl/springboot/JactlLanguageAutoConfiguration.java +++ b/components-starter/camel-jactl-starter/src/main/java/org/apache/camel/language/jactl/springboot/JactlLanguageAutoConfiguration.java @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureJactlLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.jactl", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 f82d9bc5fab4..edbf76179546 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureJavaScriptLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.js", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 30d473095d34..a2527c706270 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,7 +63,8 @@ public DataFormatCustomizer configureJaxbDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.jaxb", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 8af147a980e5..ec563bf112df 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJCacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jcache", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d0d4fad97e9a..8f6d5c612079 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJcrComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jcr", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0cf73cf2c848..b44d26718fd8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJdbcComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jdbc", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 73db943f0b6b..ec9f55501058 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJettyHttpComponent12() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jetty", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4187a95463ac..5bcf015ee0fc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJGroupsRaftComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jgroups-raft", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9d27b03883cf..3cafa3968de5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJGroupsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jgroups", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8bc0725ee17f..0f032efb0672 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJiraComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jira", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 12c0698ef670..3c046fe1967e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJmsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jms", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5f75ac25f7ba..540e7bd4c749 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJMXComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jmx", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e3e28c338a9c..2b0ee73b7ec1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJoltComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jolt", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f44bc085b01f..6aac2b7214ff 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJooqComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jooq", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2a3c3f05d654..b89d7cfe2d18 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureJavaLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.java", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 68db4126a0e9..62b0d036ce41 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureJoorLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.joor", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 58fb4bab22bf..0d5210965351 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJpaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jpa", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c5962a7a3abb..65e600696031 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureJqLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.jq", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 f7b2602b6278..9bf8ce1051b1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureScpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.scp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 374d46638537..95c6de2988f2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJsltComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jslt", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e7d5d69645cd..ed58dffffe19 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJsonValidatorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.json-validator", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8b0a0ed7d080..f684096acc26 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,7 +63,8 @@ public DataFormatCustomizer configureJsonApiDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.json-api", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 b5068f164860..e63a94f2cee6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJsonataComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jsonata", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 622f997eecbe..0b7d0636777a 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,7 +63,8 @@ public DataFormatCustomizer configureJsonbDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.jsonb", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 cb52748add84..22eaa580dc0f 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureJsonPathLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.jsonpath", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 faf8f5d5a4cf..00bf69896482 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJt400Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jt400", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 da9c8fad22c0..c2feb8586b5e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureJteComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.jte", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 be97069f6f2c..3cc0b17e2d12 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKafkaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kafka", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 28162916e218..ef0060a082ae 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKameletComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kamelet", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2211d739cf86..5d426b5e416a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKeycloakComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.keycloak", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8cd72669ee95..61953751deb6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKnativeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.knative", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6414cf70274d..074083504b1e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKServeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kserve", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 dc1378ff73a0..8187124fbf3d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesConfigMapsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-config-maps", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 029be59f0cf4..20bcbea9ef15 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesCronJobComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-cronjob", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 297d0cce3043..78fd6c1c6c20 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesCustomResourcesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-custom-resources", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 527096327f34..6ce42656d0c6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesDeploymentsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-deployments", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6288e6e3c9e5..a0200cded6b2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesEventsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-events", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9b054c11a8ad..593f0effd96a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesHPAComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-hpa", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d465ed52aceb..7b8912a6d107 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesJobComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-job", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4303d7c17bb2..2e94e6b8b7af 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesNamespacesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-namespaces", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6f4a8f83893f..005f1dd47b0a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesNodesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-nodes", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9bd6698c8f37..b2e52922b4b9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesPersistentVolumesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-persistent-volumes", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 14c69c0bafe5..4975cb8c3ae1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesPersistentVolumesClaimsComponent() return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-persistent-volumes-claims", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6447d42b6284..c392c0000e6a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesPodsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-pods", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d5c148f81f73..f4ad0a46bd72 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesReplicationControllersComponent() return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-replication-controllers", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0392d8f56274..29646b07ce82 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesResourcesQuotaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-resources-quota", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5b60452660d3..4f89cacc4b25 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesSecretsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-secrets", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b6e7d729e443..913e499751fb 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesServiceAccountsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-service-accounts", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5ea7bf4a3da7..491de785f7c7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKubernetesServicesComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kubernetes-services", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ea6ac21ca619..6de0441f2faf 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOpenshiftBuildConfigsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openshift-build-configs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 da6564bf6273..eef32c6f81f9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOpenshiftBuildsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openshift-builds", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e16a983a6d0b..a638fdc5f1c9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOpenshiftDeploymentConfigsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openshift-deploymentconfigs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7f2ffb9c40b0..14ce5ce88c71 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKuduComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.kudu", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 370ee78a0190..9b50035dc113 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLangChain4jAgentComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-agent", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 594dd2cbdf95..26e551b0f653 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; @@ -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.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.AgentConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.agent.api.AgentConfiguration.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 9ddbe4ca6d28..9dadfacf188e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLangChain4jChatComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-chat", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1d2c9b3e7982..aded4791135c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLangChain4jEmbeddingsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-embeddings", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a22afdb50cba..f85942238193 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLangChain4jEmbeddingStoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-embeddingstore", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 13bdb693d6a4..51d83a395344 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; @@ -52,20 +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.langchain4j.embeddingstore.LangChain4jEmbeddingStoreConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.langchain4j.embeddingstore.LangChain4jEmbeddingStoreConfiguration.class); - case "dev.langchain4j.model.embedding.EmbeddingModel": return applicationContext.getBean(ref, dev.langchain4j.model.embedding.EmbeddingModel.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 c8e87d3b8678..9b15de4ac302 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLangChain4jWebSearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.langchain4j-web-search", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 26cf6d9f77c8..591d5c17873b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLanguageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.language", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c57225df69b4..cb9617f1fec2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLdapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ldap", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bf1fc17a6ef0..52d433f32699 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLdifComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ldif", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c92c978680d3..989b1a989030 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLogComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.log", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f1912484f39b..a0f538849a42 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLuceneComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.lucene", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 242c7a578e36..7cfa7ab380f0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureLumberjackComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.lumberjack", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d7a60eb0ff29..e2b074c41338 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,7 +63,8 @@ public DataFormatCustomizer configureLZFDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.lzf", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 684fd0fcb46a..9eb77db68210 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMailComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mail", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 53ef0d8a2559..f6bab48d3be1 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,7 +63,8 @@ public DataFormatCustomizer configureMimeMultipartDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.mime-multipart", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 d4636c931350..c5e720db9c2d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMapstructComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mapstruct", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fffed76e5ee1..62a5741533bc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMasterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.master", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d1d58c658c8c..faa720058bb3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMetricsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.metrics", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0fdd18d953ab..09cfe7169e5b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMicrometerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.micrometer", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e1edbb945fdb..99fadb9c1b75 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMiloBrowseComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milo-browse", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c33b189890a8..14c532265fca 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMiloClientComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milo-client", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f6b12af73e8f..a776b5cedf74 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMiloServerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milo-server", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2f5b03e5ca2c..c768bf81ce72 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMilvusComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.milvus", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a70db9893ee3..b5a5a9614068 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMinaSftpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mina-sftp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 15da810b8b30..df1f4d9f2cc7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMinaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mina", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 be22d3514528..7cdfa030a789 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMinioComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.minio", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d7fdf9b1b60d..cbc21e68465d 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,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.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.ServerSideEncryption.CustomerKey": return applicationContext.getBean(ref, io.minio.ServerSideEncryption.CustomerKey.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 56b430e8a405..6f4f355ab5d9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMllpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mllp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 80e1c910c945..abd65c9ae6b9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMockComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mock", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 635b91e20d1e..5d212e0d939b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGridFsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mongodb-gridfs", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0d047fb83bce..ce2253cd6782 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMongoDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mongodb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7f8e010f3a58..8f8b8ec74d42 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMustacheComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mustache", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 71f93265b0d9..bb636667d2f1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMvelComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mvel", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f4957ac06ffa..14ed84e22d97 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureMvelLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.mvel", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 ad9720e73e3f..573f7f01d350 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMyBatisBeanComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mybatis-bean", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 de23d31ed7c3..e1bf8f2718fd 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMyBatisComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.mybatis", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e37d4be44cd9..3dc198080fd1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNatsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.nats", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4de12dc5339c..858718ce937d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNeo4jComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.neo4j", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1a4fdaed8a64..48d8206b234f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNettyHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.netty-http", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b7752d4f9e86..0d7f88594871 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNettyComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.netty", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 844140943366..0531002aec12 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOAIPMHComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.oaipmh", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fd6c33f81ad1..c397a283b671 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,7 +63,8 @@ public DataFormatCustomizer configureOcsfDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.ocsf", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 d4145406012c..8375c7c7767b 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureOgnlLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.ognl", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 d12455683d7e..31d5d40294e1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOlingo2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.olingo2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b7eaa5827d41..c826f42c9adf 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOlingo4Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.olingo4", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8ebc7b9585f0..755af33ebabe 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOnceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.once", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f43952809c13..80077da2c334 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOpenAIComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openai", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4416933aea5e..8b01165d9003 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOpensearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.opensearch", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 00292ec34372..3671c5dc62c2 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; @@ -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.opensearch.client.RestClient": return applicationContext.getBean(ref, org.opensearch.client.RestClient.class); - case "org.opensearch.client.opensearch.OpenSearchClient": return applicationContext.getBean(ref, org.opensearch.client.opensearch.OpenSearchClient.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.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 243eb3d2367f..fc555fba7587 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureCinderComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-cinder", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 29305f4424eb..100f36c0562b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureGlanceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-glance", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a53c13d31d40..65caaec7be50 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureKeystoneComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-keystone", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6654f32d64bd..4f9d2423f8dd 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNeutronComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-neutron", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 21ad8510b7fb..af8bb07e6ff8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNovaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-nova", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b10eac6c55a0..7df3f7cf8062 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSwiftComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.openstack-swift", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f8a882db9ca7..de914c7a04dc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOpenTelemetryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.opentelemetry-metrics", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a444fafe07bf..c49d181d4379 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureOptaPlannerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.optaplanner", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8f384f0b7d6b..8eee26661fd7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePahoMqtt5Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.paho-mqtt5", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3599cd467801..0383bb6531d5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePahoComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.paho", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 7efddecc70f8..89b96ea4d49f 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,7 +63,8 @@ public DataFormatCustomizer configureParquetAvroDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.parquet-avro", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 9344f9733eb2..a167e137eae2 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePdfComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pdf", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e79045e1714d..bcbc7f1cb7de 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePgReplicationSlotComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pg-replication-slot", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6bca7cb54b53..25ea210e0d2a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePgEventComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pgevent", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c8244130ef95..461c110b3db9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePineconeVectorDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pinecone", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 83a324ff73f0..4e980920d0de 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePlatformHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.platform-http", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4324c60720ac..e00e2bc4130e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePlc4XComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.plc4x", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 980e433227a3..033878cf41c3 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,7 +63,8 @@ public DataFormatCustomizer configurePQCDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.pqc", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 fb8cd6d1827a..e1e0b14fe9ad 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePQCComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pqc", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4f0fd753b9bd..a8794dc20ed9 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; @@ -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.pqc.PQCConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.pqc.PQCConfiguration.class); - case "javax.crypto.KeyAgreement": return applicationContext.getBean(ref, javax.crypto.KeyAgreement.class); - case "java.security.KeyPair": return applicationContext.getBean(ref, java.security.KeyPair.class); - case "java.security.Signature": return applicationContext.getBean(ref, java.security.Signature.class); - case "javax.crypto.KeyGenerator": return applicationContext.getBean(ref, javax.crypto.KeyGenerator.class); - case "org.apache.camel.component.pqc.lifecycle.KeyLifecycleManager": return applicationContext.getBean(ref, org.apache.camel.component.pqc.lifecycle.KeyLifecycleManager.class); - case "java.security.KeyStore": return applicationContext.getBean(ref, java.security.KeyStore.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 840b60c4ce03..e41d02beab10 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePrinterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.lpr", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d137764bd43e..896793fd7ae6 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,7 +63,8 @@ public DataFormatCustomizer configureProtobufDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.protobuf", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 7f35725daa28..8d471680be42 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePubNubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pubnub", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 138d008e9d39..a5b8920cf84f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configurePulsarComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.pulsar", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fa0ec2bf11ab..55436b86217e 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configurePythonLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.python", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } diff --git a/components-starter/camel-python3-starter/src/main/java/org/apache/camel/language/python3/springboot/Python3LanguageAutoConfiguration.java b/components-starter/camel-python3-starter/src/main/java/org/apache/camel/language/python3/springboot/Python3LanguageAutoConfiguration.java index 22fd14c8901c..6a30db25c67a 100644 --- a/components-starter/camel-python3-starter/src/main/java/org/apache/camel/language/python3/springboot/Python3LanguageAutoConfiguration.java +++ b/components-starter/camel-python3-starter/src/main/java/org/apache/camel/language/python3/springboot/Python3LanguageAutoConfiguration.java @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configurePython3Language() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.python3", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 e7578f101fac..dc9893fa00fc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureQdrantComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.qdrant", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 dd77892f4633..772407de5c59 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureQuartzComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.quartz", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d9bb2c673714..36fe9d470bb0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureQuickfixjComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.quickfix", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-quickjs-starter/src/main/java/org/apache/camel/language/quickjs/springboot/QuickjsLanguageAutoConfiguration.java b/components-starter/camel-quickjs-starter/src/main/java/org/apache/camel/language/quickjs/springboot/QuickjsLanguageAutoConfiguration.java index 51f2968ee6cd..81b93fba30df 100644 --- a/components-starter/camel-quickjs-starter/src/main/java/org/apache/camel/language/quickjs/springboot/QuickjsLanguageAutoConfiguration.java +++ b/components-starter/camel-quickjs-starter/src/main/java/org/apache/camel/language/quickjs/springboot/QuickjsLanguageAutoConfiguration.java @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureQuickjsLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.quickjs", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 26c7d3912107..6ac5b173e77e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureReactiveStreamsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.reactive-streams", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e85b8ae1e2c8..f4a0ee8665db 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRefComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ref", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6c075dbc9261..6128ed0fc6f3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRestOpenApiComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest-openapi", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentAutoConfiguration.java b/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentAutoConfiguration.java index f3d23feb3479..1999652e0181 100644 --- a/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentAutoConfiguration.java +++ b/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureRestPostmanComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest-postman", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentConverter.java b/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentConverter.java index 80383e391d8f..cbf86b7ca77f 100644 --- a/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentConverter.java +++ b/components-starter/camel-rest-postman-starter/src/main/java/org/apache/camel/component/rest/postman/springboot/RestPostmanComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.rest.postman.RestPostmanProcessorStrategy": return applicationContext.getBean(ref, org.apache.camel.component.rest.postman.RestPostmanProcessorStrategy.class); - case "org.apache.camel.component.rest.postman.RestPostmanConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.rest.postman.RestPostmanConfiguration.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-postman"); } } \ 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 c9841c905040..a608bedef10a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRestApiComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest-api", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b1df336e4e68..fadf7d0ed588 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRestComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rest", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6419124730ca..e1efce23264c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRobotFrameworkComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.robotframework", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5a6dda0cce92..c4dc9cec8736 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRocketMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rocketmq", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 acb547121475..baf71d24b3a1 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRssComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.rss", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b67ecd368d6b..92ccc467eeb4 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,7 +63,8 @@ public DataFormatCustomizer configureRssDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.rss", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 76dfeb110dbb..91a85ff32f9c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSagaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.saga", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 725ceb483b56..494f1188ebe4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSalesforceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.salesforce", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 6718ee175728..18dd49c2b8f6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureNetWeaverComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sap-netweaver", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1612945d2a83..03c4e4bf81ff 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXQueryComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xquery", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c3466bf0d504..568a78dcdcac 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureXQueryLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.xquery", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 6135144a9d00..d234bc8e7690 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSchedulerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.scheduler", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 8ab492b6a010..cc98a3c5985e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSchematronComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.schematron", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d00d34e24b40..365dcfd7cd09 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSedaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.seda", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0dad24ad823b..2e85b7833850 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureServiceNowComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.servicenow", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 57f8baf1c87c..baf64d4b9fd7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureServletComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.servlet", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b04e87f2240e..3e65a5a63dc8 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSjmsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sjms", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5e21c76760a5..6cae29a88c2a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSjms2Component() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sjms2", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1a52ef1062d8..30a6e93cd6bb 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSlackComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.slack", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9c96ad9a4bb3..d6cd75ce867f 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSmbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.smb", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 a20ab5bd2a97..667b5b378dc3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSmooksComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.smooks", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9d91804e8639..36018e8c5891 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,7 +63,8 @@ public DataFormatCustomizer configureSmooksDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.smooks", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 7e1d55e6dc38..044ddde18bf6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSmppComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.smpp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3ac04e24409f..073f50a09878 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,7 +63,8 @@ public DataFormatCustomizer configureSnakeYAMLDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.snake-yaml", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 4c0b8a69433a..c2014a7bc704 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSnmpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.snmp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3b26d8950ba2..96a3229e5686 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,7 +63,8 @@ public DataFormatCustomizer configureSoapDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.soap", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 b5a61bbfafbb..4d166d54a347 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSolrComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.solr", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bc5ace9246d6..6796e6c114eb 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; @@ -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.solr.client.solrj.SolrClient": return applicationContext.getBean(ref, org.apache.solr.client.solrj.SolrClient.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.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 26301dc04443..f56ab1ac59b4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSplunkHECComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.splunk-hec", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 35859d23baac..b37e9df93fba 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringAiChatComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-chat", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 bbb1b39939c0..8dbad8c11972 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringAiEmbeddingsComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-embeddings", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentAutoConfiguration.java b/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentAutoConfiguration.java index 08f19672bdb0..62cf5ebf5c26 100644 --- a/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentAutoConfiguration.java +++ b/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentAutoConfiguration.java @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringAiImageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-image", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentConverter.java b/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentConverter.java index cda1c1321bb2..d65134d86dc1 100644 --- a/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentConverter.java +++ b/components-starter/camel-spring-ai-image-starter/src/main/java/org/apache/camel/component/springai/image/springboot/SpringAiImageComponentConverter.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set; +import org.apache.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.image.SpringAiImageConfiguration": return applicationContext.getBean(ref, org.apache.camel.component.springai.image.SpringAiImageConfiguration.class); - case "org.springframework.ai.image.ImageModel": return applicationContext.getBean(ref, org.springframework.ai.image.ImageModel.class); - } - return null; + return BeanReferenceHelper.resolveBeanReference(applicationContext, source, targetType, "camel.component.spring-ai-image"); } } \ 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 d7e626476d4d..b08372cd511c 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringAiVectorStoreComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ai-vector-store", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b29e65b69426..bfaac7cde70a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringBatchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-batch", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 0aa2cd22cff8..3cf72a494588 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringJdbcComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-jdbc", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ba31d118868e..14d9441b2aed 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringLdapComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ldap", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 901bbc079b61..b1cfd8fd42b7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringRabbitMQComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-rabbitmq", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e662f6265a0a..52aed6eb142e 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,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.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.amqp.rabbit.config.StatelessRetryOperationsInterceptor": return applicationContext.getBean(ref, org.springframework.amqp.rabbit.config.StatelessRetryOperationsInterceptor.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 eab3d865c79c..a58b3ceffb94 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureRedisComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-redis", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ca680e905fd2..34056787723a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureEventComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-event", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 12978ffc209b..24804350b4fc 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureSpelLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.spel", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 fb5258dde0e0..0a54d630e282 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSpringWebserviceComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.spring-ws", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2cb2ab1f4525..1af7271ad557 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSqlComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sql", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4a5f0729459b..7e44fff23c73 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSqlStoredComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.sql-stored", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 5715eb5e6a83..43180d010afe 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureSshComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.ssh", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e566a3c7db9c..e25b4aaff2be 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStAXComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stax", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d86801ac8b15..0766adae3343 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureXMLTokenizeLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.xtokenize", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 38ad051973b1..de81b178e9e6 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStitchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stitch", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 186ed0d5fc24..7a27676c1903 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStreamComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stream", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 cdda3bb17b52..4c731d8c1196 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStringTemplateComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.string-template", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 635153952b40..1e56ae960ba3 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStripeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stripe", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 32547add7dd9..2714cb8436cc 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureStubComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.stub", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f3c30eb05e7d..1de569c803d5 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,7 +63,8 @@ public DataFormatCustomizer configureSwiftMtDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.swift-mt", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 e7349915e605..179a1dbeb76c 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,7 +63,8 @@ public DataFormatCustomizer configureSwiftMxDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.swift-mx", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 b0d6fbd1b84d..a1883a73a935 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,7 +63,8 @@ public DataFormatCustomizer configureSyslogDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.syslog", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 334fbbb46566..2706b78b1d58 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTahuEdgeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tahu-edge", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4c460058921d..1519c98a2604 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTahuHostComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tahu-host", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 4779bc6663e8..f11ed8347394 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,7 +63,8 @@ public DataFormatCustomizer configureTarFileDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.tar-file", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 106a629117b2..0c369c1307cb 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTelegramComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.telegram", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e68bc9aedc26..ac7dcc1454f7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTensorFlowServingComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tensorflow-serving", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 abce0484bc28..c5c3b5793836 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureThriftComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.thrift", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 9124214aa3a0..f26431a6dcfa 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,7 +63,8 @@ public DataFormatCustomizer configureThriftDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.thrift", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 28495773ee6f..b0aed022c6d0 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureThymeleafComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.thymeleaf", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fc24233ea401..c0490bd66f9e 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTikaComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.tika", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c48a00d8c2c1..478697a27fd7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTimerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.timer", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-toon-starter/src/main/java/org/apache/camel/dataformat/toon/springboot/ToonDataFormatAutoConfiguration.java b/components-starter/camel-toon-starter/src/main/java/org/apache/camel/dataformat/toon/springboot/ToonDataFormatAutoConfiguration.java index f1219e8aeff0..5f3f0eedfea8 100644 --- a/components-starter/camel-toon-starter/src/main/java/org/apache/camel/dataformat/toon/springboot/ToonDataFormatAutoConfiguration.java +++ b/components-starter/camel-toon-starter/src/main/java/org/apache/camel/dataformat/toon/springboot/ToonDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureToonDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.toon", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 bb094f618745..b3923a374c26 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTwilioComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twilio", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b9b0b18eaeb9..0d65fd4ba8ae 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTwitterDirectMessageComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twitter-directmessage", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f095aecf7d0d..a6f6f3906934 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTwitterSearchComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twitter-search", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 18d13b231145..0fc8cb901c82 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureTwitterTimelineComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.twitter-timeline", configuration, target); } @Override public boolean isEnabled(String name, Component target) { diff --git a/components-starter/camel-ubl-starter/src/main/java/org/apache/camel/component/ubl/springboot/UblDataFormatAutoConfiguration.java b/components-starter/camel-ubl-starter/src/main/java/org/apache/camel/component/ubl/springboot/UblDataFormatAutoConfiguration.java index edc72f836a44..225950262e26 100644 --- a/components-starter/camel-ubl-starter/src/main/java/org/apache/camel/component/ubl/springboot/UblDataFormatAutoConfiguration.java +++ b/components-starter/camel-ubl-starter/src/main/java/org/apache/camel/component/ubl/springboot/UblDataFormatAutoConfiguration.java @@ -63,7 +63,8 @@ public DataFormatCustomizer configureUblDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.ubl", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 b1332985e9df..e68f4f654c69 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureUndertowComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.undertow", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 d3cd2d45a716..d5df497fabb6 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,7 +63,8 @@ public DataFormatCustomizer configureUniVocityCsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.univocity-csv", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 e0f7cf0ccb90..b61e49f385a2 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,7 +63,8 @@ public DataFormatCustomizer configureUniVocityFixedDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.univocity-fixed", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 ac1bdb1ebde5..1e024b91bd9b 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,7 +63,8 @@ public DataFormatCustomizer configureUniVocityTsvDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.univocity-tsv", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 d1dfe4d21508..a7c88c1ed56a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureValidatorComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.validator", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 26e8c71a69fb..57f20ddb9146 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureVelocityComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.velocity", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 51ec25f0f29a..0664ee5aa680 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureVertxHttpComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.vertx-http", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 043735093168..45ffd3a428b9 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureVertxComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.vertx", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 93f026fe3c44..c4844f9ea1ce 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureVertxWebsocketComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.vertx-websocket", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f81a1e7db4f4..e05aa634626d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWasmComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.wasm", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1afdd92ee3d6..66663726da28 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureWasmLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.wasm", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 0aaad41e09cb..6ce07d1577ac 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWeatherComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.weather", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 158da45bbf3f..dcf7b1db384b 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWeaviateVectorDbComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.weaviate", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3a7b37fc166e..d19098b1a16a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWeb3jComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.web3j", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 c7666a2fb0de..7eea81bb5678 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWebhookComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.webhook", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 e0db4be49304..edc4c4febd23 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWhatsAppComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.whatsapp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 ff9eebd03344..41d6610e49c4 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWordpressComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.wordpress", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 cca6801b4acb..05a421e05077 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureWorkdayComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.workday", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 2ae24c43207f..85e8d2bd7a49 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXChangeComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xchange", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b202360ba0bb..5a64b753d119 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXJComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xj", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 b13fc716e687..f73b4d97fed7 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXmlSignerComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xmlsecurity-sign", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 f3265f6c8888..a671c21f6b07 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXmlVerifierComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xmlsecurity-verify", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 26855ef8c6ff..9fe5f1da663c 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,7 +63,8 @@ public DataFormatCustomizer configureXMLSecurityDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.xml-security", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 08f6658cbdfd..7260cd6ef892 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXmppComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xmpp", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 168450f16f4a..ca34f2ae8180 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 @@ -61,7 +61,8 @@ public org.apache.camel.spi.LanguageCustomizer configureXPathLanguage() { @Override public void configure(String name, Language target) { if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) { - CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(cca.getCamelContext(), applicationContext, + "camel.language.xpath", configuration, target); } else { org.slf4j.LoggerFactory.getLogger(getClass()).debug("Language {} does not implement CamelContextAware, skipping auto-configuration properties", name); } 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 5eae11a250ef..6be05e003953 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXsltSaxonComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xslt-saxon", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 df655ecee060..0886e53355f5 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureXsltComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.xslt", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 3550b4ed647b..eb6c54334e8d 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureZendeskComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.zendesk", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 1daa8a77380d..d36314c363ad 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,7 +63,8 @@ public DataFormatCustomizer configureGzipDeflaterDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.gzip-deflater", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 2d2f5f04aa2c..f292a1c45037 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,7 +63,8 @@ public DataFormatCustomizer configureZipDeflaterDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.zip-deflater", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 9b39fde48d78..9eca35074d66 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,7 +63,8 @@ public DataFormatCustomizer configureZipFileDataFormatFactory() { return new DataFormatCustomizer() { @Override public void configure(String name, DataFormat target) { - CamelPropertiesHelper.copyProperties(camelContextProvider.getObject(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(camelContextProvider.getObject(), applicationContext, + "camel.dataformat.zip-file", configuration, target); } @Override public boolean isEnabled(String name, DataFormat target) { 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 4f09a831553d..f9d09894c548 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureMasterComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.zookeeper-master", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 fba1830bdf8e..18318b61ad4a 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 @@ -58,7 +58,8 @@ public ComponentCustomizer configureZooKeeperComponent() { return new ComponentCustomizer() { @Override public void configure(String name, Component target) { - CamelPropertiesHelper.copyProperties(target.getCamelContext(), configuration, target); + CamelPropertiesHelper.copyConfigurationProperties(target.getCamelContext(), applicationContext, + "camel.component.zookeeper", configuration, target); } @Override public boolean isEnabled(String name, Component target) { 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 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 5c360d573e62..8989cb412117 100644 --- a/core/camel-spring-boot/src/main/docs/spring-boot.json +++ b/core/camel-spring-boot/src/main/docs/spring-boot.json @@ -1335,6 +1335,12 @@ "description": "Security policy for plain-text secrets. When set, overrides the global policy for properties that contain sensitive values configured as plain text.", "sourceType": "org.apache.camel.spring.boot.security.CamelSecurityPolicyConfigurationProperties" }, + { + "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 new file mode 100644 index 000000000000..8c8aa810982d --- /dev/null +++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/util/BeanReferenceHelper.java @@ -0,0 +1,195 @@ +/* + * 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 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; + +/** + * 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: + *