http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java index 2590ac0..95e7bc5 100644 --- a/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-chunk-starter/src/main/java/org/apache/camel/component/chunk/springboot/ChunkComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.chunk.ChunkComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class ChunkComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(ChunkComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private ChunkComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<ChunkComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private ChunkComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class ChunkComponentAutoConfiguration { ChunkComponent component = new ChunkComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class ChunkComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<ChunkComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.chunk.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.chunk.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component;
http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java index 4fdf432..0513a9d 100644 --- a/platforms/spring-boot/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-cm-sms-starter/src/main/java/org/apache/camel/component/cm/springboot/CMComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.cm.CMComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class CMComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(CMComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private CMComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<CMComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private CMComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class CMComponentAutoConfiguration { CMComponent component = new CMComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class CMComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<CMComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.cm-sms.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.cm-sms.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java index e40d1d9..a3e3919 100644 --- a/platforms/spring-boot/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-cmis-starter/src/main/java/org/apache/camel/component/cmis/springboot/CMISComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.cmis.CMISComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class CMISComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(CMISComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private CMISComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<CMISComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private CMISComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class CMISComponentAutoConfiguration { CMISComponent component = new CMISComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class CMISComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<CMISComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.cmis.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.cmis.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java index 8ef4049..924acda 100644 --- a/platforms/spring-boot/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-coap-starter/src/main/java/org/apache/camel/coap/springboot/CoAPComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.coap.CoAPComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class CoAPComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(CoAPComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private CoAPComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<CoAPComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private CoAPComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class CoAPComponentAutoConfiguration { CoAPComponent component = new CoAPComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class CoAPComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<CoAPComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.coap.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.coap.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java index 160ba57..960b9dd 100644 --- a/platforms/spring-boot/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-cometd-starter/src/main/java/org/apache/camel/component/cometd/springboot/CometdComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.cometd.CometdComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class CometdComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(CometdComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private CometdComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<CometdComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private CometdComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class CometdComponentAutoConfiguration { CometdComponent component = new CometdComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class CometdComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<CometdComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.cometd.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.cometd.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java index c80838a..0d586ef 100644 --- a/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-consul-starter/src/main/java/org/apache/camel/component/consul/springboot/ConsulComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.consul.ConsulComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class ConsulComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(ConsulComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private ConsulComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<ConsulComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private ConsulComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class ConsulComponentAutoConfiguration { ConsulComponent component = new ConsulComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class ConsulComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<ConsulComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.consul.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.consul.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-context-starter/src/main/java/org/apache/camel/component/context/springboot/QualifiedContextComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-context-starter/src/main/java/org/apache/camel/component/context/springboot/QualifiedContextComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-context-starter/src/main/java/org/apache/camel/component/context/springboot/QualifiedContextComponentAutoConfiguration.java index 5b1142e..d622147 100644 --- a/platforms/spring-boot/components-starter/camel-context-starter/src/main/java/org/apache/camel/component/context/springboot/QualifiedContextComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-context-starter/src/main/java/org/apache/camel/component/context/springboot/QualifiedContextComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.context.QualifiedContextComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class QualifiedContextComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(QualifiedContextComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private QualifiedContextComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<QualifiedContextComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private QualifiedContextComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -78,8 +81,8 @@ public class QualifiedContextComponentAutoConfiguration { QualifiedContextComponent component = new QualifiedContextComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -102,14 +105,23 @@ public class QualifiedContextComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<QualifiedContextComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.context.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.context.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java index e88d559..c105de7 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/bean/springboot/BeanComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.bean.BeanComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class BeanComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(BeanComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private BeanComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<BeanComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private BeanComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class BeanComponentAutoConfiguration { BeanComponent component = new BeanComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class BeanComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<BeanComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.bean.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.bean.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java index 6f2346e..fbc8382 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/beanclass/springboot/ClassComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.beanclass.ClassComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class ClassComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(ClassComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private ClassComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<ClassComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private ClassComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class ClassComponentAutoConfiguration { ClassComponent component = new ClassComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class ClassComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<ClassComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.class.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.class.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/binding/springboot/BindingNameComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/binding/springboot/BindingNameComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/binding/springboot/BindingNameComponentAutoConfiguration.java index b75d31d..e24b90b 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/binding/springboot/BindingNameComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/binding/springboot/BindingNameComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.binding.BindingNameComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class BindingNameComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(BindingNameComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private BindingNameComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<BindingNameComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private BindingNameComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -78,8 +81,8 @@ public class BindingNameComponentAutoConfiguration { BindingNameComponent component = new BindingNameComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -102,14 +105,23 @@ public class BindingNameComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<BindingNameComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.binding.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.binding.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java index 51a5a48..1ea0571 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/browse/springboot/BrowseComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.browse.BrowseComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class BrowseComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(BrowseComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private BrowseComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<BrowseComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private BrowseComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class BrowseComponentAutoConfiguration { BrowseComponent component = new BrowseComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class BrowseComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<BrowseComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.browse.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.browse.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java index e058778..75f7818 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/controlbus/springboot/ControlBusComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.controlbus.ControlBusComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class ControlBusComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(ControlBusComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private ControlBusComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<ControlBusComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private ControlBusComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class ControlBusComponentAutoConfiguration { ControlBusComponent component = new ControlBusComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class ControlBusComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<ControlBusComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.controlbus.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.controlbus.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java index e4e52df..5693f66 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataformat/springboot/DataFormatComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.dataformat.DataFormatComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class DataFormatComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(DataFormatComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private DataFormatComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<DataFormatComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private DataFormatComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class DataFormatComponentAutoConfiguration { DataFormatComponent component = new DataFormatComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class DataFormatComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<DataFormatComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.dataformat.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.dataformat.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java index f980917..93f5f90 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/dataset/springboot/DataSetComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.dataset.DataSetComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class DataSetComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(DataSetComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private DataSetComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<DataSetComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private DataSetComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class DataSetComponentAutoConfiguration { DataSetComponent component = new DataSetComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class DataSetComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<DataSetComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.dataset.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.dataset.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java index 8af5edd..05bd34b 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/direct/springboot/DirectComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.direct.DirectComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class DirectComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(DirectComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private DirectComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<DirectComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private DirectComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class DirectComponentAutoConfiguration { DirectComponent component = new DirectComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class DirectComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<DirectComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.direct.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.direct.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component; http://git-wip-us.apache.org/repos/asf/camel/blob/1ca7a426/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentAutoConfiguration.java index 36e0f82..bfd4a08 100644 --- a/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-core-starter/src/main/java/org/apache/camel/component/directvm/springboot/DirectVmComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.directvm.DirectVmComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class DirectVmComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(DirectVmComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private DirectVmComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<DirectVmComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private DirectVmComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class DirectVmComponentAutoConfiguration { DirectVmComponent component = new DirectVmComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class DirectVmComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<DirectVmComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.direct-vm.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.direct-vm.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component;
