This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/master by this push: new e53ae52 Sync with master e53ae52 is described below commit e53ae521ee74f31603d1fb62099962b02065f23e Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Mon Feb 8 06:58:08 2021 +0100 Sync with master --- .../catalog/components/spring-redis.json | 1 + components-starter/camel-corda-starter/pom.xml | 8 +++ components-starter/camel-iota-starter/pom.xml | 12 ++++ .../src/main/docs/spring-redis-starter.adoc | 3 +- .../RedisComponentAutoConfiguration.java | 2 +- .../springboot/RedisComponentConfiguration.java | 14 +++++ .../redis/springboot/RedisComponentConverter.java | 65 ++++++++++++++++++++++ .../src/main/resources/META-INF/spring.factories | 4 +- docs/modules/ROOT/pages/spring-redis-starter.adoc | 3 +- 9 files changed, 108 insertions(+), 4 deletions(-) diff --git a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/spring-redis.json b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/spring-redis.json index e818dc8..c030b76 100644 --- a/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/spring-redis.json +++ b/catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/components/spring-redis.json @@ -22,6 +22,7 @@ "lenientProperties": false }, "componentProperties": { + "redisTemplate": { "kind": "property", "displayName": "Redis Template", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.springframework.data.redis.core.RedisTemplate", "deprecated": false, "autowired": true, "secret": false, "description": "Reference to a pre-configured RedisTemplate instance to use." }, "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a me [...] "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during star [...] "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...] diff --git a/components-starter/camel-corda-starter/pom.xml b/components-starter/camel-corda-starter/pom.xml index d667b96..158a2e5 100644 --- a/components-starter/camel-corda-starter/pom.xml +++ b/components-starter/camel-corda-starter/pom.xml @@ -41,6 +41,14 @@ <!--START OF GENERATED CODE--> <exclusions> <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </exclusion> + <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> </exclusion> diff --git a/components-starter/camel-iota-starter/pom.xml b/components-starter/camel-iota-starter/pom.xml index 95d1ad5..758052f 100644 --- a/components-starter/camel-iota-starter/pom.xml +++ b/components-starter/camel-iota-starter/pom.xml @@ -38,6 +38,18 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-iota</artifactId> <version>${camel-version}</version> + <!--START OF GENERATED CODE--> + <exclusions> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </exclusion> + </exclusions> + <!--END OF GENERATED CODE--> </dependency> <!--START OF GENERATED CODE--> <dependency> diff --git a/components-starter/camel-spring-redis-starter/src/main/docs/spring-redis-starter.adoc b/components-starter/camel-spring-redis-starter/src/main/docs/spring-redis-starter.adoc index 23881aa..a0cc931 100644 --- a/components-starter/camel-spring-redis-starter/src/main/docs/spring-redis-starter.adoc +++ b/components-starter/camel-spring-redis-starter/src/main/docs/spring-redis-starter.adoc @@ -17,7 +17,7 @@ When using spring-redis with Spring Boot make sure to use the following Maven de ---- -The component supports 4 options, which are listed below. +The component supports 5 options, which are listed below. @@ -28,5 +28,6 @@ The component supports 4 options, which are listed below. | *camel.component.spring-redis.bridge-error-handler* | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | Boolean | *camel.component.spring-redis.enabled* | Whether to enable auto configuration of the spring-redis component. This is enabled by default. | | Boolean | *camel.component.spring-redis.lazy-start-producer* | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is process [...] +| *camel.component.spring-redis.redis-template* | Reference to a pre-configured RedisTemplate instance to use. The option is a org.springframework.data.redis.core.RedisTemplate type. | | RedisTemplate |=== // spring-boot-auto-configure options: END diff --git a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java index 23628b8..b6768b8 100644 --- a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java +++ b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentAutoConfiguration.java @@ -44,7 +44,7 @@ import org.springframework.context.annotation.Lazy; @Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class) @EnableConfigurationProperties({ComponentConfigurationProperties.class,RedisComponentConfiguration.class}) @ConditionalOnHierarchicalProperties({"camel.component", "camel.component.spring-redis"}) -@AutoConfigureAfter(CamelAutoConfiguration.class) +@AutoConfigureAfter({CamelAutoConfiguration.class, RedisComponentConverter.class}) public class RedisComponentAutoConfiguration { @Autowired diff --git a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConfiguration.java b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConfiguration.java index 6b4a999..a743e45 100644 --- a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConfiguration.java +++ b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConfiguration.java @@ -19,6 +19,7 @@ package org.apache.camel.component.redis.springboot; import javax.annotation.Generated; import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.data.redis.core.RedisTemplate; /** * Send and receive messages from Redis. @@ -37,6 +38,11 @@ public class RedisComponentConfiguration */ private Boolean enabled; /** + * Reference to a pre-configured RedisTemplate instance to use. The option + * is a org.springframework.data.redis.core.RedisTemplate type. + */ + private RedisTemplate redisTemplate; + /** * Allows for bridging the consumer to the Camel routing Error Handler, * which mean any exceptions occurred while the consumer is trying to pickup * incoming messages, or the likes, will now be processed as a message and @@ -66,6 +72,14 @@ public class RedisComponentConfiguration */ private Boolean autowiredEnabled = true; + public RedisTemplate getRedisTemplate() { + return redisTemplate; + } + + public void setRedisTemplate(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + public Boolean getBridgeErrorHandler() { return bridgeErrorHandler; } diff --git a/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java new file mode 100644 index 0000000..34c648d --- /dev/null +++ b/components-starter/camel-spring-redis-starter/src/main/java/org/apache/camel/component/redis/springboot/RedisComponentConverter.java @@ -0,0 +1,65 @@ +/* + * 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.component.redis.springboot; + +import java.util.LinkedHashSet; +import java.util.Set; +import javax.annotation.Generated; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.TypeDescriptor; +import org.springframework.core.convert.converter.GenericConverter; +import org.springframework.stereotype.Component; + +/** + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo") +@Configuration(proxyBeanMethods = false) +@ConfigurationPropertiesBinding +@Component +public class RedisComponentConverter implements GenericConverter { + + @Autowired + private ApplicationContext applicationContext; + + public Set<ConvertiblePair> getConvertibleTypes() { + Set<ConvertiblePair> answer = new LinkedHashSet<>(); + answer.add(new ConvertiblePair(String.class, org.springframework.data.redis.core.RedisTemplate.class)); + return answer; + } + + public Object convert( + Object source, + TypeDescriptor sourceType, + TypeDescriptor targetType) { + if (source == null) { + return null; + } + String ref = source.toString(); + if (!ref.startsWith("#")) { + return null; + } + ref = ref.startsWith("#bean:") ? ref.substring(6) : ref.substring(1); + switch (targetType.getName()) { + case "org.springframework.data.redis.core.RedisTemplate": return applicationContext.getBean(ref, org.springframework.data.redis.core.RedisTemplate.class); + } + return null; + } +} \ No newline at end of file diff --git a/components-starter/camel-spring-redis-starter/src/main/resources/META-INF/spring.factories b/components-starter/camel-spring-redis-starter/src/main/resources/META-INF/spring.factories index f1f5133..3ba18a5 100644 --- a/components-starter/camel-spring-redis-starter/src/main/resources/META-INF/spring.factories +++ b/components-starter/camel-spring-redis-starter/src/main/resources/META-INF/spring.factories @@ -15,4 +15,6 @@ ## limitations under the License. ## --------------------------------------------------------------------------- org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -org.apache.camel.component.redis.springboot.RedisComponentAutoConfiguration +org.apache.camel.component.redis.springboot.RedisComponentAutoConfiguration,\ +org.apache.camel.component.redis.springboot.RedisComponentConverter + diff --git a/docs/modules/ROOT/pages/spring-redis-starter.adoc b/docs/modules/ROOT/pages/spring-redis-starter.adoc index 23881aa..a0cc931 100644 --- a/docs/modules/ROOT/pages/spring-redis-starter.adoc +++ b/docs/modules/ROOT/pages/spring-redis-starter.adoc @@ -17,7 +17,7 @@ When using spring-redis with Spring Boot make sure to use the following Maven de ---- -The component supports 4 options, which are listed below. +The component supports 5 options, which are listed below. @@ -28,5 +28,6 @@ The component supports 4 options, which are listed below. | *camel.component.spring-redis.bridge-error-handler* | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | Boolean | *camel.component.spring-redis.enabled* | Whether to enable auto configuration of the spring-redis component. This is enabled by default. | | Boolean | *camel.component.spring-redis.lazy-start-producer* | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is process [...] +| *camel.component.spring-redis.redis-template* | Reference to a pre-configured RedisTemplate instance to use. The option is a org.springframework.data.redis.core.RedisTemplate type. | | RedisTemplate |=== // spring-boot-auto-configure options: END