Repository: camel Updated Branches: refs/heads/master 75c62f2d2 -> 084ab29a6
[Spring Boot] Refactoring. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/084ab29a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/084ab29a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/084ab29a Branch: refs/heads/master Commit: 084ab29a67bd5fd532dc95898604eef35ae7a9c8 Parents: 75c62f2 Author: Henryk Konsek <[email protected]> Authored: Tue Jan 20 11:42:59 2015 +0100 Committer: Henryk Konsek <[email protected]> Committed: Tue Jan 20 11:43:09 2015 +0100 ---------------------------------------------------------------------- .../spring/boot/CamelAutoConfiguration.java | 2 +- .../SpringConversionServiceConfiguration.java | 58 -------------------- .../boot/TypeConversionConfiguration.java | 58 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/084ab29a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java index bb0bf6d..6bfbe39 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java @@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import; @Configuration @EnableConfigurationProperties(CamelConfigurationProperties.class) -@Import(SpringConversionServiceConfiguration.class) +@Import(TypeConversionConfiguration.class) public class CamelAutoConfiguration { /** http://git-wip-us.apache.org/repos/asf/camel/blob/084ab29a/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 deleted file mode 100644 index 1d5808a..0000000 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/SpringConversionServiceConfiguration.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.spring.boot; - -import static java.util.Arrays.asList; - -import org.apache.camel.CamelContext; -import org.apache.camel.TypeConverter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.converter.Converter; -import org.springframework.core.convert.support.DefaultConversionService; - -@Configuration -@ConditionalOnProperty(value = "camel.springboot.typeConversion", matchIfMissing = true) -public class SpringConversionServiceConfiguration { - - @Bean - TypeConverter typeConverter(CamelContext camelContext) { - return camelContext.getTypeConverter(); - } - - @ConditionalOnMissingBean - @Bean - ConversionService conversionService(ApplicationContext applicationContext) { - DefaultConversionService service = new DefaultConversionService(); - for (Converter converter : applicationContext.getBeansOfType(Converter.class).values()) { - service.addConverter(converter); - } - return service; - } - - @Bean - SpringTypeConverter springTypeConverter(CamelContext camelContext, ConversionService[] conversionServices) { - SpringTypeConverter springTypeConverter = new SpringTypeConverter(asList(conversionServices)); - camelContext.getTypeConverterRegistry().addFallbackTypeConverter(springTypeConverter, true); - return springTypeConverter; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/084ab29a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/TypeConversionConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/TypeConversionConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/TypeConversionConfiguration.java new file mode 100644 index 0000000..ecb6099 --- /dev/null +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/TypeConversionConfiguration.java @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.boot; + +import static java.util.Arrays.asList; + +import org.apache.camel.CamelContext; +import org.apache.camel.TypeConverter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.ConversionService; +import org.springframework.core.convert.converter.Converter; +import org.springframework.core.convert.support.DefaultConversionService; + +@Configuration +@ConditionalOnProperty(value = "camel.springboot.typeConversion", matchIfMissing = true) +public class TypeConversionConfiguration { + + @Bean + TypeConverter typeConverter(CamelContext camelContext) { + return camelContext.getTypeConverter(); + } + + @Bean + SpringTypeConverter springTypeConverter(CamelContext camelContext, ConversionService[] conversionServices) { + SpringTypeConverter springTypeConverter = new SpringTypeConverter(asList(conversionServices)); + camelContext.getTypeConverterRegistry().addFallbackTypeConverter(springTypeConverter, true); + return springTypeConverter; + } + + @ConditionalOnMissingBean + @Bean + ConversionService defaultCamelConversionService(ApplicationContext applicationContext) { + DefaultConversionService service = new DefaultConversionService(); + for (Converter converter : applicationContext.getBeansOfType(Converter.class).values()) { + service.addConverter(converter); + } + return service; + } + +}
