CAMEL-11237: Regen spring-boot Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/23a97258 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/23a97258 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/23a97258
Branch: refs/heads/master Commit: 23a97258a24a78aa557d79725558e822ec77fdc5 Parents: 90bb213 Author: Dmitry Volodin <dmvo...@gmail.com> Authored: Tue May 23 18:46:42 2017 +0300 Committer: Dmitry Volodin <dmvo...@gmail.com> Committed: Tue May 23 18:46:42 2017 +0300 ---------------------------------------------------------------------- .../GrpcComponentAutoConfiguration.java | 38 +++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/23a97258/platforms/spring-boot/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java index 9344c25..53a07fa 100644 --- a/platforms/spring-boot/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-grpc-starter/src/main/java/org/apache/camel/component/grpc/springboot/GrpcComponentAutoConfiguration.java @@ -23,10 +23,12 @@ import javax.annotation.Generated; import org.apache.camel.CamelContext; import org.apache.camel.component.grpc.GrpcComponent; import org.apache.camel.spi.ComponentCustomizer; +import org.apache.camel.spi.HasId; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.apache.camel.spring.boot.ComponentConfigurationProperties; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; +import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; import org.apache.camel.util.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -36,6 +38,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; @@ -56,13 +59,13 @@ public class GrpcComponentAutoConfiguration { private static final Logger LOGGER = LoggerFactory .getLogger(GrpcComponentAutoConfiguration.class); @Autowired + private ApplicationContext applicationContext; + @Autowired private CamelContext camelContext; + @Autowired + private GrpcComponentConfiguration configuration; @Autowired(required = false) private List<ComponentCustomizer<GrpcComponent>> customizers; - @Autowired - private ComponentConfigurationProperties globalConfiguration; - @Autowired - private GrpcComponentConfiguration componentConfiguration; static class GroupConditions extends GroupCondition { public GroupConditions() { @@ -77,8 +80,8 @@ public class GrpcComponentAutoConfiguration { GrpcComponent component = new GrpcComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(componentConfiguration, parameters, - null, false); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); Class<?> paramClass = value.getClass(); @@ -101,14 +104,23 @@ public class GrpcComponentAutoConfiguration { } IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); - boolean useCustomizers = globalConfiguration.getCustomizer() - .isEnabled() - && componentConfiguration.getCustomizer().isEnabled(); - if (useCustomizers && ObjectHelper.isNotEmpty(customizers)) { + if (ObjectHelper.isNotEmpty(customizers)) { for (ComponentCustomizer<GrpcComponent> customizer : customizers) { - LOGGER.debug("Configure component {}, with customizer {}", - component, customizer); - customizer.customize(component); + boolean useCustomizer = (customizer instanceof HasId) + ? HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.grpc.customizer", + ((HasId) customizer).getId()) + : HierarchicalPropertiesEvaluator.evaluate( + applicationContext.getEnvironment(), + "camel.component.customizer", + "camel.component.grpc.customizer"); + if (useCustomizer) { + LOGGER.debug("Configure component {}, with customizer {}", + component, customizer); + customizer.customize(component); + } } } return component;