http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java index 64eec42..0aa37a7 100644 --- a/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.lucene.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.lucene.LuceneComponent; +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(LuceneComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(LuceneComponentConfiguration.class) -public class LuceneComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + LuceneComponentConfiguration.class}) +public class LuceneComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(LuceneComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<LuceneComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private LuceneComponentConfiguration componentConfiguration; + + public LuceneComponentAutoConfiguration() { + 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.lucene"); + } + } @Lazy @Bean(name = "lucene-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(LuceneComponent.class) - public LuceneComponent configureLuceneComponent(CamelContext camelContext, - LuceneComponentConfiguration configuration) throws Exception { + public LuceneComponent configureLuceneComponent() throws Exception { LuceneComponent component = new LuceneComponent(); 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 LuceneComponentAutoConfiguration { } 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.lucene"); - if (isEnabled(conditionContext, "camel.component.lucene.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<LuceneComponent> 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-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java index 6513191..a2d9ac7 100644 --- a/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-lucene-starter/src/main/java/org/apache/camel/component/lucene/springboot/LuceneComponentConfiguration.java @@ -20,6 +20,7 @@ import java.io.File; import java.net.URI; import javax.annotation.Generated; import org.apache.camel.component.lucene.LuceneOperation; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.util.Version; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -32,7 +33,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.lucene") -public class LuceneComponentConfiguration { +public class LuceneComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use a shared lucene configuration http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java index df79781..7e3833e 100644 --- a/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.lumberjack.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.lumberjack.LumberjackComponent; +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(LumberjackComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(LumberjackComponentConfiguration.class) -public class LumberjackComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + LumberjackComponentConfiguration.class}) +public class LumberjackComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(LumberjackComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<LumberjackComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private LumberjackComponentConfiguration componentConfiguration; + + public LumberjackComponentAutoConfiguration() { + 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.lumberjack"); + } + } @Lazy @Bean(name = "lumberjack-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(LumberjackComponent.class) - public LumberjackComponent configureLumberjackComponent( - CamelContext camelContext, - LumberjackComponentConfiguration configuration) throws Exception { + public LumberjackComponent configureLumberjackComponent() throws Exception { LumberjackComponent component = new LumberjackComponent(); 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 +114,16 @@ public class LumberjackComponentAutoConfiguration { } 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.lumberjack"); - if (isEnabled(conditionContext, "camel.component.lumberjack.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<LumberjackComponent> 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-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java index 611df02..57777b3 100644 --- a/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-lumberjack-starter/src/main/java/org/apache/camel/component/lumberjack/springboot/LumberjackComponentConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.lumberjack.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.camel.util.jsse.SSLContextParameters; 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.lumberjack") -public class LumberjackComponentConfiguration { +public class LumberjackComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * Sets the default SSL configuration to use for all the endpoints. You can http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java index cd137da..a026158 100644 --- a/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatAutoConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.lzf.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.dataformat.lzf.LZFDataFormat; 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(LZFDataFormatAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(LZFDataFormatConfiguration.class) -public class LZFDataFormatAutoConfiguration { +@EnableConfigurationProperties({DataFormatConfigurationProperties.class, + LZFDataFormatConfiguration.class}) +public class LZFDataFormatAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(LZFDataFormatAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<DataFormatCustomizer<LZFDataFormat>> customizers; + @Autowired + private DataFormatConfigurationProperties globalConfiguration; + @Autowired + private LZFDataFormatConfiguration dataformatConfiguration; + + public LZFDataFormatAutoConfiguration() { + 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.lzf"); + } + } @Bean(name = "lzf-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(LZFDataFormat.class) - public DataFormatFactory configureLZFDataFormatFactory( - final CamelContext camelContext, - final LZFDataFormatConfiguration configuration) { + public DataFormatFactory configureLZFDataFormatFactory() throws Exception { return new DataFormatFactory() { public DataFormat newInstance() { LZFDataFormat dataformat = new LZFDataFormat(); @@ -71,7 +103,7 @@ public class LZFDataFormatAutoConfiguration { } 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 LZFDataFormatAutoConfiguration { } catch (Exception e) { throw new RuntimeCamelException(e); } + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && dataformatConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (DataFormatCustomizer<LZFDataFormat> 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.lzf"); - if (isEnabled(conditionContext, "camel.dataformat.lzf.", - 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-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatConfiguration.java index f04ab15..e4d2ca3 100644 --- a/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-lzf-starter/src/main/java/org/apache/camel/dataformat/lzf/springboot/LZFDataFormatConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.lzf.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.lzf") -public class LZFDataFormatConfiguration { +public class LZFDataFormatConfiguration + extends + DataFormatConfigurationPropertiesCommon { /** * Enable encoding (compress) using multiple processing cores. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java index fcd9d5e..55043e7 100644 --- a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentAutoConfiguration.java @@ -17,50 +17,82 @@ package org.apache.camel.component.mail.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.mail.MailComponent; +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(MailComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(MailComponentConfiguration.class) -public class MailComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + MailComponentConfiguration.class}) +public class MailComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(MailComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<MailComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private MailComponentConfiguration componentConfiguration; + + public MailComponentAutoConfiguration() { + 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.mail"); + } + } @Lazy @Bean(name = {"imap-component", "imaps-component", "pop3-component", "pop3s-component", "smtp-component", "smtps-component"}) @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(MailComponent.class) - public MailComponent configureMailComponent(CamelContext camelContext, - MailComponentConfiguration configuration) throws Exception { + public MailComponent configureMailComponent() throws Exception { MailComponent component = new MailComponent(); 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 MailComponentAutoConfiguration { } 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.mail"); - if (isEnabled(conditionContext, "camel.component.mail.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<MailComponent> 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-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java index dc3597a..be43bab 100644 --- a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/component/mail/springboot/MailComponentConfiguration.java @@ -22,6 +22,7 @@ import javax.mail.Session; import org.apache.camel.component.mail.AttachmentsContentTransferEncodingResolver; import org.apache.camel.component.mail.ContentTypeResolver; import org.apache.camel.component.mail.JavaMailSender; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.camel.util.jsse.SSLContextParameters; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -33,7 +34,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.mail") -public class MailComponentConfiguration { +public class MailComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * Sets the Mail configuration http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java index d95972e..6497000 100644 --- a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatAutoConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.mime.multipart.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,74 @@ import org.apache.camel.CamelContextAware; import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.mime.multipart.MimeMultipartDataFormat; 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(MimeMultipartDataFormatAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(MimeMultipartDataFormatConfiguration.class) -public class MimeMultipartDataFormatAutoConfiguration { +@EnableConfigurationProperties({DataFormatConfigurationProperties.class, + MimeMultipartDataFormatConfiguration.class}) +public class MimeMultipartDataFormatAutoConfiguration + extends + AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(MimeMultipartDataFormatAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<DataFormatCustomizer<MimeMultipartDataFormat>> customizers; + @Autowired + private DataFormatConfigurationProperties globalConfiguration; + @Autowired + private MimeMultipartDataFormatConfiguration dataformatConfiguration; + + public MimeMultipartDataFormatAutoConfiguration() { + 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.mime-multipart"); + } + } @Bean(name = "mime-multipart-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(MimeMultipartDataFormat.class) - public DataFormatFactory configureMimeMultipartDataFormatFactory( - final CamelContext camelContext, - final MimeMultipartDataFormatConfiguration configuration) { + public DataFormatFactory configureMimeMultipartDataFormatFactory() + throws Exception { return new DataFormatFactory() { public DataFormat newInstance() { MimeMultipartDataFormat dataformat = new MimeMultipartDataFormat(); @@ -71,7 +106,7 @@ public class MimeMultipartDataFormatAutoConfiguration { } try { Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, + IntrospectionSupport.getProperties(dataformatConfiguration, parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, @@ -79,34 +114,19 @@ public class MimeMultipartDataFormatAutoConfiguration { } catch (Exception e) { throw new RuntimeCamelException(e); } + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && dataformatConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (DataFormatCustomizer<MimeMultipartDataFormat> 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.mime-multipart"); - if (isEnabled(conditionContext, "camel.dataformat.mime-multipart.", - 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-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatConfiguration.java index c88a4a1..0d5c31b 100644 --- a/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mail-starter/src/main/java/org/apache/camel/dataformat/mime/multipart/springboot/MimeMultipartDataFormatConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.mime.multipart.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.mime-multipart") -public class MimeMultipartDataFormatConfiguration { +public class MimeMultipartDataFormatConfiguration + extends + DataFormatConfigurationPropertiesCommon { /** * Specify the subtype of the MIME Multipart. Default is mixed. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java index 6f000b7..482549f 100644 --- a/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.metrics.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.metrics.MetricsComponent; +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(MetricsComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(MetricsComponentConfiguration.class) -public class MetricsComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + MetricsComponentConfiguration.class}) +public class MetricsComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(MetricsComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<MetricsComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private MetricsComponentConfiguration componentConfiguration; + + public MetricsComponentAutoConfiguration() { + 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.metrics"); + } + } @Lazy @Bean(name = "metrics-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(MetricsComponent.class) - public MetricsComponent configureMetricsComponent( - CamelContext camelContext, - MetricsComponentConfiguration configuration) throws Exception { + public MetricsComponent configureMetricsComponent() throws Exception { MetricsComponent component = new MetricsComponent(); 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 +114,16 @@ public class MetricsComponentAutoConfiguration { } 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.metrics"); - if (isEnabled(conditionContext, "camel.component.metrics.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<MetricsComponent> 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-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java index 1f6e350..b78934e 100644 --- a/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-metrics-starter/src/main/java/org/apache/camel/component/metrics/springboot/MetricsComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.metrics.springboot; import javax.annotation.Generated; import com.codahale.metrics.MetricRegistry; +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.metrics") -public class MetricsComponentConfiguration { +public class MetricsComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use a custom configured MetricRegistry. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java index 245a1e6..d2fc0eb 100644 --- a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.milo.client.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.milo.client.MiloClientComponent; +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(MiloClientComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(MiloClientComponentConfiguration.class) -public class MiloClientComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + MiloClientComponentConfiguration.class}) +public class MiloClientComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(MiloClientComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<MiloClientComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private MiloClientComponentConfiguration componentConfiguration; + + public MiloClientComponentAutoConfiguration() { + 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.milo-client"); + } + } @Lazy @Bean(name = "milo-client-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(MiloClientComponent.class) - public MiloClientComponent configureMiloClientComponent( - CamelContext camelContext, - MiloClientComponentConfiguration configuration) throws Exception { + public MiloClientComponent configureMiloClientComponent() throws Exception { MiloClientComponent component = new MiloClientComponent(); 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 +114,16 @@ public class MiloClientComponentAutoConfiguration { } 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.milo-client"); - if (isEnabled(conditionContext, "camel.component.milo-client.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<MiloClientComponent> 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-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConfiguration.java index 0760771..c05cf37 100644 --- a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/client/springboot/MiloClientComponentConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.milo.client.springboot; import javax.annotation.Generated; +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.milo-client") -public class MiloClientComponentConfiguration { +public class MiloClientComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * All default options for client http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java index 620cacd..87a74df 100644 --- a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.milo.server.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.milo.server.MiloServerComponent; +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(MiloServerComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(MiloServerComponentConfiguration.class) -public class MiloServerComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + MiloServerComponentConfiguration.class}) +public class MiloServerComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(MiloServerComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<MiloServerComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private MiloServerComponentConfiguration componentConfiguration; + + public MiloServerComponentAutoConfiguration() { + 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.milo-server"); + } + } @Lazy @Bean(name = "milo-server-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(MiloServerComponent.class) - public MiloServerComponent configureMiloServerComponent( - CamelContext camelContext, - MiloServerComponentConfiguration configuration) throws Exception { + public MiloServerComponent configureMiloServerComponent() throws Exception { MiloServerComponent component = new MiloServerComponent(); 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 +114,16 @@ public class MiloServerComponentAutoConfiguration { } 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.milo-server"); - if (isEnabled(conditionContext, "camel.component.milo-server.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<MiloServerComponent> 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-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConfiguration.java index 4a368e0..3b094ae 100644 --- a/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-milo-starter/src/main/java/org/apache/camel/component/milo/server/springboot/MiloServerComponentConfiguration.java @@ -22,6 +22,7 @@ import java.util.Set; import java.util.function.Supplier; import javax.annotation.Generated; import org.apache.camel.component.milo.KeyStoreLoader.Result; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.eclipse.milo.opcua.stack.core.application.CertificateManager; import org.eclipse.milo.opcua.stack.core.application.CertificateValidator; import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; @@ -36,7 +37,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.milo-server") -public class MiloServerComponentConfiguration { +public class MiloServerComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The URI of the namespace defaults to urn:org:apache:camel http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java index 5b919b5..180febf 100644 --- a/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.mina2.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.mina2.Mina2Component; +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(Mina2ComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(Mina2ComponentConfiguration.class) -public class Mina2ComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + Mina2ComponentConfiguration.class}) +public class Mina2ComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(Mina2ComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<Mina2Component>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private Mina2ComponentConfiguration componentConfiguration; + + public Mina2ComponentAutoConfiguration() { + 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.mina2"); + } + } @Lazy @Bean(name = "mina2-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(Mina2Component.class) - public Mina2Component configureMina2Component(CamelContext camelContext, - Mina2ComponentConfiguration configuration) throws Exception { + public Mina2Component configureMina2Component() throws Exception { Mina2Component component = new Mina2Component(); 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 Mina2ComponentAutoConfiguration { } 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.mina2"); - if (isEnabled(conditionContext, "camel.component.mina2.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<Mina2Component> 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-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java index 1448d76..0404030 100644 --- a/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-mina2-starter/src/main/java/org/apache/camel/component/mina2/springboot/Mina2ComponentConfiguration.java @@ -21,6 +21,7 @@ import javax.annotation.Generated; import org.apache.camel.LoggingLevel; import org.apache.camel.component.mina2.Mina2Component; import org.apache.camel.component.mina2.Mina2TextLineDelimiter; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.camel.util.jsse.SSLContextParameters; import org.apache.mina.filter.codec.ProtocolCodecFactory; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -33,7 +34,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.mina2") -public class Mina2ComponentConfiguration { +public class Mina2ComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use the shared mina configuration.