You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/05/19 12:35:23 UTC
[13/38] camel git commit: CAMEL-11291: spring boot starters: allow to
hook into auto configuration process
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java
index aa05c12..632a8fe 100644
--- a/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentAutoConfiguration.java
@@ -16,68 +16,114 @@
*/
package org.apache.camel.component.mllp.springboot;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mllp.MllpComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MllpComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-public class MllpComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MllpComponentConfiguration.class})
+public class MllpComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MllpComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MllpComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MllpComponentConfiguration componentConfiguration;
+
+ public MllpComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mllp");
+ }
+ }
@Lazy
@Bean(name = "mllp-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MllpComponent.class)
- public MllpComponent configureMllpComponent(CamelContext camelContext)
- throws Exception {
+ public MllpComponent configureMllpComponent() throws Exception {
MllpComponent component = new MllpComponent();
component.setCamelContext(camelContext);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mllp");
- if (isEnabled(conditionContext, "camel.component.mllp.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(componentConfiguration, 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) {
+ }
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
}
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MllpComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
+ }
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConfiguration.java
index 3cd81cb..9f588ce 100644
--- a/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mllp-starter/src/main/java/org/apache/camel/component/mllp/springboot/MllpComponentConfiguration.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.mllp.springboot;
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -24,8 +26,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mllp")
-public class MllpComponentConfiguration {
+public class MllpComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* Whether the component should resolve property placeholders on itself when
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java
index 3306a78..b1bc590 100644
--- a/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentAutoConfiguration.java
@@ -16,68 +16,114 @@
*/
package org.apache.camel.component.mongodb.gridfs.springboot;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mongodb.gridfs.GridFsComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(GridFsComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-public class GridFsComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ GridFsComponentConfiguration.class})
+public class GridFsComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(GridFsComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<GridFsComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private GridFsComponentConfiguration componentConfiguration;
+
+ public GridFsComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mongodb-gridfs");
+ }
+ }
@Lazy
@Bean(name = "mongodb-gridfs-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(GridFsComponent.class)
- public GridFsComponent configureGridFsComponent(CamelContext camelContext)
- throws Exception {
+ public GridFsComponent configureGridFsComponent() throws Exception {
GridFsComponent component = new GridFsComponent();
component.setCamelContext(camelContext);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mongodb-gridfs");
- if (isEnabled(conditionContext, "camel.component.mongodb-gridfs.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(componentConfiguration, 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) {
+ }
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
}
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<GridFsComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
+ }
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentConfiguration.java
index 5ae07dd..041767c 100644
--- a/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mongodb-gridfs-starter/src/main/java/org/apache/camel/component/mongodb/gridfs/springboot/GridFsComponentConfiguration.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.mongodb.gridfs.springboot;
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -23,8 +25,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mongodb-gridfs")
-public class GridFsComponentConfiguration {
+public class GridFsComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* Whether the component should resolve property placeholders on itself when
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java
index 6c0bace..cab569e 100644
--- a/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentAutoConfiguration.java
@@ -16,68 +16,114 @@
*/
package org.apache.camel.component.mongodb.springboot;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mongodb.MongoDbComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MongoDbComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-public class MongoDbComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MongoDbComponentConfiguration.class})
+public class MongoDbComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MongoDbComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MongoDbComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MongoDbComponentConfiguration componentConfiguration;
+
+ public MongoDbComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mongodb");
+ }
+ }
@Lazy
@Bean(name = "mongodb-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MongoDbComponent.class)
- public MongoDbComponent configureMongoDbComponent(CamelContext camelContext)
- throws Exception {
+ public MongoDbComponent configureMongoDbComponent() throws Exception {
MongoDbComponent component = new MongoDbComponent();
component.setCamelContext(camelContext);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mongodb");
- if (isEnabled(conditionContext, "camel.component.mongodb.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(componentConfiguration, 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) {
+ }
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
}
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MongoDbComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
+ }
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConfiguration.java
index 43ceeb5..0db099a 100644
--- a/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mongodb-starter/src/main/java/org/apache/camel/component/mongodb/springboot/MongoDbComponentConfiguration.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.mongodb.springboot;
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -23,8 +25,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mongodb")
-public class MongoDbComponentConfiguration {
+public class MongoDbComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* Whether the component should resolve property placeholders on itself when
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentAutoConfiguration.java
index 24c20db..442d8ef 100644
--- a/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentAutoConfiguration.java
@@ -16,68 +16,114 @@
*/
package org.apache.camel.component.mongodb3.springboot;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mongodb3.MongoDbComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MongoDbComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-public class MongoDbComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MongoDbComponentConfiguration.class})
+public class MongoDbComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MongoDbComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MongoDbComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MongoDbComponentConfiguration componentConfiguration;
+
+ public MongoDbComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mongodb3");
+ }
+ }
@Lazy
@Bean(name = "mongodb3-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MongoDbComponent.class)
- public MongoDbComponent configureMongoDbComponent(CamelContext camelContext)
- throws Exception {
+ public MongoDbComponent configureMongoDbComponent() throws Exception {
MongoDbComponent component = new MongoDbComponent();
component.setCamelContext(camelContext);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mongodb3");
- if (isEnabled(conditionContext, "camel.component.mongodb3.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(componentConfiguration, 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) {
+ }
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
}
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MongoDbComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
+ }
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentConfiguration.java
index c2569b6..2ec1b0f 100644
--- a/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mongodb3-starter/src/main/java/org/apache/camel/component/mongodb3/springboot/MongoDbComponentConfiguration.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.mongodb3.springboot;
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -23,8 +25,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mongodb3")
-public class MongoDbComponentConfiguration {
+public class MongoDbComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* Whether the component should resolve property placeholders on itself when
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentAutoConfiguration.java
index 8bfa98c..6bc65e3 100644
--- a/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentAutoConfiguration.java
@@ -17,49 +17,81 @@
package org.apache.camel.component.mqtt.springboot;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mqtt.MQTTComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MQTTComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-@EnableConfigurationProperties(MQTTComponentConfiguration.class)
-public class MQTTComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MQTTComponentConfiguration.class})
+public class MQTTComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MQTTComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MQTTComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MQTTComponentConfiguration componentConfiguration;
+
+ public MQTTComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mqtt");
+ }
+ }
@Lazy
@Bean(name = "mqtt-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MQTTComponent.class)
- public MQTTComponent configureMQTTComponent(CamelContext camelContext,
- MQTTComponentConfiguration configuration) throws Exception {
+ public MQTTComponent configureMQTTComponent() throws Exception {
MQTTComponent component = new MQTTComponent();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
+ IntrospectionSupport.getProperties(componentConfiguration, parameters,
+ null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
@@ -82,32 +114,16 @@ public class MQTTComponentAutoConfiguration {
}
IntrospectionSupport.setProperties(camelContext,
camelContext.getTypeConverter(), component, parameters);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mqtt");
- if (isEnabled(conditionContext, "camel.component.mqtt.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MQTTComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
- }
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentConfiguration.java
index a449f1b..285c4a8 100644
--- a/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mqtt-starter/src/main/java/org/apache/camel/component/mqtt/springboot/MQTTComponentConfiguration.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.mqtt.springboot;
import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -27,7 +28,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mqtt")
-public class MQTTComponentConfiguration {
+public class MQTTComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* The URI of the MQTT broker to connect too - this component also supports
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentAutoConfiguration.java
index ec86706..272b283 100644
--- a/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentAutoConfiguration.java
@@ -17,49 +17,81 @@
package org.apache.camel.component.validator.msv.springboot;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.validator.msv.MsvComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MsvComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-@EnableConfigurationProperties(MsvComponentConfiguration.class)
-public class MsvComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MsvComponentConfiguration.class})
+public class MsvComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MsvComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MsvComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MsvComponentConfiguration componentConfiguration;
+
+ public MsvComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.msv");
+ }
+ }
@Lazy
@Bean(name = "msv-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MsvComponent.class)
- public MsvComponent configureMsvComponent(CamelContext camelContext,
- MsvComponentConfiguration configuration) throws Exception {
+ public MsvComponent configureMsvComponent() throws Exception {
MsvComponent component = new MsvComponent();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
+ IntrospectionSupport.getProperties(componentConfiguration, parameters,
+ null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
@@ -82,32 +114,16 @@ public class MsvComponentAutoConfiguration {
}
IntrospectionSupport.setProperties(camelContext,
camelContext.getTypeConverter(), component, parameters);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.msv");
- if (isEnabled(conditionContext, "camel.component.msv.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MsvComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
- }
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentConfiguration.java
index 5a5165f..24a2a0d 100644
--- a/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-msv-starter/src/main/java/org/apache/camel/component/validator/msv/springboot/MsvComponentConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.validator.msv.springboot;
import javax.annotation.Generated;
import javax.xml.validation.SchemaFactory;
import org.apache.camel.component.validator.ValidatorResourceResolverFactory;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
@@ -29,7 +30,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.msv")
-public class MsvComponentConfiguration {
+public class MsvComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* To use the javax.xml.validation.SchemaFactory.
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java
index fb6ca8d..a1f513d 100644
--- a/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentAutoConfiguration.java
@@ -17,50 +17,81 @@
package org.apache.camel.component.mustache.springboot;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mustache.MustacheComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MustacheComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-@EnableConfigurationProperties(MustacheComponentConfiguration.class)
-public class MustacheComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MustacheComponentConfiguration.class})
+public class MustacheComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MustacheComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MustacheComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MustacheComponentConfiguration componentConfiguration;
+
+ public MustacheComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mustache");
+ }
+ }
@Lazy
@Bean(name = "mustache-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MustacheComponent.class)
- public MustacheComponent configureMustacheComponent(
- CamelContext camelContext,
- MustacheComponentConfiguration configuration) throws Exception {
+ public MustacheComponent configureMustacheComponent() throws Exception {
MustacheComponent component = new MustacheComponent();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
+ IntrospectionSupport.getProperties(componentConfiguration, parameters,
+ null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
@@ -83,32 +114,16 @@ public class MustacheComponentAutoConfiguration {
}
IntrospectionSupport.setProperties(camelContext,
camelContext.getTypeConverter(), component, parameters);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mustache");
- if (isEnabled(conditionContext, "camel.component.mustache.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MustacheComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
- }
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
index 32cf515..7de17ba 100644
--- a/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mustache-starter/src/main/java/org/apache/camel/component/mustache/springboot/MustacheComponentConfiguration.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.mustache.springboot;
import javax.annotation.Generated;
import com.github.mustachejava.MustacheFactory;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
@@ -28,7 +29,9 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mustache")
-public class MustacheComponentConfiguration {
+public class MustacheComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* To use a custom MustacheFactory
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java
index bfaef25..c437e3d 100644
--- a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentAutoConfiguration.java
@@ -16,68 +16,114 @@
*/
package org.apache.camel.component.mvel.springboot;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mvel.MvelComponent;
+import org.apache.camel.spi.ComponentCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.ComponentConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MvelComponentAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-public class MvelComponentAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({ComponentConfigurationProperties.class,
+ MvelComponentConfiguration.class})
+public class MvelComponentAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MvelComponentAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<ComponentCustomizer<MvelComponent>> customizers;
+ @Autowired
+ private ComponentConfigurationProperties globalConfiguration;
+ @Autowired
+ private MvelComponentConfiguration componentConfiguration;
+
+ public MvelComponentAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mvel");
+ }
+ }
@Lazy
@Bean(name = "mvel-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MvelComponent.class)
- public MvelComponent configureMvelComponent(CamelContext camelContext)
- throws Exception {
+ public MvelComponent configureMvelComponent() throws Exception {
MvelComponent component = new MvelComponent();
component.setCamelContext(camelContext);
- return component;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.component.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.component.mvel");
- if (isEnabled(conditionContext, "camel.component.mvel.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ Map<String, Object> parameters = new HashMap<>();
+ IntrospectionSupport.getProperties(componentConfiguration, 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) {
+ }
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
}
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
+ IntrospectionSupport.setProperties(camelContext,
+ camelContext.getTypeConverter(), component, parameters);
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && componentConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (ComponentCustomizer<MvelComponent> configurer : customizers) {
+ LOGGER.debug("Configure component {}, with configurer {}",
+ component, configurer);
+ configurer.customize(component);
+ }
}
+ return component;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
index 93f1409..073512f 100644
--- a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/component/mvel/springboot/MvelComponentConfiguration.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.mvel.springboot;
+import javax.annotation.Generated;
+import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -23,8 +25,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
+@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.mvel")
-public class MvelComponentConfiguration {
+public class MvelComponentConfiguration
+ extends
+ ComponentConfigurationPropertiesCommon {
/**
* Whether the component should resolve property placeholders on itself when
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java
index 0072cfe..f1165ef 100644
--- a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageAutoConfiguration.java
@@ -17,45 +17,78 @@
package org.apache.camel.language.mvel.springboot;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.language.mvel.MvelLanguage;
+import org.apache.camel.spi.LanguageCustomizer;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.LanguageConfigurationProperties;
+import org.apache.camel.spring.boot.util.GroupCondition;
import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionMessage;
-import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
+import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
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;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
-import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@Configuration
-@ConditionalOnBean(type = "org.apache.camel.spring.boot.CamelAutoConfiguration")
@Conditional(MvelLanguageAutoConfiguration.Condition.class)
-@AutoConfigureAfter(name = "org.apache.camel.spring.boot.CamelAutoConfiguration")
-@EnableConfigurationProperties(MvelLanguageConfiguration.class)
-public class MvelLanguageAutoConfiguration {
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+@EnableConfigurationProperties({LanguageConfigurationProperties.class,
+ MvelLanguageConfiguration.class})
+public class MvelLanguageAutoConfiguration extends AllNestedConditions {
+
+ private static final Logger LOGGER = LoggerFactory
+ .getLogger(MvelLanguageAutoConfiguration.class);
+ @Autowired
+ private CamelContext camelContext;
+ @Autowired(required = false)
+ private List<LanguageCustomizer<MvelLanguage>> customizers;
+ @Autowired
+ private LanguageConfigurationProperties globalConfiguration;
+ @Autowired
+ private MvelLanguageConfiguration languageConfiguration;
+
+ public MvelLanguageAutoConfiguration() {
+ super(ConfigurationPhase.REGISTER_BEAN);
+ }
+
+ @ConditionalOnBean(CamelContext.class)
+ public static class OnCamelContext {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class OnCamelAutoConfiguration {
+ }
+
+ @ConditionalOnBean(CamelAutoConfiguration.class)
+ public static class Condition extends GroupCondition {
+ public Condition() {
+ super("camel.component", "camel.component.mvel");
+ }
+ }
@Bean(name = "mvel-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MvelLanguage.class)
- public MvelLanguage configureMvelLanguage(CamelContext camelContext,
- MvelLanguageConfiguration configuration) throws Exception {
+ public MvelLanguage configureMvelLanguage() throws Exception {
MvelLanguage language = new MvelLanguage();
if (CamelContextAware.class.isAssignableFrom(MvelLanguage.class)) {
CamelContextAware contextAware = CamelContextAware.class
@@ -65,36 +98,20 @@ public class MvelLanguageAutoConfiguration {
}
}
Map<String, Object> parameters = new HashMap<>();
- IntrospectionSupport.getProperties(configuration, parameters, null,
- false);
+ IntrospectionSupport.getProperties(languageConfiguration, parameters,
+ null, false);
IntrospectionSupport.setProperties(camelContext,
camelContext.getTypeConverter(), language, parameters);
- return language;
- }
-
- @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
- public static class Condition extends SpringBootCondition {
- @Override
- public ConditionOutcome getMatchOutcome(
- ConditionContext conditionContext,
- AnnotatedTypeMetadata annotatedTypeMetadata) {
- boolean groupEnabled = isEnabled(conditionContext,
- "camel.language.", true);
- ConditionMessage.Builder message = ConditionMessage
- .forCondition("camel.language.mvel");
- if (isEnabled(conditionContext, "camel.language.mvel.",
- groupEnabled)) {
- return ConditionOutcome.match(message.because("enabled"));
+ boolean useConfigurers = globalConfiguration.getConfigurer()
+ .isEnabled()
+ && languageConfiguration.getConfigurer().isEnabled();
+ if (useConfigurers && ObjectHelper.isNotEmpty(customizers)) {
+ for (LanguageCustomizer<MvelLanguage> configurer : customizers) {
+ LOGGER.debug("Configure language {}, with configurer {}",
+ language, configurer);
+ configurer.customize(language);
}
- return ConditionOutcome.noMatch(message.because("not enabled"));
- }
-
- private boolean isEnabled(
- org.springframework.context.annotation.ConditionContext context,
- java.lang.String prefix, boolean defaultValue) {
- RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
- context.getEnvironment(), prefix);
- return resolver.getProperty("enabled", Boolean.class, defaultValue);
}
+ return language;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/3eeb97ac/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageConfiguration.java
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageConfiguration.java b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageConfiguration.java
index 9eeb3e7..c9cddbf 100644
--- a/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-mvel-starter/src/main/java/org/apache/camel/language/mvel/springboot/MvelLanguageConfiguration.java
@@ -17,6 +17,7 @@
package org.apache.camel.language.mvel.springboot;
import javax.annotation.Generated;
+import org.apache.camel.spring.boot.LanguageConfigurationPropertiesCommon;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@@ -26,7 +27,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
*/
@Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.language.mvel")
-public class MvelLanguageConfiguration {
+public class MvelLanguageConfiguration
+ extends
+ LanguageConfigurationPropertiesCommon {
/**
* Whether to trim the value to remove leading and trailing whitespaces and