Repository: camel Updated Branches: refs/heads/master 9a0278461 -> b46e7c21c
[Spring Boot] Added support for multiple conversion services. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b46e7c21 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b46e7c21 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b46e7c21 Branch: refs/heads/master Commit: b46e7c21c204c70e0df0906313b3b5d23fb2f2e6 Parents: 9a02784 Author: Henryk Konsek <[email protected]> Authored: Mon Jan 5 16:06:48 2015 +0100 Committer: Henryk Konsek <[email protected]> Committed: Mon Jan 5 16:06:48 2015 +0100 ---------------------------------------------------------------------- .../boot/SpringConversionServiceConfiguration.java | 6 ++++-- .../apache/camel/spring/boot/SpringTypeConverter.java | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b46e7c21/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringConversionServiceConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringConversionServiceConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringConversionServiceConfiguration.java index eb0dab0..7efcd2e 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringConversionServiceConfiguration.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringConversionServiceConfiguration.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spring.boot; +import static java.util.Arrays.asList; + import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -38,8 +40,8 @@ public class SpringConversionServiceConfiguration { } @Bean - SpringTypeConverter springTypeConverter(ConversionService conversionService) { - return new SpringTypeConverter(conversionService); + SpringTypeConverter springTypeConverter(ConversionService[] conversionServices) { + return new SpringTypeConverter(asList(conversionServices)); } } http://git-wip-us.apache.org/repos/asf/camel/blob/b46e7c21/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringTypeConverter.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringTypeConverter.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringTypeConverter.java index 8748ef9..4ce793c 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringTypeConverter.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringTypeConverter.java @@ -16,6 +16,8 @@ */ package org.apache.camel.spring.boot; +import java.util.List; + import org.apache.camel.Exchange; import org.apache.camel.TypeConversionException; import org.apache.camel.support.TypeConverterSupport; @@ -24,17 +26,19 @@ import org.springframework.core.convert.ConversionService; public class SpringTypeConverter extends TypeConverterSupport { - private final ConversionService conversionService; + private final List<ConversionService> conversionServices; @Autowired - public SpringTypeConverter(ConversionService conversionService) { - this.conversionService = conversionService; + public SpringTypeConverter(List<ConversionService> conversionServices) { + this.conversionServices = conversionServices; } @Override public <T> T convertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException { - if (conversionService.canConvert(value.getClass(), type)) { - return conversionService.convert(value, type); + for (ConversionService conversionService : conversionServices) { + if (conversionService.canConvert(value.getClass(), type)) { + return conversionService.convert(value, type); + } } return null; }
