http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConfiguration.java index 41bf0ce..61744bc 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/ringbuffer/springboot/HazelcastRingbufferComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.hazelcast.ringbuffer.springboot; import javax.annotation.Generated; import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -29,7 +30,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hazelcast-ringbuffer") -public class HazelcastRingbufferComponentConfiguration { +public class HazelcastRingbufferComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The hazelcast instance reference which can be used for hazelcast
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java index 57df3a1..bc75276 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentAutoConfiguration.java @@ -17,50 +17,84 @@ package org.apache.camel.component.hazelcast.seda.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hazelcast.seda.HazelcastSedaComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HazelcastSedaComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HazelcastSedaComponentConfiguration.class) -public class HazelcastSedaComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HazelcastSedaComponentConfiguration.class}) +public class HazelcastSedaComponentAutoConfiguration + extends + AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HazelcastSedaComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HazelcastSedaComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HazelcastSedaComponentConfiguration componentConfiguration; + + public HazelcastSedaComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hazelcast-seda"); + } + } @Lazy @Bean(name = "hazelcast-seda-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HazelcastSedaComponent.class) - public HazelcastSedaComponent configureHazelcastSedaComponent( - CamelContext camelContext, - HazelcastSedaComponentConfiguration configuration) throws Exception { + public HazelcastSedaComponent configureHazelcastSedaComponent() + throws Exception { HazelcastSedaComponent component = new HazelcastSedaComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -83,32 +117,16 @@ public class HazelcastSedaComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hazelcast-seda"); - if (isEnabled(conditionContext, "camel.component.hazelcast-seda.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HazelcastSedaComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConfiguration.java index 33ead30..3cc79c3 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/seda/springboot/HazelcastSedaComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.hazelcast.seda.springboot; import javax.annotation.Generated; import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -28,7 +29,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hazelcast-seda") -public class HazelcastSedaComponentConfiguration { +public class HazelcastSedaComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The hazelcast instance reference which can be used for hazelcast http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java index 18717d8..23801f5 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentAutoConfiguration.java @@ -17,50 +17,82 @@ package org.apache.camel.component.hazelcast.set.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hazelcast.set.HazelcastSetComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HazelcastSetComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HazelcastSetComponentConfiguration.class) -public class HazelcastSetComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HazelcastSetComponentConfiguration.class}) +public class HazelcastSetComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HazelcastSetComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HazelcastSetComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HazelcastSetComponentConfiguration componentConfiguration; + + public HazelcastSetComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hazelcast-set"); + } + } @Lazy @Bean(name = "hazelcast-set-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HazelcastSetComponent.class) - public HazelcastSetComponent configureHazelcastSetComponent( - CamelContext camelContext, - HazelcastSetComponentConfiguration configuration) throws Exception { + public HazelcastSetComponent configureHazelcastSetComponent() + throws Exception { HazelcastSetComponent component = new HazelcastSetComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -83,32 +115,16 @@ public class HazelcastSetComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hazelcast-set"); - if (isEnabled(conditionContext, "camel.component.hazelcast-set.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HazelcastSetComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConfiguration.java index 16aa2bf..adb7b11 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/set/springboot/HazelcastSetComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.hazelcast.set.springboot; import javax.annotation.Generated; import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -28,7 +29,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hazelcast-set") -public class HazelcastSetComponentConfiguration { +public class HazelcastSetComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The hazelcast instance reference which can be used for hazelcast http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java index 3d225f4..951a3c0 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentAutoConfiguration.java @@ -17,51 +17,84 @@ package org.apache.camel.component.hazelcast.topic.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hazelcast.topic.HazelcastTopicComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HazelcastTopicComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HazelcastTopicComponentConfiguration.class) -public class HazelcastTopicComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HazelcastTopicComponentConfiguration.class}) +public class HazelcastTopicComponentAutoConfiguration + extends + AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HazelcastTopicComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HazelcastTopicComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HazelcastTopicComponentConfiguration componentConfiguration; + + public HazelcastTopicComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hazelcast-topic"); + } + } @Lazy @Bean(name = "hazelcast-topic-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HazelcastTopicComponent.class) - public HazelcastTopicComponent configureHazelcastTopicComponent( - CamelContext camelContext, - HazelcastTopicComponentConfiguration configuration) + public HazelcastTopicComponent configureHazelcastTopicComponent() throws Exception { HazelcastTopicComponent component = new HazelcastTopicComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -84,32 +117,16 @@ public class HazelcastTopicComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hazelcast-topic"); - if (isEnabled(conditionContext, "camel.component.hazelcast-topic.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HazelcastTopicComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConfiguration.java index 92cf232..c02824b 100644 --- a/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hazelcast-starter/src/main/java/org/apache/camel/component/hazelcast/topic/springboot/HazelcastTopicComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.hazelcast.topic.springboot; import javax.annotation.Generated; import com.hazelcast.core.HazelcastInstance; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -28,7 +29,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hazelcast-topic") -public class HazelcastTopicComponentConfiguration { +public class HazelcastTopicComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The hazelcast instance reference which can be used for hazelcast http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentAutoConfiguration.java index 3ce6fae..a35e8eb 100644 --- a/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.hbase.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hbase.HBaseComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HBaseComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HBaseComponentConfiguration.class) -public class HBaseComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HBaseComponentConfiguration.class}) +public class HBaseComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HBaseComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HBaseComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HBaseComponentConfiguration componentConfiguration; + + public HBaseComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hbase"); + } + } @Lazy @Bean(name = "hbase-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HBaseComponent.class) - public HBaseComponent configureHBaseComponent(CamelContext camelContext, - HBaseComponentConfiguration configuration) throws Exception { + public HBaseComponent configureHBaseComponent() throws Exception { HBaseComponent component = new HBaseComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -82,32 +114,16 @@ public class HBaseComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hbase"); - if (isEnabled(conditionContext, "camel.component.hbase.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HBaseComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentConfiguration.java index a9540d4..cee47fa 100644 --- a/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hbase-starter/src/main/java/org/apache/camel/component/hbase/springboot/HBaseComponentConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.hbase.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.hadoop.conf.Configuration; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -28,7 +29,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hbase") -public class HBaseComponentConfiguration { +public class HBaseComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use the shared configuration http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentAutoConfiguration.java index 2da832e..2b3d597 100644 --- a/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.hdfs.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hdfs.HdfsComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HdfsComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HdfsComponentConfiguration.class) -public class HdfsComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HdfsComponentConfiguration.class}) +public class HdfsComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HdfsComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HdfsComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HdfsComponentConfiguration componentConfiguration; + + public HdfsComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hdfs"); + } + } @Lazy @Bean(name = "hdfs-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HdfsComponent.class) - public HdfsComponent configureHdfsComponent(CamelContext camelContext, - HdfsComponentConfiguration configuration) throws Exception { + public HdfsComponent configureHdfsComponent() throws Exception { HdfsComponent component = new HdfsComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -82,32 +114,16 @@ public class HdfsComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hdfs"); - if (isEnabled(conditionContext, "camel.component.hdfs.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HdfsComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentConfiguration.java index 83f62eb..054e6cc 100644 --- a/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hdfs-starter/src/main/java/org/apache/camel/component/hdfs/springboot/HdfsComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.hdfs.springboot; import javax.annotation.Generated; import javax.security.auth.login.Configuration; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -27,7 +28,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hdfs") -public class HdfsComponentConfiguration { +public class HdfsComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use the given configuration for security with JAAS. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentAutoConfiguration.java index 5e7cc06..1443f2d 100644 --- a/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.hdfs2.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hdfs2.HdfsComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HdfsComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HdfsComponentConfiguration.class) -public class HdfsComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HdfsComponentConfiguration.class}) +public class HdfsComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HdfsComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HdfsComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HdfsComponentConfiguration componentConfiguration; + + public HdfsComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hdfs2"); + } + } @Lazy @Bean(name = "hdfs2-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HdfsComponent.class) - public HdfsComponent configureHdfsComponent(CamelContext camelContext, - HdfsComponentConfiguration configuration) throws Exception { + public HdfsComponent configureHdfsComponent() throws Exception { HdfsComponent component = new HdfsComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -82,32 +114,16 @@ public class HdfsComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hdfs2"); - if (isEnabled(conditionContext, "camel.component.hdfs2.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HdfsComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentConfiguration.java index 4c45bf1..4da121f 100644 --- a/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hdfs2-starter/src/main/java/org/apache/camel/component/hdfs2/springboot/HdfsComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.hdfs2.springboot; import javax.annotation.Generated; import javax.security.auth.login.Configuration; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -27,7 +28,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hdfs2") -public class HdfsComponentConfiguration { +public class HdfsComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use the given configuration for security with JAAS. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatAutoConfiguration.java index 4629150..ea4c243 100644 --- a/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatAutoConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.hessian.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; @@ -24,40 +25,72 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.hessian.HessianDataFormat; import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatCustomizer; import org.apache.camel.spi.DataFormatFactory; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.DataFormatConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HessianDataFormatAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HessianDataFormatConfiguration.class) -public class HessianDataFormatAutoConfiguration { +@EnableConfigurationProperties({DataFormatConfigurationProperties.class, + HessianDataFormatConfiguration.class}) +public class HessianDataFormatAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HessianDataFormatAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<DataFormatCustomizer<HessianDataFormat>> customizers; + @Autowired + private DataFormatConfigurationProperties globalConfiguration; + @Autowired + private HessianDataFormatConfiguration dataformatConfiguration; + + public HessianDataFormatAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class Condition extends GroupCondition { + public Condition() { + super("camel.dataformat", "camel.dataformat.hessian"); + } + } @Bean(name = "hessian-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HessianDataFormat.class) - public DataFormatFactory configureHessianDataFormatFactory( - final CamelContext camelContext, - final HessianDataFormatConfiguration configuration) { + public DataFormatFactory configureHessianDataFormatFactory() + throws Exception { return new DataFormatFactory() { public DataFormat newInstance() { HessianDataFormat dataformat = new HessianDataFormat(); @@ -71,7 +104,7 @@ public class HessianDataFormatAutoConfiguration { } try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, + IntrospectionSupport.getProperties(dataformatConfiguration, parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, @@ -79,34 +112,19 @@ public class HessianDataFormatAutoConfiguration { } catch (Exception e) { throw new RuntimeCamelException(e); } + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && dataformatConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (DataFormatCustomizer<HessianDataFormat> configurer : customizers) { + LOGGER.debug( + "Configure dataformat {}, with configurer {}", + dataformat, configurer); + configurer.customize(dataformat); + } + } return dataformat; } }; } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.dataformat.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.dataformat.hessian"); - if (isEnabled(conditionContext, "camel.dataformat.hessian.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); - } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); - } - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatConfiguration.java index 2a48dc4..f339ba4 100644 --- a/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hessian-starter/src/main/java/org/apache/camel/dataformat/hessian/springboot/HessianDataFormatConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.hessian.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.DataFormatConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -26,7 +27,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.dataformat.hessian") -public class HessianDataFormatConfiguration { +public class HessianDataFormatConfiguration + extends + DataFormatConfigurationPropertiesCommon { /** * Whether the data format should set the Content-Type header with the type http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentAutoConfiguration.java index ee16b53..768da11 100644 --- a/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentAutoConfiguration.java @@ -16,68 +16,114 @@ */ package org.apache.camel.component.hipchat.springboot; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.hipchat.HipchatComponent; +import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.ComponentConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HipchatComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -public class HipchatComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + HipchatComponentConfiguration.class}) +public class HipchatComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HipchatComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<HipchatComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private HipchatComponentConfiguration componentConfiguration; + + public HipchatComponentAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + public static class Condition extends GroupCondition { + public Condition() { + super("camel.component", "camel.component.hipchat"); + } + } @Lazy @Bean(name = "hipchat-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HipchatComponent.class) - public HipchatComponent configureHipchatComponent(CamelContext camelContext) - throws Exception { + public HipchatComponent configureHipchatComponent() throws Exception { HipchatComponent component = new HipchatComponent(); component.setCamelContext(camelContext); - return component; - } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.component.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.component.hipchat"); - if (isEnabled(conditionContext, "camel.component.hipchat.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(componentConfiguration, parameters, + null, false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } } - return ConditionOutcome.noMatch(message.because("not enabled")); } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<HipchatComponent> configurer : customizers) { + LOGGER.debug("Configure component {}, with configurer {}", + component, configurer); + configurer.customize(component); + } } + return component; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentConfiguration.java index 65c7b54..5865e11 100644 --- a/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hipchat-starter/src/main/java/org/apache/camel/component/hipchat/springboot/HipchatComponentConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.hipchat.springboot; +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -24,8 +26,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * * Generated by camel-package-maven-plugin - do not edit this file! */ +@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.hipchat") -public class HipchatComponentConfiguration { +public class HipchatComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * Whether the component should resolve property placeholders on itself when http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java index 242569d..119cd5c 100644 --- a/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatAutoConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.hl7.springboot; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.annotation.Generated; import org.apache.camel.CamelContext; @@ -24,40 +25,71 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.hl7.HL7DataFormat; import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatCustomizer; import org.apache.camel.spi.DataFormatFactory; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.DataFormatConfigurationProperties; +import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.ObjectHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionMessage; -import org.springframework.boot.autoconfigure.condition.ConditionOutcome; +import org.springframework.boot.autoconfigure.condition.AllNestedConditions; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; -import org.springframework.core.type.AnnotatedTypeMetadata; /** * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @Configuration -@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(HL7DataFormatAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(HL7DataFormatConfiguration.class) -public class HL7DataFormatAutoConfiguration { +@EnableConfigurationProperties({DataFormatConfigurationProperties.class, + HL7DataFormatConfiguration.class}) +public class HL7DataFormatAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(HL7DataFormatAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<DataFormatCustomizer<HL7DataFormat>> customizers; + @Autowired + private DataFormatConfigurationProperties globalConfiguration; + @Autowired + private HL7DataFormatConfiguration dataformatConfiguration; + + public HL7DataFormatAutoConfiguration() { + super(ConfigurationPhase.REGISTER_BEAN); + } + + @ConditionalOnBean(CamelContext.class) + public static class OnCamelContext { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class OnCamelAutoConfiguration { + } + + @ConditionalOnBean(CamelAutoConfiguration.class) + public static class Condition extends GroupCondition { + public Condition() { + super("camel.dataformat", "camel.dataformat.hl7"); + } + } @Bean(name = "hl7-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(HL7DataFormat.class) - public DataFormatFactory configureHL7DataFormatFactory( - final CamelContext camelContext, - final HL7DataFormatConfiguration configuration) { + public DataFormatFactory configureHL7DataFormatFactory() throws Exception { return new DataFormatFactory() { public DataFormat newInstance() { HL7DataFormat dataformat = new HL7DataFormat(); @@ -71,7 +103,7 @@ public class HL7DataFormatAutoConfiguration { } try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, + IntrospectionSupport.getProperties(dataformatConfiguration, parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, @@ -79,34 +111,19 @@ public class HL7DataFormatAutoConfiguration { } catch (Exception e) { throw new RuntimeCamelException(e); } + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && dataformatConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (DataFormatCustomizer<HL7DataFormat> configurer : customizers) { + LOGGER.debug( + "Configure dataformat {}, with configurer {}", + dataformat, configurer); + configurer.customize(dataformat); + } + } return dataformat; } }; } - - @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") - public static class Condition extends SpringBootCondition { - @Override - public ConditionOutcome getMatchOutcome( - ConditionContext conditionContext, - AnnotatedTypeMetadata annotatedTypeMetadata) { - boolean groupEnabled = isEnabled(conditionContext, - "camel.dataformat.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.dataformat.hl7"); - if (isEnabled(conditionContext, "camel.dataformat.hl7.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); - } - return ConditionOutcome.noMatch(message.because("not enabled")); - } - - private boolean isEnabled( - org.springframework.context.annotation.ConditionContext context, - java.lang.String prefix, boolean defaultValue) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), prefix); - return resolver.getProperty("enabled", Boolean.class, defaultValue); - } - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConfiguration.java index f20bde9..d7103a1 100644 --- a/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-hl7-starter/src/main/java/org/apache/camel/component/hl7/springboot/HL7DataFormatConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.hl7.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.DataFormatConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -26,7 +27,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.dataformat.hl7") -public class HL7DataFormatConfiguration { +public class HL7DataFormatConfiguration + extends + DataFormatConfigurationPropertiesCommon { /** * Whether to validate the HL7 message Is by default true.