Repository: camel Updated Branches: refs/heads/master cc06080b0 -> f5f187bd7
http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java index 098d350..45fc318 100644 --- a/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentAutoConfiguration.java @@ -16,8 +16,11 @@ */ package org.apache.camel.component.stringtemplate.springboot; +import java.util.HashMap; +import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.component.stringtemplate.StringTemplateComponent; +import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; @@ -26,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; @@ -40,6 +44,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(StringTemplateComponentAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(StringTemplateComponentConfiguration.class) public class StringTemplateComponentAutoConfiguration { @Lazy @@ -47,9 +52,36 @@ public class StringTemplateComponentAutoConfiguration { @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(StringTemplateComponent.class) public StringTemplateComponent configureStringTemplateComponent( - CamelContext camelContext) throws Exception { + CamelContext camelContext, + StringTemplateComponentConfiguration configuration) + throws Exception { StringTemplateComponent component = new StringTemplateComponent(); component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); return component; } http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java new file mode 100644 index 0000000..3699ee0 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-stringtemplate-starter/src/main/java/org/apache/camel/component/stringtemplate/springboot/StringTemplateComponentConfiguration.java @@ -0,0 +1,44 @@ +/** + * 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.stringtemplate.springboot; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Transforms the message using a String template. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.string-template") +public class StringTemplateComponentConfiguration { + + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConfiguration.java index 435bf3f..b4b53fd 100644 --- a/platforms/spring-boot/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-telegram-starter/src/main/java/org/apache/camel/component/telegram/springboot/TelegramComponentConfiguration.java @@ -31,6 +31,12 @@ public class TelegramComponentConfiguration { * is not provided in the endpoints. */ private String authorizationToken; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public String getAuthorizationToken() { return authorizationToken; @@ -39,4 +45,13 @@ public class TelegramComponentConfiguration { public void setAuthorizationToken(String authorizationToken) { this.authorizationToken = authorizationToken; } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java index 72c4d56..e0efc72 100644 --- a/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentAutoConfiguration.java @@ -16,8 +16,11 @@ */ package org.apache.camel.component.tika.springboot; +import java.util.HashMap; +import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.component.tika.TikaComponent; +import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; @@ -26,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; @@ -40,16 +44,42 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(TikaComponentAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(TikaComponentConfiguration.class) public class TikaComponentAutoConfiguration { @Lazy @Bean(name = "tika-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(TikaComponent.class) - public TikaComponent configureTikaComponent(CamelContext camelContext) - throws Exception { + public TikaComponent configureTikaComponent(CamelContext camelContext, + TikaComponentConfiguration configuration) throws Exception { TikaComponent component = new TikaComponent(); component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); return component; } http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentConfiguration.java new file mode 100644 index 0000000..5f8f7ff --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-tika-starter/src/main/java/org/apache/camel/component/tika/springboot/TikaComponentConfiguration.java @@ -0,0 +1,45 @@ +/** + * 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.tika.springboot; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * This component integrates with Apache Tika to extract content and metadata + * from thousands of file types. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.tika") +public class TikaComponentConfiguration { + + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java index 114bc76..21cd925 100644 --- a/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-twitter-starter/src/main/java/org/apache/camel/component/twitter/springboot/TwitterComponentConfiguration.java @@ -59,6 +59,12 @@ public class TwitterComponentConfiguration { * The http proxy port which can be used for the camel-twitter. */ private Integer httpProxyPort; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public String getAccessToken() { return accessToken; @@ -123,4 +129,13 @@ public class TwitterComponentConfiguration { public void setHttpProxyPort(Integer httpProxyPort) { this.httpProxyPort = httpProxyPort; } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java index a03aa81..959d7e3 100644 --- a/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-undertow-starter/src/main/java/org/apache/camel/component/undertow/springboot/UndertowComponentConfiguration.java @@ -41,6 +41,12 @@ public class UndertowComponentConfiguration { */ @NestedConfigurationProperty private SSLContextParameters sslContextParameters; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public UndertowHttpBinding getUndertowHttpBinding() { return undertowHttpBinding; @@ -58,4 +64,13 @@ public class UndertowComponentConfiguration { SSLContextParameters sslContextParameters) { this.sslContextParameters = sslContextParameters; } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java index de0eed8..365d4af 100644 --- a/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-velocity-starter/src/main/java/org/apache/camel/component/velocity/springboot/VelocityComponentConfiguration.java @@ -33,6 +33,12 @@ public class VelocityComponentConfiguration { */ @NestedConfigurationProperty private VelocityEngine velocityEngine; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public VelocityEngine getVelocityEngine() { return velocityEngine; @@ -41,4 +47,13 @@ public class VelocityComponentConfiguration { public void setVelocityEngine(VelocityEngine velocityEngine) { this.velocityEngine = velocityEngine; } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConfiguration.java index c8df960..0a44bdf 100644 --- a/platforms/spring-boot/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-vertx-starter/src/main/java/org/apache/camel/component/vertx/springboot/VertxComponentConfiguration.java @@ -60,6 +60,12 @@ public class VertxComponentConfiguration { * default value is 60. */ private Integer timeout = 60; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public VertxFactory getVertxFactory() { return vertxFactory; @@ -108,4 +114,13 @@ public class VertxComponentConfiguration { public void setTimeout(Integer timeout) { this.timeout = timeout; } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java index be36aaa..31b87da 100644 --- a/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentAutoConfiguration.java @@ -16,8 +16,11 @@ */ package org.apache.camel.component.weather.springboot; +import java.util.HashMap; +import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.component.weather.WeatherComponent; +import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; @@ -26,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; @@ -40,16 +44,43 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(WeatherComponentAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(WeatherComponentConfiguration.class) public class WeatherComponentAutoConfiguration { @Lazy @Bean(name = "weather-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(WeatherComponent.class) - public WeatherComponent configureWeatherComponent(CamelContext camelContext) - throws Exception { + public WeatherComponent configureWeatherComponent( + CamelContext camelContext, + WeatherComponentConfiguration configuration) throws Exception { WeatherComponent component = new WeatherComponent(); component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); return component; } http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentConfiguration.java new file mode 100644 index 0000000..7389950 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-weather-starter/src/main/java/org/apache/camel/component/weather/springboot/WeatherComponentConfiguration.java @@ -0,0 +1,44 @@ +/** + * 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.weather.springboot; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Polls the weather information from Open Weather Map. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.weather") +public class WeatherComponentConfiguration { + + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-websocket-starter/src/main/java/org/apache/camel/component/websocket/springboot/WebsocketComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-websocket-starter/src/main/java/org/apache/camel/component/websocket/springboot/WebsocketComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-websocket-starter/src/main/java/org/apache/camel/component/websocket/springboot/WebsocketComponentConfiguration.java index e5c89a9..4a09926 100644 --- a/platforms/spring-boot/components-starter/camel-websocket-starter/src/main/java/org/apache/camel/component/websocket/springboot/WebsocketComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-websocket-starter/src/main/java/org/apache/camel/component/websocket/springboot/WebsocketComponentConfiguration.java @@ -95,6 +95,12 @@ public class WebsocketComponentConfiguration { * reserved for the default implementation. */ private Map<String, WebSocketFactory> socketFactory; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public String getStaticResources() { return staticResources; @@ -192,4 +198,13 @@ public class WebsocketComponentConfiguration { public void setSocketFactory(Map<String, WebSocketFactory> socketFactory) { this.socketFactory = socketFactory; } + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentAutoConfiguration.java index ab993bb..68c1c93 100644 --- a/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentAutoConfiguration.java @@ -16,8 +16,11 @@ */ package org.apache.camel.component.xmlrpc.springboot; +import java.util.HashMap; +import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.component.xmlrpc.XmlRpcComponent; +import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; @@ -26,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; @@ -40,16 +44,42 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(XmlRpcComponentAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(XmlRpcComponentConfiguration.class) public class XmlRpcComponentAutoConfiguration { @Lazy @Bean(name = "xmlrpc-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XmlRpcComponent.class) - public XmlRpcComponent configureXmlRpcComponent(CamelContext camelContext) - throws Exception { + public XmlRpcComponent configureXmlRpcComponent(CamelContext camelContext, + XmlRpcComponentConfiguration configuration) throws Exception { XmlRpcComponent component = new XmlRpcComponent(); component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); return component; } http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentConfiguration.java new file mode 100644 index 0000000..08d52b6 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-xmlrpc-starter/src/main/java/org/apache/camel/component/xmlrpc/springboot/XmlRpcComponentConfiguration.java @@ -0,0 +1,44 @@ +/** + * 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.xmlrpc.springboot; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * The xmlrpc component is used for sending messages to a XML RPC service. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.xmlrpc") +public class XmlRpcComponentConfiguration { + + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignatureComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignatureComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignatureComponentConfiguration.java index 7a09eec..4d6be26 100644 --- a/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignatureComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmlsecurity-starter/src/main/java/org/apache/camel/component/xmlsecurity/springboot/XmlSignatureComponentConfiguration.java @@ -48,6 +48,12 @@ public class XmlSignatureComponentConfiguration { * configuring endpoints. */ private XmlVerifierConfigurationNestedConfiguration verifierConfiguration; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public XmlSignerConfigurationNestedConfiguration getSignerConfiguration() { return signerConfiguration; @@ -67,6 +73,15 @@ public class XmlSignatureComponentConfiguration { this.verifierConfiguration = verifierConfiguration; } + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + public static class XmlSignerConfigurationNestedConfiguration { public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.xmlsecurity.processor.XmlSignerConfiguration.class; private CamelContext camelContext; http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java index a48647e..2db4c07 100644 --- a/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentAutoConfiguration.java @@ -16,8 +16,11 @@ */ package org.apache.camel.component.xmpp.springboot; +import java.util.HashMap; +import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.component.xmpp.XmppComponent; +import org.apache.camel.util.IntrospectionSupport; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; @@ -26,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.bind.RelaxedPropertyResolver; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; @@ -40,16 +44,42 @@ import org.springframework.core.type.AnnotatedTypeMetadata; @ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration") @Conditional(XmppComponentAutoConfiguration.Condition.class) @AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration") +@EnableConfigurationProperties(XmppComponentConfiguration.class) public class XmppComponentAutoConfiguration { @Lazy @Bean(name = "xmpp-component") @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(XmppComponent.class) - public XmppComponent configureXmppComponent(CamelContext camelContext) - throws Exception { + public XmppComponent configureXmppComponent(CamelContext camelContext, + XmppComponentConfiguration configuration) throws Exception { XmppComponent component = new XmppComponent(); component.setCamelContext(camelContext); + Map<String, Object> parameters = new HashMap<>(); + IntrospectionSupport.getProperties(configuration, parameters, null, + false); + for (Map.Entry<String, Object> entry : parameters.entrySet()) { + Object value = entry.getValue(); + Class<?> paramClass = value.getClass(); + if (paramClass.getName().endsWith("NestedConfiguration")) { + Class nestedClass = null; + try { + nestedClass = (Class) paramClass.getDeclaredField( + "CAMEL_NESTED_CLASS").get(null); + HashMap<String, Object> nestedParameters = new HashMap<>(); + IntrospectionSupport.getProperties(value, nestedParameters, + null, false); + Object nestedProperty = nestedClass.newInstance(); + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), nestedProperty, + nestedParameters); + entry.setValue(nestedProperty); + } catch (NoSuchFieldException e) { + } + } + } + IntrospectionSupport.setProperties(camelContext, + camelContext.getTypeConverter(), component, parameters); return component; } http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentConfiguration.java new file mode 100644 index 0000000..2663cb7 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-xmpp-starter/src/main/java/org/apache/camel/component/xmpp/springboot/XmppComponentConfiguration.java @@ -0,0 +1,44 @@ +/** + * 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.xmpp.springboot; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * To send and receive messages from a XMPP (chat) server. + * + * Generated by camel-package-maven-plugin - do not edit this file! + */ +@ConfigurationProperties(prefix = "camel.component.xmpp") +public class XmppComponentConfiguration { + + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; + + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-yammer-starter/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-yammer-starter/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-yammer-starter/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentConfiguration.java index 6ac4d92..780d9f5 100644 --- a/platforms/spring-boot/components-starter/camel-yammer-starter/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-yammer-starter/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentConfiguration.java @@ -45,6 +45,12 @@ public class YammerComponentConfiguration { * To use a shared yammer configuration */ private YammerConfigurationNestedConfiguration config; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public String getConsumerKey() { return consumerKey; @@ -78,6 +84,15 @@ public class YammerComponentConfiguration { this.config = config; } + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + public static class YammerConfigurationNestedConfiguration { public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.yammer.YammerConfiguration.class; /** http://git-wip-us.apache.org/repos/asf/camel/blob/c7907e9f/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConfiguration.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConfiguration.java index 57b177f..6c424ab 100644 --- a/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-zookeeper-starter/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentConfiguration.java @@ -32,6 +32,12 @@ public class ZooKeeperComponentConfiguration { * To use a shared ZooKeeperConfiguration */ private ZooKeeperConfigurationNestedConfiguration configuration; + /** + * Whether the component should resolve property placeholders on itself when + * starting. Only properties which are of String type can use property + * placeholders. + */ + private Boolean resolvePropertyPlaceholders = true; public ZooKeeperConfigurationNestedConfiguration getConfiguration() { return configuration; @@ -42,6 +48,15 @@ public class ZooKeeperComponentConfiguration { this.configuration = configuration; } + public Boolean getResolvePropertyPlaceholders() { + return resolvePropertyPlaceholders; + } + + public void setResolvePropertyPlaceholders( + Boolean resolvePropertyPlaceholders) { + this.resolvePropertyPlaceholders = resolvePropertyPlaceholders; + } + public static class ZooKeeperConfigurationNestedConfiguration { public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.zookeeper.ZooKeeperConfiguration.class; /**