http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java index a8388f1..e10eae6 100644 --- a/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatAutoConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.converter.jaxb.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.converter.jaxb.JaxbDataFormat; 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(JaxbDataFormatAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JaxbDataFormatConfiguration.class) -public class JaxbDataFormatAutoConfiguration { +@EnableConfigurationProperties({DataFormatConfigurationProperties.class, + JaxbDataFormatConfiguration.class}) +public class JaxbDataFormatAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JaxbDataFormatAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<DataFormatCustomizer<JaxbDataFormat>> customizers; + @Autowired + private DataFormatConfigurationProperties globalConfiguration; + @Autowired + private JaxbDataFormatConfiguration dataformatConfiguration; + + public JaxbDataFormatAutoConfiguration() { + 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.jaxb"); + } + } @Bean(name = "jaxb-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JaxbDataFormat.class) - public DataFormatFactory configureJaxbDataFormatFactory( - final CamelContext camelContext, - final JaxbDataFormatConfiguration configuration) { + public DataFormatFactory configureJaxbDataFormatFactory() throws Exception { return new DataFormatFactory() { public DataFormat newInstance() { JaxbDataFormat dataformat = new JaxbDataFormat(); @@ -71,7 +103,7 @@ public class JaxbDataFormatAutoConfiguration { } 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 JaxbDataFormatAutoConfiguration { } catch (Exception e) { throw new RuntimeCamelException(e); } + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && dataformatConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (DataFormatCustomizer<JaxbDataFormat> 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.jaxb"); - if (isEnabled(conditionContext, "camel.dataformat.jaxb.", - 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-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatConfiguration.java index 4d28036..4583401 100644 --- a/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jaxb-starter/src/main/java/org/apache/camel/converter/jaxb/springboot/JaxbDataFormatConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.converter.jaxb.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.jaxb") -public class JaxbDataFormatConfiguration { +public class JaxbDataFormatConfiguration + extends + DataFormatConfigurationPropertiesCommon { /** * Package name where your JAXB classes are located. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentAutoConfiguration.java index 13ede67..eb1d6fe 100644 --- a/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentAutoConfiguration.java @@ -16,68 +16,114 @@ */ package org.apache.camel.component.jbpm.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.jbpm.JBPMComponent; +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(JBPMComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -public class JBPMComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JBPMComponentConfiguration.class}) +public class JBPMComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JBPMComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JBPMComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JBPMComponentConfiguration componentConfiguration; + + public JBPMComponentAutoConfiguration() { + 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.jbpm"); + } + } @Lazy @Bean(name = "jbpm-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JBPMComponent.class) - public JBPMComponent configureJBPMComponent(CamelContext camelContext) - throws Exception { + public JBPMComponent configureJBPMComponent() throws Exception { JBPMComponent component = new JBPMComponent(); 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.jbpm"); - if (isEnabled(conditionContext, "camel.component.jbpm.", - 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<JBPMComponent> 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-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentConfiguration.java index 0e8d8a1..e4e1501 100644 --- a/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jbpm-starter/src/main/java/org/apache/camel/component/jbpm/springboot/JBPMComponentConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.jbpm.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.jbpm") -public class JBPMComponentConfiguration { +public class JBPMComponentConfiguration + 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-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java index 37137b4..1d403a1 100644 --- a/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.jcache.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.jcache.JCacheComponent; +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(JCacheComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JCacheComponentConfiguration.class) -public class JCacheComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JCacheComponentConfiguration.class}) +public class JCacheComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JCacheComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JCacheComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JCacheComponentConfiguration componentConfiguration; + + public JCacheComponentAutoConfiguration() { + 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.jcache"); + } + } @Lazy @Bean(name = "jcache-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JCacheComponent.class) - public JCacheComponent configureJCacheComponent(CamelContext camelContext, - JCacheComponentConfiguration configuration) throws Exception { + public JCacheComponent configureJCacheComponent() throws Exception { JCacheComponent component = new JCacheComponent(); 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 JCacheComponentAutoConfiguration { } 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.jcache"); - if (isEnabled(conditionContext, "camel.component.jcache.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<JCacheComponent> 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-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConfiguration.java index be5ced1..e377cca 100644 --- a/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jcache-starter/src/main/java/org/apache/camel/component/jcache/springboot/JCacheComponentConfiguration.java @@ -19,6 +19,7 @@ package org.apache.camel.component.jcache.springboot; import java.util.Properties; import javax.annotation.Generated; import javax.cache.configuration.Configuration; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -29,7 +30,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.jcache") -public class JCacheComponentConfiguration { +public class JCacheComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The fully qualified class name of the javax.cache.spi.CachingProvider http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java index 8aebcc2..8209a00 100644 --- a/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentAutoConfiguration.java @@ -16,68 +16,114 @@ */ package org.apache.camel.component.jcr.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.jcr.JcrComponent; +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(JcrComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -public class JcrComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JcrComponentConfiguration.class}) +public class JcrComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JcrComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JcrComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JcrComponentConfiguration componentConfiguration; + + public JcrComponentAutoConfiguration() { + 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.jcr"); + } + } @Lazy @Bean(name = "jcr-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JcrComponent.class) - public JcrComponent configureJcrComponent(CamelContext camelContext) - throws Exception { + public JcrComponent configureJcrComponent() throws Exception { JcrComponent component = new JcrComponent(); 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.jcr"); - if (isEnabled(conditionContext, "camel.component.jcr.", - 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<JcrComponent> 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-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentConfiguration.java index bea31b2..d49c895 100644 --- a/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jcr-starter/src/main/java/org/apache/camel/component/jcr/springboot/JcrComponentConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.jcr.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.jcr") -public class JcrComponentConfiguration { +public class JcrComponentConfiguration + 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-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java index 2424bdc..3ef6712 100644 --- a/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.jdbc.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.jdbc.JdbcComponent; +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(JdbcComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JdbcComponentConfiguration.class) -public class JdbcComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JdbcComponentConfiguration.class}) +public class JdbcComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JdbcComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JdbcComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JdbcComponentConfiguration componentConfiguration; + + public JdbcComponentAutoConfiguration() { + 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.jdbc"); + } + } @Lazy @Bean(name = "jdbc-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JdbcComponent.class) - public JdbcComponent configureJdbcComponent(CamelContext camelContext, - JdbcComponentConfiguration configuration) throws Exception { + public JdbcComponent configureJdbcComponent() throws Exception { JdbcComponent component = new JdbcComponent(); 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 JdbcComponentAutoConfiguration { } 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.jdbc"); - if (isEnabled(conditionContext, "camel.component.jdbc.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<JdbcComponent> 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-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConfiguration.java index f2e6234..3a33752 100644 --- a/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jdbc-starter/src/main/java/org/apache/camel/component/jdbc/springboot/JdbcComponentConfiguration.java @@ -18,6 +18,7 @@ package org.apache.camel.component.jdbc.springboot; import javax.annotation.Generated; import javax.sql.DataSource; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -28,7 +29,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.jdbc") -public class JdbcComponentConfiguration { +public class JdbcComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use the DataSource instance instead of looking up the data source by http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentAutoConfiguration9.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentAutoConfiguration9.java b/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentAutoConfiguration9.java index c887d25..5f413f9 100644 --- a/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentAutoConfiguration9.java +++ b/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentAutoConfiguration9.java @@ -17,50 +17,81 @@ package org.apache.camel.component.jetty9.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.jetty9.JettyHttpComponent9; +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(JettyHttpComponentAutoConfiguration9.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JettyHttpComponentConfiguration9.class) -public class JettyHttpComponentAutoConfiguration9 { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JettyHttpComponentConfiguration9.class}) +public class JettyHttpComponentAutoConfiguration9 extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JettyHttpComponentAutoConfiguration9.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JettyHttpComponent9>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JettyHttpComponentConfiguration9 componentConfiguration; + + public JettyHttpComponentAutoConfiguration9() { + 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.jetty"); + } + } @Lazy @Bean(name = "jetty-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JettyHttpComponent9.class) - public JettyHttpComponent9 configureJettyHttpComponent9( - CamelContext camelContext, - JettyHttpComponentConfiguration9 configuration) throws Exception { + public JettyHttpComponent9 configureJettyHttpComponent9() throws Exception { JettyHttpComponent9 component = new JettyHttpComponent9(); 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 JettyHttpComponentAutoConfiguration9 { } 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.jetty"); - if (isEnabled(conditionContext, "camel.component.jetty.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<JettyHttpComponent9> 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-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentConfiguration9.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentConfiguration9.java b/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentConfiguration9.java index dc841bb..669cde9 100644 --- a/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentConfiguration9.java +++ b/platforms/spring-boot/components-starter/camel-jetty9-starter/src/main/java/org/apache/camel/component/jetty9/springboot/JettyHttpComponentConfiguration9.java @@ -22,6 +22,7 @@ import org.apache.camel.component.jetty.JettyHttpBinding; import org.apache.camel.http.common.HttpBinding; import org.apache.camel.http.common.HttpConfiguration; import org.apache.camel.spi.HeaderFilterStrategy; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.camel.util.jsse.SSLContextParameters; import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.server.Connector; @@ -38,7 +39,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.jetty") -public class JettyHttpComponentConfiguration9 { +public class JettyHttpComponentConfiguration9 + extends + ComponentConfigurationPropertiesCommon { /** * The key password which is used to access the certificate's key entry in http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java index 492439c..3e6fbab 100644 --- a/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.jgroups.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.jgroups.JGroupsComponent; +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(JGroupsComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JGroupsComponentConfiguration.class) -public class JGroupsComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JGroupsComponentConfiguration.class}) +public class JGroupsComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JGroupsComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JGroupsComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JGroupsComponentConfiguration componentConfiguration; + + public JGroupsComponentAutoConfiguration() { + 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.jgroups"); + } + } @Lazy @Bean(name = "jgroups-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JGroupsComponent.class) - public JGroupsComponent configureJGroupsComponent( - CamelContext camelContext, - JGroupsComponentConfiguration configuration) throws Exception { + public JGroupsComponent configureJGroupsComponent() throws Exception { JGroupsComponent component = new JGroupsComponent(); 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 JGroupsComponentAutoConfiguration { } 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.jgroups"); - if (isEnabled(conditionContext, "camel.component.jgroups.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<JGroupsComponent> 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-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConfiguration.java index 0c2e812..f9654c1 100644 --- a/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jgroups-starter/src/main/java/org/apache/camel/component/jgroups/springboot/JGroupsComponentConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.component.jgroups.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.jgroups.JChannel; 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.jgroups") -public class JGroupsComponentConfiguration { +public class JGroupsComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * Channel to use http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatAutoConfiguration.java index 1597cbd..cf90aec 100644 --- a/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatAutoConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.jibx.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.jibx.JibxDataFormat; 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(JibxDataFormatAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JibxDataFormatConfiguration.class) -public class JibxDataFormatAutoConfiguration { +@EnableConfigurationProperties({DataFormatConfigurationProperties.class, + JibxDataFormatConfiguration.class}) +public class JibxDataFormatAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JibxDataFormatAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<DataFormatCustomizer<JibxDataFormat>> customizers; + @Autowired + private DataFormatConfigurationProperties globalConfiguration; + @Autowired + private JibxDataFormatConfiguration dataformatConfiguration; + + public JibxDataFormatAutoConfiguration() { + 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.jibx"); + } + } @Bean(name = "jibx-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JibxDataFormat.class) - public DataFormatFactory configureJibxDataFormatFactory( - final CamelContext camelContext, - final JibxDataFormatConfiguration configuration) { + public DataFormatFactory configureJibxDataFormatFactory() throws Exception { return new DataFormatFactory() { public DataFormat newInstance() { JibxDataFormat dataformat = new JibxDataFormat(); @@ -71,7 +103,7 @@ public class JibxDataFormatAutoConfiguration { } 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 JibxDataFormatAutoConfiguration { } catch (Exception e) { throw new RuntimeCamelException(e); } + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && dataformatConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (DataFormatCustomizer<JibxDataFormat> 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.jibx"); - if (isEnabled(conditionContext, "camel.dataformat.jibx.", - 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-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatConfiguration.java index a2e21b7..1e2ac48 100644 --- a/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jibx-starter/src/main/java/org/apache/camel/dataformat/jibx/springboot/JibxDataFormatConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.jibx.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.jibx") -public class JibxDataFormatConfiguration { +public class JibxDataFormatConfiguration + extends + DataFormatConfigurationPropertiesCommon { /** * Class name to use when unmarshalling from XML to Java. http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentAutoConfiguration.java index eeb94b4..897b95c 100644 --- a/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentAutoConfiguration.java @@ -16,68 +16,114 @@ */ package org.apache.camel.component.validator.jing.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.validator.jing.JingComponent; +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(JingComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -public class JingComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + JingComponentConfiguration.class}) +public class JingComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JingComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<JingComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private JingComponentConfiguration componentConfiguration; + + public JingComponentAutoConfiguration() { + 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.jing"); + } + } @Lazy @Bean(name = "jing-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JingComponent.class) - public JingComponent configureJingComponent(CamelContext camelContext) - throws Exception { + public JingComponent configureJingComponent() throws Exception { JingComponent component = new JingComponent(); 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.jing"); - if (isEnabled(conditionContext, "camel.component.jing.", - 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<JingComponent> 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-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentConfiguration.java index 78fbd75..3bd9a8f 100644 --- a/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-jing-starter/src/main/java/org/apache/camel/component/validator/jing/springboot/JingComponentConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.validator.jing.springboot; +import javax.annotation.Generated; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -23,8 +25,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.jing") -public class JingComponentConfiguration { +public class JingComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * Whether the component should resolve property placeholders on itself when