http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentConfiguration.java index bf7acc2..76c577f 100644 --- a/platforms/spring-boot/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-sap-netweaver-starter/src/main/java/org/apache/camel/component/sap/netweaver/springboot/NetWeaverComponentConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.sap.netweaver.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.sap-netweaver") -public class NetWeaverComponentConfiguration { +public class NetWeaverComponentConfiguration + 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-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java index 2542c9b..0ad9896 100644 --- a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentAutoConfiguration.java @@ -17,49 +17,81 @@ package org.apache.camel.component.xquery.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.xquery.XQueryComponent; +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(XQueryComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(XQueryComponentConfiguration.class) -public class XQueryComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + XQueryComponentConfiguration.class}) +public class XQueryComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(XQueryComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<XQueryComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private XQueryComponentConfiguration componentConfiguration; + + public XQueryComponentAutoConfiguration() { + 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.xquery"); + } + } @Lazy @Bean(name = "xquery-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XQueryComponent.class) - public XQueryComponent configureXQueryComponent(CamelContext camelContext, - XQueryComponentConfiguration configuration) throws Exception { + public XQueryComponent configureXQueryComponent() throws Exception { XQueryComponent component = new XQueryComponent(); 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 XQueryComponentAutoConfiguration { } 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.xquery"); - if (isEnabled(conditionContext, "camel.component.xquery.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<XQueryComponent> 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-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConfiguration.java index 69b7644..ac5bde8 100644 --- a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/component/xquery/springboot/XQueryComponentConfiguration.java @@ -20,6 +20,7 @@ import java.util.Map; import javax.annotation.Generated; import net.sf.saxon.Configuration; import net.sf.saxon.lib.ModuleURIResolver; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -30,7 +31,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.xquery") -public class XQueryComponentConfiguration { +public class XQueryComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * To use the custom ModuleURIResolver http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java index c970cf3..00e7137 100644 --- a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageAutoConfiguration.java @@ -17,45 +17,78 @@ package org.apache.camel.language.xquery.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.CamelContextAware; import org.apache.camel.language.xquery.XQueryLanguage; +import org.apache.camel.spi.LanguageCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.LanguageConfigurationProperties; +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.Scope; -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(XQueryLanguageAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(XQueryLanguageConfiguration.class) -public class XQueryLanguageAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({LanguageConfigurationProperties.class, + XQueryLanguageConfiguration.class}) +public class XQueryLanguageAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(XQueryLanguageAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<LanguageCustomizer<XQueryLanguage>> customizers; + @Autowired + private LanguageConfigurationProperties globalConfiguration; + @Autowired + private XQueryLanguageConfiguration languageConfiguration; + + public XQueryLanguageAutoConfiguration() { + 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.component", "camel.component.xquery"); + } + } @Bean(name = "xquery-language") @Scope("prototype") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XQueryLanguage.class) - public XQueryLanguage configureXQueryLanguage(CamelContext camelContext, - XQueryLanguageConfiguration configuration) throws Exception { + public XQueryLanguage configureXQueryLanguage() throws Exception { XQueryLanguage language = new XQueryLanguage(); if (CamelContextAware.class.isAssignableFrom(XQueryLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class @@ -65,36 +98,20 @@ public class XQueryLanguageAutoConfiguration { } } Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(languageConfiguration, parameters, + null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters); - return language; - } - - @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.language.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.language.xquery"); - if (isEnabled(conditionContext, "camel.language.xquery.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && languageConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (LanguageCustomizer<XQueryLanguage> configurer : customizers) { + LOGGER.debug("Configure language {}, with configurer {}", + language, configurer); + configurer.customize(language); } - 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 language; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageConfiguration.java b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageConfiguration.java index d479273..9112e66 100644 --- a/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-saxon-starter/src/main/java/org/apache/camel/language/xquery/springboot/XQueryLanguageConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.language.xquery.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.LanguageConfigurationPropertiesCommon; 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.language.xquery") -public class XQueryLanguageConfiguration { +public class XQueryLanguageConfiguration + extends + LanguageConfigurationPropertiesCommon { /** * Sets the class name of the result type (type from output) The default http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java index 6b5e42f..3a6641c 100644 --- a/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentAutoConfiguration.java @@ -16,68 +16,114 @@ */ package org.apache.camel.component.schematron.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.schematron.SchematronComponent; +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(SchematronComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -public class SchematronComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + SchematronComponentConfiguration.class}) +public class SchematronComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(SchematronComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<SchematronComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private SchematronComponentConfiguration componentConfiguration; + + public SchematronComponentAutoConfiguration() { + 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.schematron"); + } + } @Lazy @Bean(name = "schematron-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(SchematronComponent.class) - public SchematronComponent configureSchematronComponent( - CamelContext camelContext) throws Exception { + public SchematronComponent configureSchematronComponent() throws Exception { SchematronComponent component = new SchematronComponent(); 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.schematron"); - if (isEnabled(conditionContext, "camel.component.schematron.", - 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<SchematronComponent> 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-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentConfiguration.java index 5dfa627..52f3f7b 100644 --- a/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-schematron-starter/src/main/java/org/apache/camel/component/schematron/springboot/SchematronComponentConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.schematron.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.schematron") -public class SchematronComponentConfiguration { +public class SchematronComponentConfiguration + 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-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageAutoConfiguration.java index 7a2e636..3885b92 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageAutoConfiguration.java @@ -17,46 +17,78 @@ package org.apache.camel.builder.script.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.CamelContextAware; import org.apache.camel.builder.script.JavaScriptLanguage; +import org.apache.camel.spi.LanguageCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.LanguageConfigurationProperties; +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.Scope; -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(JavaScriptLanguageAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(JavaScriptLanguageConfiguration.class) -public class JavaScriptLanguageAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({LanguageConfigurationProperties.class, + JavaScriptLanguageConfiguration.class}) +public class JavaScriptLanguageAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(JavaScriptLanguageAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<LanguageCustomizer<JavaScriptLanguage>> customizers; + @Autowired + private LanguageConfigurationProperties globalConfiguration; + @Autowired + private JavaScriptLanguageConfiguration languageConfiguration; + + public JavaScriptLanguageAutoConfiguration() { + 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.component", "camel.component.javascript"); + } + } @Bean(name = "javaScript-language") @Scope("prototype") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JavaScriptLanguage.class) - public JavaScriptLanguage configureJavaScriptLanguage( - CamelContext camelContext, - JavaScriptLanguageConfiguration configuration) throws Exception { + public JavaScriptLanguage configureJavaScriptLanguage() throws Exception { JavaScriptLanguage language = new JavaScriptLanguage(); if (CamelContextAware.class.isAssignableFrom(JavaScriptLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class @@ -66,36 +98,20 @@ public class JavaScriptLanguageAutoConfiguration { } } Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(languageConfiguration, parameters, + null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters); - return language; - } - - @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.language.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.language.javascript"); - if (isEnabled(conditionContext, "camel.language.javascript.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && languageConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (LanguageCustomizer<JavaScriptLanguage> configurer : customizers) { + LOGGER.debug("Configure language {}, with configurer {}", + language, configurer); + configurer.customize(language); } - 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 language; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageConfiguration.java index bbd9a57..981f688 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/JavaScriptLanguageConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.builder.script.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.LanguageConfigurationPropertiesCommon; 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.language.javascript") -public class JavaScriptLanguageConfiguration { +public class JavaScriptLanguageConfiguration + extends + LanguageConfigurationPropertiesCommon { /** * Whether to trim the value to remove leading and trailing whitespaces and http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageAutoConfiguration.java index 23202cd..2105527 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageAutoConfiguration.java @@ -17,45 +17,78 @@ package org.apache.camel.builder.script.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.CamelContextAware; import org.apache.camel.builder.script.PhpLanguage; +import org.apache.camel.spi.LanguageCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.LanguageConfigurationProperties; +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.Scope; -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(PhpLanguageAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(PhpLanguageConfiguration.class) -public class PhpLanguageAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({LanguageConfigurationProperties.class, + PhpLanguageConfiguration.class}) +public class PhpLanguageAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(PhpLanguageAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<LanguageCustomizer<PhpLanguage>> customizers; + @Autowired + private LanguageConfigurationProperties globalConfiguration; + @Autowired + private PhpLanguageConfiguration languageConfiguration; + + public PhpLanguageAutoConfiguration() { + 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.component", "camel.component.php"); + } + } @Bean(name = "php-language") @Scope("prototype") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(PhpLanguage.class) - public PhpLanguage configurePhpLanguage(CamelContext camelContext, - PhpLanguageConfiguration configuration) throws Exception { + public PhpLanguage configurePhpLanguage() throws Exception { PhpLanguage language = new PhpLanguage(); if (CamelContextAware.class.isAssignableFrom(PhpLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class @@ -65,35 +98,20 @@ public class PhpLanguageAutoConfiguration { } } Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(languageConfiguration, parameters, + null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters); - return language; - } - - @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.language.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.language.php"); - if (isEnabled(conditionContext, "camel.language.php.", groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && languageConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (LanguageCustomizer<PhpLanguage> configurer : customizers) { + LOGGER.debug("Configure language {}, with configurer {}", + language, configurer); + configurer.customize(language); } - 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 language; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageConfiguration.java index 4d6641b..07efa74 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PhpLanguageConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.builder.script.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.LanguageConfigurationPropertiesCommon; 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.language.php") -public class PhpLanguageConfiguration { +public class PhpLanguageConfiguration + extends + LanguageConfigurationPropertiesCommon { /** * Whether to trim the value to remove leading and trailing whitespaces and http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageAutoConfiguration.java index 6cac0e9..fa09d1e 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageAutoConfiguration.java @@ -17,45 +17,78 @@ package org.apache.camel.builder.script.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.CamelContextAware; import org.apache.camel.builder.script.PythonLanguage; +import org.apache.camel.spi.LanguageCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.LanguageConfigurationProperties; +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.Scope; -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(PythonLanguageAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(PythonLanguageConfiguration.class) -public class PythonLanguageAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({LanguageConfigurationProperties.class, + PythonLanguageConfiguration.class}) +public class PythonLanguageAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(PythonLanguageAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<LanguageCustomizer<PythonLanguage>> customizers; + @Autowired + private LanguageConfigurationProperties globalConfiguration; + @Autowired + private PythonLanguageConfiguration languageConfiguration; + + public PythonLanguageAutoConfiguration() { + 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.component", "camel.component.python"); + } + } @Bean(name = "python-language") @Scope("prototype") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(PythonLanguage.class) - public PythonLanguage configurePythonLanguage(CamelContext camelContext, - PythonLanguageConfiguration configuration) throws Exception { + public PythonLanguage configurePythonLanguage() throws Exception { PythonLanguage language = new PythonLanguage(); if (CamelContextAware.class.isAssignableFrom(PythonLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class @@ -65,36 +98,20 @@ public class PythonLanguageAutoConfiguration { } } Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(languageConfiguration, parameters, + null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters); - return language; - } - - @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.language.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.language.python"); - if (isEnabled(conditionContext, "camel.language.python.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && languageConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (LanguageCustomizer<PythonLanguage> configurer : customizers) { + LOGGER.debug("Configure language {}, with configurer {}", + language, configurer); + configurer.customize(language); } - 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 language; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageConfiguration.java index 214f23a..2a5b536 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/PythonLanguageConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.builder.script.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.LanguageConfigurationPropertiesCommon; 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.language.python") -public class PythonLanguageConfiguration { +public class PythonLanguageConfiguration + extends + LanguageConfigurationPropertiesCommon { /** * Whether to trim the value to remove leading and trailing whitespaces and http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageAutoConfiguration.java index c480b3b..8663695 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageAutoConfiguration.java @@ -17,45 +17,78 @@ package org.apache.camel.builder.script.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.CamelContextAware; import org.apache.camel.builder.script.RubyLanguage; +import org.apache.camel.spi.LanguageCustomizer; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.apache.camel.spring.boot.LanguageConfigurationProperties; +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.Scope; -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(RubyLanguageAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(RubyLanguageConfiguration.class) -public class RubyLanguageAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({LanguageConfigurationProperties.class, + RubyLanguageConfiguration.class}) +public class RubyLanguageAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(RubyLanguageAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<LanguageCustomizer<RubyLanguage>> customizers; + @Autowired + private LanguageConfigurationProperties globalConfiguration; + @Autowired + private RubyLanguageConfiguration languageConfiguration; + + public RubyLanguageAutoConfiguration() { + 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.component", "camel.component.ruby"); + } + } @Bean(name = "ruby-language") @Scope("prototype") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(RubyLanguage.class) - public RubyLanguage configureRubyLanguage(CamelContext camelContext, - RubyLanguageConfiguration configuration) throws Exception { + public RubyLanguage configureRubyLanguage() throws Exception { RubyLanguage language = new RubyLanguage(); if (CamelContextAware.class.isAssignableFrom(RubyLanguage.class)) { CamelContextAware contextAware = CamelContextAware.class @@ -65,36 +98,20 @@ public class RubyLanguageAutoConfiguration { } } Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); + IntrospectionSupport.getProperties(languageConfiguration, parameters, + null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters); - return language; - } - - @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.language.", true); - ConditionMessage.Builder message = ConditionMessage - .forCondition("camel.language.ruby"); - if (isEnabled(conditionContext, "camel.language.ruby.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && languageConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (LanguageCustomizer<RubyLanguage> configurer : customizers) { + LOGGER.debug("Configure language {}, with configurer {}", + language, configurer); + configurer.customize(language); } - 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 language; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageConfiguration.java b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageConfiguration.java index 8811497..60ce848 100644 --- a/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-script-starter/src/main/java/org/apache/camel/builder/script/springboot/RubyLanguageConfiguration.java @@ -17,6 +17,7 @@ package org.apache.camel.builder.script.springboot; import javax.annotation.Generated; +import org.apache.camel.spring.boot.LanguageConfigurationPropertiesCommon; 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.language.ruby") -public class RubyLanguageConfiguration { +public class RubyLanguageConfiguration + extends + LanguageConfigurationPropertiesCommon { /** * Whether to trim the value to remove leading and trailing whitespaces and http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java index f201ffe..3e176b0 100644 --- a/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.servicenow.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.servicenow.ServiceNowComponent; +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(ServiceNowComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(ServiceNowComponentConfiguration.class) -public class ServiceNowComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + ServiceNowComponentConfiguration.class}) +public class ServiceNowComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(ServiceNowComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<ServiceNowComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private ServiceNowComponentConfiguration componentConfiguration; + + public ServiceNowComponentAutoConfiguration() { + 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.servicenow"); + } + } @Lazy @Bean(name = "servicenow-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(ServiceNowComponent.class) - public ServiceNowComponent configureServiceNowComponent( - CamelContext camelContext, - ServiceNowComponentConfiguration configuration) throws Exception { + public ServiceNowComponent configureServiceNowComponent() throws Exception { ServiceNowComponent component = new ServiceNowComponent(); 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 ServiceNowComponentAutoConfiguration { } 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.servicenow"); - if (isEnabled(conditionContext, "camel.component.servicenow.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<ServiceNowComponent> 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-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java index 4b7fc5b..3aa6b72 100644 --- a/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/java/org/apache/camel/component/servicenow/springboot/ServiceNowComponentConfiguration.java @@ -21,6 +21,7 @@ import javax.annotation.Generated; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.component.servicenow.ServiceNowComponent; import org.apache.camel.component.servicenow.ServiceNowRelease; +import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.apache.camel.util.jsse.SSLContextParameters; import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy; import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; @@ -35,7 +36,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.servicenow") -public class ServiceNowComponentConfiguration { +public class ServiceNowComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * The ServiceNow default configuration http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java index 7b6ae53..9cf11b5 100644 --- a/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentAutoConfiguration.java @@ -17,50 +17,81 @@ package org.apache.camel.component.servlet.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.servlet.ServletComponent; +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(ServletComponentAutoConfiguration.Condition.class) -@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") -@EnableConfigurationProperties(ServletComponentConfiguration.class) -public class ServletComponentAutoConfiguration { +@AutoConfigureAfter(CamelAutoConfiguration.class) +@EnableConfigurationProperties({ComponentConfigurationProperties.class, + ServletComponentConfiguration.class}) +public class ServletComponentAutoConfiguration extends AllNestedConditions { + + private static final Logger LOGGER = LoggerFactory + .getLogger(ServletComponentAutoConfiguration.class); + @Autowired + private CamelContext camelContext; + @Autowired(required = false) + private List<ComponentCustomizer<ServletComponent>> customizers; + @Autowired + private ComponentConfigurationProperties globalConfiguration; + @Autowired + private ServletComponentConfiguration componentConfiguration; + + public ServletComponentAutoConfiguration() { + 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.servlet"); + } + } @Lazy @Bean(name = "servlet-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(ServletComponent.class) - public ServletComponent configureServletComponent( - CamelContext camelContext, - ServletComponentConfiguration configuration) throws Exception { + public ServletComponent configureServletComponent() throws Exception { ServletComponent component = new ServletComponent(); 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 ServletComponentAutoConfiguration { } 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.servlet"); - if (isEnabled(conditionContext, "camel.component.servlet.", - groupEnabled)) { - return ConditionOutcome.match(message.because("enabled")); + boolean useConfigurers = globalConfiguration.getConfigurer() + .isEnabled() + && componentConfiguration.getConfigurer().isEnabled(); + if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) { + for (ComponentCustomizer<ServletComponent> 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-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConfiguration.java index a54938a..56af726 100644 --- a/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-servlet-starter/src/main/java/org/apache/camel/component/servlet/springboot/ServletComponentConfiguration.java @@ -21,6 +21,7 @@ import org.apache.camel.component.servlet.HttpRegistry; 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.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; @@ -32,7 +33,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @ConfigurationProperties(prefix = "camel.component.servlet") -public class ServletComponentConfiguration { +public class ServletComponentConfiguration + extends + ComponentConfigurationPropertiesCommon { /** * Default name of servlet to use. The default name is CamelServlet.