Repository: camel Updated Branches: refs/heads/master d4c4a84f5 -> c0a9f5cd4
http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java index 72f025e..417d610 100644 --- a/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-protobuf-starter/src/main/java/org/apache/camel/dataformat/protobuf/springboot/ProtobufDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.protobuf.ProtobufDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(ProtobufDataFormatConfiguration.class) public class ProtobufDataFormatAutoConfiguration { - @Bean(name = "protobuf-dataformat") - @Scope("prototype") + @Bean(name = "protobuf-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(ProtobufDataFormat.class) - public ProtobufDataFormat configureProtobufDataFormat( - CamelContext camelContext, - ProtobufDataFormatConfiguration configuration) throws Exception { - ProtobufDataFormat dataformat = new ProtobufDataFormat(); - if (CamelContextAware.class.isAssignableFrom(ProtobufDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureProtobufDataFormatFactory( + final CamelContext camelContext, + final ProtobufDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + ProtobufDataFormat dataformat = new ProtobufDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(ProtobufDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java index 68b7ed8..708a3bd 100644 --- a/platforms/spring-boot/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-rss-starter/src/main/java/org/apache/camel/dataformat/rss/springboot/RssDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.rss.RssDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,26 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(RssDataFormatConfiguration.class) public class RssDataFormatAutoConfiguration { - @Bean(name = "rss-dataformat") - @Scope("prototype") + @Bean(name = "rss-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(RssDataFormat.class) - public RssDataFormat configureRssDataFormat(CamelContext camelContext, - RssDataFormatConfiguration configuration) throws Exception { - RssDataFormat dataformat = new RssDataFormat(); - if (CamelContextAware.class.isAssignableFrom(RssDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureRssDataFormatFactory( + final CamelContext camelContext, + final RssDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + RssDataFormat dataformat = new RssDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(RssDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java index d5f11b7..c5595d9 100644 --- a/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.snakeyaml.SnakeYAMLDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(SnakeYAMLDataFormatConfiguration.class) public class SnakeYAMLDataFormatAutoConfiguration { - @Bean(name = "yaml-snakeyaml-dataformat") - @Scope("prototype") + @Bean(name = "yaml-snakeyaml-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(SnakeYAMLDataFormat.class) - public SnakeYAMLDataFormat configureSnakeYAMLDataFormat( - CamelContext camelContext, - SnakeYAMLDataFormatConfiguration configuration) throws Exception { - SnakeYAMLDataFormat dataformat = new SnakeYAMLDataFormat(); - if (CamelContextAware.class.isAssignableFrom(SnakeYAMLDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureSnakeYAMLDataFormatFactory( + final CamelContext camelContext, + final SnakeYAMLDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + SnakeYAMLDataFormat dataformat = new SnakeYAMLDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(SnakeYAMLDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapJaxbDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapJaxbDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapJaxbDataFormatAutoConfiguration.java index 66da5e5..85e6b5d 100644 --- a/platforms/spring-boot/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapJaxbDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-soap-starter/src/main/java/org/apache/camel/dataformat/soap/springboot/SoapJaxbDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.soap.SoapJaxbDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(SoapJaxbDataFormatConfiguration.class) public class SoapJaxbDataFormatAutoConfiguration { - @Bean(name = "soapjaxb-dataformat") - @Scope("prototype") + @Bean(name = "soapjaxb-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(SoapJaxbDataFormat.class) - public SoapJaxbDataFormat configureSoapJaxbDataFormat( - CamelContext camelContext, - SoapJaxbDataFormatConfiguration configuration) throws Exception { - SoapJaxbDataFormat dataformat = new SoapJaxbDataFormat(); - if (CamelContextAware.class.isAssignableFrom(SoapJaxbDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureSoapJaxbDataFormatFactory( + final CamelContext camelContext, + final SoapJaxbDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + SoapJaxbDataFormat dataformat = new SoapJaxbDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(SoapJaxbDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java index b92c561..6c96a3f 100644 --- a/platforms/spring-boot/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-syslog-starter/src/main/java/org/apache/camel/component/syslog/springboot/SyslogDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.syslog.SyslogDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(SyslogDataFormatConfiguration.class) public class SyslogDataFormatAutoConfiguration { - @Bean(name = "syslog-dataformat") - @Scope("prototype") + @Bean(name = "syslog-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(SyslogDataFormat.class) - public SyslogDataFormat configureSyslogDataFormat( - CamelContext camelContext, - SyslogDataFormatConfiguration configuration) throws Exception { - SyslogDataFormat dataformat = new SyslogDataFormat(); - if (CamelContextAware.class.isAssignableFrom(SyslogDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureSyslogDataFormatFactory( + final CamelContext camelContext, + final SyslogDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + SyslogDataFormat dataformat = new SyslogDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(SyslogDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-tagsoup-starter/src/main/java/org/apache/camel/dataformat/tagsoup/springboot/TidyMarkupDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-tagsoup-starter/src/main/java/org/apache/camel/dataformat/tagsoup/springboot/TidyMarkupDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-tagsoup-starter/src/main/java/org/apache/camel/dataformat/tagsoup/springboot/TidyMarkupDataFormatAutoConfiguration.java index 66ec2fd..b9f2ed8 100644 --- a/platforms/spring-boot/components-starter/camel-tagsoup-starter/src/main/java/org/apache/camel/dataformat/tagsoup/springboot/TidyMarkupDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-tagsoup-starter/src/main/java/org/apache/camel/dataformat/tagsoup/springboot/TidyMarkupDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.tagsoup.TidyMarkupDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,28 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(TidyMarkupDataFormatConfiguration.class) public class TidyMarkupDataFormatAutoConfiguration { - @Bean(name = "tidyMarkup-dataformat") - @Scope("prototype") + @Bean(name = "tidyMarkup-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(TidyMarkupDataFormat.class) - public TidyMarkupDataFormat configureTidyMarkupDataFormat( - CamelContext camelContext, - TidyMarkupDataFormatConfiguration configuration) throws Exception { - TidyMarkupDataFormat dataformat = new TidyMarkupDataFormat(); - if (CamelContextAware.class - .isAssignableFrom(TidyMarkupDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureTidyMarkupDataFormatFactory( + final CamelContext camelContext, + final TidyMarkupDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + TidyMarkupDataFormat dataformat = new TidyMarkupDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(TidyMarkupDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java index 614b891..24b34f7 100644 --- a/platforms/spring-boot/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-tarfile-starter/src/main/java/org/apache/camel/dataformat/tarfile/springboot/TarFileDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.tarfile.TarFileDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(TarFileDataFormatConfiguration.class) public class TarFileDataFormatAutoConfiguration { - @Bean(name = "tarfile-dataformat") - @Scope("prototype") + @Bean(name = "tarfile-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(TarFileDataFormat.class) - public TarFileDataFormat configureTarFileDataFormat( - CamelContext camelContext, - TarFileDataFormatConfiguration configuration) throws Exception { - TarFileDataFormat dataformat = new TarFileDataFormat(); - if (CamelContextAware.class.isAssignableFrom(TarFileDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureTarFileDataFormatFactory( + final CamelContext camelContext, + final TarFileDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + TarFileDataFormat dataformat = new TarFileDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(TarFileDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java index 23d657a..9430915 100644 --- a/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityCsvDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.univocity.UniVocityCsvDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,28 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(UniVocityCsvDataFormatConfiguration.class) public class UniVocityCsvDataFormatAutoConfiguration { - @Bean(name = "univocity-csv-dataformat") - @Scope("prototype") + @Bean(name = "univocity-csv-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(UniVocityCsvDataFormat.class) - public UniVocityCsvDataFormat configureUniVocityCsvDataFormat( - CamelContext camelContext, - UniVocityCsvDataFormatConfiguration configuration) throws Exception { - UniVocityCsvDataFormat dataformat = new UniVocityCsvDataFormat(); - if (CamelContextAware.class - .isAssignableFrom(UniVocityCsvDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureUniVocityCsvDataFormatFactory( + final CamelContext camelContext, + final UniVocityCsvDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + UniVocityCsvDataFormat dataformat = new UniVocityCsvDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(UniVocityCsvDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedWidthDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedWidthDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedWidthDataFormatAutoConfiguration.java index 56b8cea..b7e50b3 100644 --- a/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedWidthDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityFixedWidthDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.univocity.UniVocityFixedWidthDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,29 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(UniVocityFixedWidthDataFormatConfiguration.class) public class UniVocityFixedWidthDataFormatAutoConfiguration { - @Bean(name = "univocity-fixed-dataformat") - @Scope("prototype") + @Bean(name = "univocity-fixed-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(UniVocityFixedWidthDataFormat.class) - public UniVocityFixedWidthDataFormat configureUniVocityFixedWidthDataFormat( - CamelContext camelContext, - UniVocityFixedWidthDataFormatConfiguration configuration) - throws Exception { - UniVocityFixedWidthDataFormat dataformat = new UniVocityFixedWidthDataFormat(); - if (CamelContextAware.class - .isAssignableFrom(UniVocityFixedWidthDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureUniVocityFixedWidthDataFormatFactory( + final CamelContext camelContext, + final UniVocityFixedWidthDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + UniVocityFixedWidthDataFormat dataformat = new UniVocityFixedWidthDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(UniVocityFixedWidthDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java index d137e5b..aaaff6c 100644 --- a/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-univocity-parsers-starter/src/main/java/org/apache/camel/dataformat/univocity/springboot/UniVocityTsvDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.univocity.UniVocityTsvDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,28 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(UniVocityTsvDataFormatConfiguration.class) public class UniVocityTsvDataFormatAutoConfiguration { - @Bean(name = "univocity-tsv-dataformat") - @Scope("prototype") + @Bean(name = "univocity-tsv-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(UniVocityTsvDataFormat.class) - public UniVocityTsvDataFormat configureUniVocityTsvDataFormat( - CamelContext camelContext, - UniVocityTsvDataFormatConfiguration configuration) throws Exception { - UniVocityTsvDataFormat dataformat = new UniVocityTsvDataFormat(); - if (CamelContextAware.class - .isAssignableFrom(UniVocityTsvDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureUniVocityTsvDataFormatFactory( + final CamelContext camelContext, + final UniVocityTsvDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + UniVocityTsvDataFormat dataformat = new UniVocityTsvDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(UniVocityTsvDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-xmlbeans-starter/src/main/java/org/apache/camel/converter/xmlbeans/springboot/XmlBeansDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmlbeans-starter/src/main/java/org/apache/camel/converter/xmlbeans/springboot/XmlBeansDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xmlbeans-starter/src/main/java/org/apache/camel/converter/xmlbeans/springboot/XmlBeansDataFormatAutoConfiguration.java index 3b1d7fe..7ec6a95 100644 --- a/platforms/spring-boot/components-starter/camel-xmlbeans-starter/src/main/java/org/apache/camel/converter/xmlbeans/springboot/XmlBeansDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmlbeans-starter/src/main/java/org/apache/camel/converter/xmlbeans/springboot/XmlBeansDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.converter.xmlbeans.XmlBeansDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(XmlBeansDataFormatConfiguration.class) public class XmlBeansDataFormatAutoConfiguration { - @Bean(name = "xmlBeans-dataformat") - @Scope("prototype") + @Bean(name = "xmlBeans-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XmlBeansDataFormat.class) - public XmlBeansDataFormat configureXmlBeansDataFormat( - CamelContext camelContext, - XmlBeansDataFormatConfiguration configuration) throws Exception { - XmlBeansDataFormat dataformat = new XmlBeansDataFormat(); - if (CamelContextAware.class.isAssignableFrom(XmlBeansDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureXmlBeansDataFormatFactory( + final CamelContext camelContext, + final XmlBeansDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + XmlBeansDataFormat dataformat = new XmlBeansDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(XmlBeansDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-xmljson-starter/src/main/java/org/apache/camel/dataformat/xmljson/springboot/XmlJsonDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmljson-starter/src/main/java/org/apache/camel/dataformat/xmljson/springboot/XmlJsonDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xmljson-starter/src/main/java/org/apache/camel/dataformat/xmljson/springboot/XmlJsonDataFormatAutoConfiguration.java index 2e76919..6c6c7b7 100644 --- a/platforms/spring-boot/components-starter/camel-xmljson-starter/src/main/java/org/apache/camel/dataformat/xmljson/springboot/XmlJsonDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmljson-starter/src/main/java/org/apache/camel/dataformat/xmljson/springboot/XmlJsonDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.xmljson.XmlJsonDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(XmlJsonDataFormatConfiguration.class) public class XmlJsonDataFormatAutoConfiguration { - @Bean(name = "xmljson-dataformat") - @Scope("prototype") + @Bean(name = "xmljson-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XmlJsonDataFormat.class) - public XmlJsonDataFormat configureXmlJsonDataFormat( - CamelContext camelContext, - XmlJsonDataFormatConfiguration configuration) throws Exception { - XmlJsonDataFormat dataformat = new XmlJsonDataFormat(); - if (CamelContextAware.class.isAssignableFrom(XmlJsonDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureXmlJsonDataFormatFactory( + final CamelContext camelContext, + final XmlJsonDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + XmlJsonDataFormat dataformat = new XmlJsonDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(XmlJsonDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/dataformat/xmlrpc/springboot/XmlRpcDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/dataformat/xmlrpc/springboot/XmlRpcDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/dataformat/xmlrpc/springboot/XmlRpcDataFormatAutoConfiguration.java index f8c75a6..79d2439 100644 --- a/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/dataformat/xmlrpc/springboot/XmlRpcDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/dataformat/xmlrpc/springboot/XmlRpcDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.xmlrpc.XmlRpcDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(XmlRpcDataFormatConfiguration.class) public class XmlRpcDataFormatAutoConfiguration { - @Bean(name = "xmlrpc-dataformat") - @Scope("prototype") + @Bean(name = "xmlrpc-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XmlRpcDataFormat.class) - public XmlRpcDataFormat configureXmlRpcDataFormat( - CamelContext camelContext, - XmlRpcDataFormatConfiguration configuration) throws Exception { - XmlRpcDataFormat dataformat = new XmlRpcDataFormat(); - if (CamelContextAware.class.isAssignableFrom(XmlRpcDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureXmlRpcDataFormatFactory( + final CamelContext camelContext, + final XmlRpcDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + XmlRpcDataFormat dataformat = new XmlRpcDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(XmlRpcDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java index bb55452..62ca4d5 100644 --- a/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/dataformat/xmlsecurity/springboot/XMLSecurityDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.xmlsecurity.XMLSecurityDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,28 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(XMLSecurityDataFormatConfiguration.class) public class XMLSecurityDataFormatAutoConfiguration { - @Bean(name = "secureXML-dataformat") - @Scope("prototype") + @Bean(name = "secureXML-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XMLSecurityDataFormat.class) - public XMLSecurityDataFormat configureXMLSecurityDataFormat( - CamelContext camelContext, - XMLSecurityDataFormatConfiguration configuration) throws Exception { - XMLSecurityDataFormat dataformat = new XMLSecurityDataFormat(); - if (CamelContextAware.class - .isAssignableFrom(XMLSecurityDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureXMLSecurityDataFormatFactory( + final CamelContext camelContext, + final XMLSecurityDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + XMLSecurityDataFormat dataformat = new XMLSecurityDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(XMLSecurityDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java index 325c7b7..b45b669 100644 --- a/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.xstream.JsonDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,26 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(JsonDataFormatConfiguration.class) public class JsonDataFormatAutoConfiguration { - @Bean(name = "json-xstream-dataformat") - @Scope("prototype") + @Bean(name = "json-xstream-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(JsonDataFormat.class) - public JsonDataFormat configureJsonDataFormat(CamelContext camelContext, - JsonDataFormatConfiguration configuration) throws Exception { - JsonDataFormat dataformat = new JsonDataFormat(); - if (CamelContextAware.class.isAssignableFrom(JsonDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureJsonDataFormatFactory( + final CamelContext camelContext, + final JsonDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + JsonDataFormat dataformat = new JsonDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(JsonDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java index d75f8b6..c132cab 100644 --- a/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xstream-starter/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.xstream.XStreamDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(XStreamDataFormatConfiguration.class) public class XStreamDataFormatAutoConfiguration { - @Bean(name = "xstream-dataformat") - @Scope("prototype") + @Bean(name = "xstream-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XStreamDataFormat.class) - public XStreamDataFormat configureXStreamDataFormat( - CamelContext camelContext, - XStreamDataFormatConfiguration configuration) throws Exception { - XStreamDataFormat dataformat = new XStreamDataFormat(); - if (CamelContextAware.class.isAssignableFrom(XStreamDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureXStreamDataFormatFactory( + final CamelContext camelContext, + final XStreamDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + XStreamDataFormat dataformat = new XStreamDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(XStreamDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java index 50ef0a8..a0a3213 100644 --- a/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-zipfile-starter/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java @@ -20,7 +20,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.dataformat.zipfile.ZipFileDataFormat; +import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.DataFormatFactory; import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -35,7 +38,6 @@ 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; /** @@ -48,27 +50,36 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @EnableConfigurationProperties(ZipFileDataFormatConfiguration.class) public class ZipFileDataFormatAutoConfiguration { - @Bean(name = "zipfile-dataformat") - @Scope("prototype") + @Bean(name = "zipfile-dataformat-factory") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(ZipFileDataFormat.class) - public ZipFileDataFormat configureZipFileDataFormat( - CamelContext camelContext, - ZipFileDataFormatConfiguration configuration) throws Exception { - ZipFileDataFormat dataformat = new ZipFileDataFormat(); - if (CamelContextAware.class.isAssignableFrom(ZipFileDataFormat.class)) { - CamelContextAware contextAware = CamelContextAware.class - .cast(dataformat); - if (contextAware != null) { - contextAware.setCamelContext(camelContext); + public DataFormatFactory configureZipFileDataFormatFactory( + final CamelContext camelContext, + final ZipFileDataFormatConfiguration configuration) { + return new DataFormatFactory() { + public DataFormat newInstance() { + ZipFileDataFormat dataformat = new ZipFileDataFormat(); + if (CamelContextAware.class + .isAssignableFrom(ZipFileDataFormat.class)) { + CamelContextAware contextAware = CamelContextAware.class + .cast(dataformat); + if (contextAware != null) { + contextAware.setCamelContext(camelContext); + } + } + try { + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, + parameters, null, false); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), dataformat, + parameters); + } catch (Exception e) { + throw new RuntimeCamelException(e); + } + return dataformat; } - } - Map<String, Object> parameters = new HashMap<>(); - IntrospectionSupport.getProperties(configuration, parameters, null, - false); - IntrospectionSupport.setProperties(camelContext, - camelContext.getTypeConverter(), dataformat, parameters); - return dataformat; + }; } public static class Condition extends SpringBootCondition { http://git-wip-us.apache.org/repos/asf/camel/blob/c0a9f5cd/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java ---------------------------------------------------------------------- diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java index f8651ed..3ad7332 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java @@ -885,29 +885,30 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo { javaClass.addImport("org.apache.camel.CamelContextAware"); javaClass.addImport(model.getJavaType()); javaClass.addImport("org.apache.camel.CamelContext"); + javaClass.addImport("org.apache.camel.RuntimeCamelException"); + javaClass.addImport("org.apache.camel.spi.DataFormat"); + javaClass.addImport("org.apache.camel.spi.DataFormatFactory"); String body = createDataFormatBody(model.getShortJavaType(), hasOptions); - String methodName = "configure" + model.getShortJavaType(); + String methodName = "configure" + model.getShortJavaType() + "Factory"; MethodSource<JavaClassSource> method = javaClass.addMethod() .setName(methodName) .setPublic() .setBody(body) - .setReturnType(model.getShortJavaType()) - .addThrows(Exception.class); + .setReturnType("org.apache.camel.spi.DataFormatFactory"); - method.addParameter("CamelContext", "camelContext"); + method.addParameter("CamelContext", "camelContext").setFinal(true); if (hasOptions) { - method.addParameter(configurationName, "configuration"); + method.addParameter(configurationName, "configuration").setFinal(true); } // Determine all the aliases // adding the '-dataformat' suffix to prevent collision with component names - String[] springBeanAliases = dataFormatAliases.stream().map(alias -> alias + "-dataformat").toArray(size -> new String[size]); + String[] springBeanAliases = dataFormatAliases.stream().map(alias -> alias + "-dataformat-factory").toArray(size -> new String[size]); method.addAnnotation(Bean.class).setStringArrayValue("name", springBeanAliases); - method.addAnnotation(Scope.class).setStringValue("prototype"); method.addAnnotation(ConditionalOnClass.class).setLiteralValue("value", "CamelContext.class"); method.addAnnotation(ConditionalOnMissingBean.class).setLiteralValue("value", model.getShortJavaType() + ".class"); @@ -1059,22 +1060,29 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo { private static String createDataFormatBody(String shortJavaType, boolean hasOptions) { StringBuilder sb = new StringBuilder(); - sb.append(shortJavaType).append(" dataformat = new ").append(shortJavaType).append("();").append("\n"); - sb.append("if (CamelContextAware.class.isAssignableFrom(").append(shortJavaType).append(".class)) {\n"); - sb.append(" CamelContextAware contextAware = CamelContextAware.class.cast(dataformat);\n"); - sb.append(" if (contextAware != null) {\n"); - sb.append(" contextAware.setCamelContext(camelContext);\n"); - sb.append(" }\n"); - sb.append("}\n"); + sb.append("return new DataFormatFactory() {\n"); + sb.append(" public DataFormat newInstance() {\n"); + sb.append(" ").append(shortJavaType).append(" dataformat = new ").append(shortJavaType).append("();").append("\n"); + sb.append(" if (CamelContextAware.class.isAssignableFrom(").append(shortJavaType).append(".class)) {\n"); + sb.append(" CamelContextAware contextAware = CamelContextAware.class.cast(dataformat);\n"); + sb.append(" if (contextAware != null) {\n"); + sb.append(" contextAware.setCamelContext(camelContext);\n"); + sb.append(" }\n"); + sb.append(" }\n"); if (hasOptions) { sb.append("\n"); - sb.append("Map<String, Object> parameters = new HashMap<>();\n"); - sb.append("IntrospectionSupport.getProperties(configuration, parameters, null, false);\n"); - sb.append("\n"); - sb.append("IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);\n"); + sb.append(" try {\n"); + sb.append(" Map<String, Object> parameters = new HashMap<>();\n"); + sb.append(" IntrospectionSupport.getProperties(configuration, parameters, null, false);\n"); + sb.append(" IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);\n"); + sb.append(" } catch (Exception e) {\n"); + sb.append(" throw new RuntimeCamelException(e);\n"); + sb.append(" }\n"); } sb.append("\n"); - sb.append("return dataformat;"); + sb.append(" return dataformat;\n"); + sb.append(" }\n"); + sb.append("};\n"); return sb.toString(); }