You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/06/11 07:59:39 UTC

[1/2] camel git commit: CAMEL-10042: camel-spring-boot - Add default values to auto configuration

Repository: camel
Updated Branches:
  refs/heads/master 2312fdc33 -> 92f1eda2c


CAMEL-10042: camel-spring-boot - Add default values to auto configuration


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4254d431
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4254d431
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4254d431

Branch: refs/heads/master
Commit: 4254d4315b032f1f1897822ee33c1d05a233d4d1
Parents: 2312fdc
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jun 11 09:21:21 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jun 11 09:21:21 2016 +0200

----------------------------------------------------------------------
 .../springboot/AMQPComponentConfiguration.java  |  4 ++++
 .../DisruptorComponentConfiguration.java        |  4 ++++
 .../DisruptorVmComponentConfiguration.java      |  4 ++++
 .../springboot/GsonDataFormatConfiguration.java |  3 ++-
 .../JacksonDataFormatConfiguration.java         |  3 ++-
 .../springboot/JmsComponentConfiguration.java   |  4 ++++
 .../SnakeYAMLDataFormatConfiguration.java       |  3 ++-
 .../springboot/SshComponentConfiguration.java   |  4 ++++
 .../springboot/JsonDataFormatConfiguration.java |  3 ++-
 .../SpringBootAutoConfigurationMojo.java        | 20 ++++++++++++++++++++
 .../packaging/model/ComponentOptionModel.java   |  9 +++++++++
 .../packaging/model/DataFormatOptionModel.java  |  9 +++++++++
 .../packaging/model/EndpointOptionModel.java    |  9 +++++++++
 13 files changed, 75 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
index c1997e2..62e758e 100644
--- a/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
+++ b/components/camel-amqp/src/main/java/org/apache/camel/component/amqp/springboot/AMQPComponentConfiguration.java
@@ -27,6 +27,7 @@ import org.apache.camel.component.jms.QueueBrowseStrategy;
 import org.apache.camel.component.jms.ReplyToType;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.jms.core.JmsOperations;
@@ -847,10 +848,13 @@ public class AMQPComponentConfiguration {
         this.recoveryInterval = recoveryInterval;
     }
 
+    @Deprecated
+    @DeprecatedConfigurationProperty
     public Boolean getSubscriptionDurable() {
         return subscriptionDurable;
     }
 
+    @Deprecated
     public void setSubscriptionDurable(Boolean subscriptionDurable) {
         this.subscriptionDurable = subscriptionDurable;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentConfiguration.java b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentConfiguration.java
index 077c3b7..61056f2 100644
--- a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentConfiguration.java
+++ b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/springboot/DisruptorComponentConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.disruptor.springboot;
 import org.apache.camel.component.disruptor.DisruptorProducerType;
 import org.apache.camel.component.disruptor.DisruptorWaitStrategy;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 
 /**
  * The disruptor component provides asynchronous SEDA behavior using LMAX
@@ -102,10 +103,13 @@ public class DisruptorComponentConfiguration {
         this.defaultBlockWhenFull = defaultBlockWhenFull;
     }
 
+    @Deprecated
+    @DeprecatedConfigurationProperty
     public int getQueueSize() {
         return queueSize;
     }
 
+    @Deprecated
     public void setQueueSize(int queueSize) {
         this.queueSize = queueSize;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentConfiguration.java b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentConfiguration.java
index c872df3..aca3020 100644
--- a/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentConfiguration.java
+++ b/components/camel-disruptor/src/main/java/org/apache/camel/component/disruptor/vm/springboot/DisruptorVmComponentConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.disruptor.vm.springboot;
 import org.apache.camel.component.disruptor.DisruptorProducerType;
 import org.apache.camel.component.disruptor.DisruptorWaitStrategy;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 
 /**
  * The disruptor component provides asynchronous SEDA behavior using LMAX
@@ -102,10 +103,13 @@ public class DisruptorVmComponentConfiguration {
         this.defaultBlockWhenFull = defaultBlockWhenFull;
     }
 
+    @Deprecated
+    @DeprecatedConfigurationProperty
     public int getQueueSize() {
         return queueSize;
     }
 
+    @Deprecated
     public void setQueueSize(int queueSize) {
         this.queueSize = queueSize;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java b/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
index 6e68b76..01218f4 100644
--- a/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
+++ b/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.gson.springboot;
 
+import org.apache.camel.component.gson.GsonDataFormat;
 import org.apache.camel.model.dataformat.JsonLibrary;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -39,7 +40,7 @@ public class GsonDataFormatConfiguration {
     /**
      * Which json library to use such. Is by default xstream
      */
-    private JsonLibrary library;
+    private JsonLibrary library = JsonLibrary.XStream;
     /**
      * Class name of the java type to use when unarmshalling
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
index c2f9ba2..4abf089 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.jackson.springboot;
 
+import org.apache.camel.component.jackson.JacksonDataFormat;
 import org.apache.camel.model.dataformat.JsonLibrary;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -39,7 +40,7 @@ public class JacksonDataFormatConfiguration {
     /**
      * Which json library to use such. Is by default xstream
      */
-    private JsonLibrary library;
+    private JsonLibrary library = JsonLibrary.XStream;
     /**
      * Class name of the java type to use when unarmshalling
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-jms/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
index 8862b42..f6ffeb5 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/springboot/JmsComponentConfiguration.java
@@ -27,6 +27,7 @@ import org.apache.camel.component.jms.QueueBrowseStrategy;
 import org.apache.camel.component.jms.ReplyToType;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.jms.core.JmsOperations;
@@ -848,10 +849,13 @@ public class JmsComponentConfiguration {
         this.recoveryInterval = recoveryInterval;
     }
 
+    @Deprecated
+    @DeprecatedConfigurationProperty
     public Boolean getSubscriptionDurable() {
         return subscriptionDurable;
     }
 
+    @Deprecated
     public void setSubscriptionDurable(Boolean subscriptionDurable) {
         this.subscriptionDurable = subscriptionDurable;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
index 613f989..5032391 100644
--- a/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
+++ b/components/camel-snakeyaml/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.snakeyaml.springboot;
 
+import org.apache.camel.component.snakeyaml.SnakeYAMLDataFormat;
 import org.apache.camel.model.dataformat.YAMLLibrary;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -30,7 +31,7 @@ public class SnakeYAMLDataFormatConfiguration {
     /**
      * Which yaml library to use such. Is by default SnakeYAML
      */
-    private YAMLLibrary library;
+    private YAMLLibrary library = YAMLLibrary.SnakeYAML;
     /**
      * Class name of the java type to use when unarmshalling
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java
index 36fca04..b50dfc4 100644
--- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java
+++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/springboot/SshComponentConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.ssh.springboot;
 import org.apache.camel.component.ssh.SshConfiguration;
 import org.apache.sshd.common.KeyPairProvider;
 import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 
 /**
  * The ssh component enables access to SSH servers such that you can send an SSH
@@ -157,10 +158,13 @@ public class SshComponentConfiguration {
         this.timeout = timeout;
     }
 
+    @Deprecated
+    @DeprecatedConfigurationProperty
     public String getCertFilename() {
         return certFilename;
     }
 
+    @Deprecated
     public void setCertFilename(String certFilename) {
         this.certFilename = certFilename;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatConfiguration.java b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatConfiguration.java
index ac5cb6c..143b35b 100644
--- a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatConfiguration.java
+++ b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatConfiguration.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.dataformat.xstream.springboot;
 
+import org.apache.camel.dataformat.xstream.JsonDataFormat;
 import org.apache.camel.model.dataformat.JsonLibrary;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
@@ -39,7 +40,7 @@ public class JsonDataFormatConfiguration {
     /**
      * Which json library to use such. Is by default xstream
      */
-    private JsonLibrary library;
+    private JsonLibrary library = JsonLibrary.XStream;
     /**
      * Class name of the java type to use when unarmshalling
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
index e997e18..f758230 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
@@ -48,6 +48,7 @@ import org.jboss.forge.roaster.model.util.Strings;
 import org.sonatype.plexus.build.incremental.BuildContext;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -211,6 +212,10 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
             PropertySource<JavaClassSource> prop = javaClass.addProperty(type, option.getName());
             if ("true".equals(option.getDeprecated())) {
                 prop.getField().addAnnotation(Deprecated.class);
+                prop.getAccessor().addAnnotation(Deprecated.class);
+                prop.getMutator().addAnnotation(Deprecated.class);
+                // DeprecatedConfigurationProperty must be on getter when deprecated
+                prop.getAccessor().addAnnotation(DeprecatedConfigurationProperty.class);
             }
             if (!Strings.isBlank(option.getDescription())) {
                 prop.getField().getJavaDoc().setFullText(option.getDescription());
@@ -220,6 +225,10 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
                     prop.getField().setStringInitializer(option.getDefaultValue());
                 } else if ("integer".equals(option.getType()) || "boolean".equals(option.getType())) {
                     prop.getField().setLiteralInitializer(option.getDefaultValue());
+                } else if (!Strings.isBlank(option.getEnumValues())) {
+                    String enumShortName = type.substring(type.lastIndexOf(".") + 1);
+                    prop.getField().setLiteralInitializer(enumShortName + "." + option.getDefaultValue());
+                    javaClass.addImport(model.getJavaType());
                 }
             }
         }
@@ -286,6 +295,10 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
             PropertySource<JavaClassSource> prop = javaClass.addProperty(type, option.getName());
             if ("true".equals(option.getDeprecated())) {
                 prop.getField().addAnnotation(Deprecated.class);
+                prop.getAccessor().addAnnotation(Deprecated.class);
+                prop.getMutator().addAnnotation(Deprecated.class);
+                // DeprecatedConfigurationProperty must be on getter when deprecated
+                prop.getAccessor().addAnnotation(DeprecatedConfigurationProperty.class);
             }
             if (!Strings.isBlank(option.getDescription())) {
                 prop.getField().getJavaDoc().setFullText(option.getDescription());
@@ -295,6 +308,10 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
                     prop.getField().setStringInitializer(option.getDefaultValue());
                 } else if ("integer".equals(option.getType()) || "boolean".equals(option.getType())) {
                     prop.getField().setLiteralInitializer(option.getDefaultValue());
+                } else if (!Strings.isBlank(option.getEnumValues())) {
+                    String enumShortName = type.substring(type.lastIndexOf(".") + 1);
+                    prop.getField().setLiteralInitializer(enumShortName + "." + option.getDefaultValue());
+                    javaClass.addImport(model.getJavaType());
                 }
             }
         }
@@ -759,6 +776,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
             option.setDeprecated(getSafeValue("deprecated", row));
             option.setDescription(getSafeValue("description", row));
             option.setDefaultValue(getSafeValue("defaultValue", row));
+            option.setEnumValues(getSafeValue("enum", row));
             component.addComponentOption(option);
         }
 
@@ -777,6 +795,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
             option.setDeprecated(getSafeValue("deprecated", row));
             option.setDefaultValue(getSafeValue("defaultValue", row));
             option.setDescription(getSafeValue("description", row));
+            option.setEnumValues(getSafeValue("enum", row));
             component.addEndpointOption(option);
         }
 
@@ -808,6 +827,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
             option.setDeprecated(getSafeValue("deprecated", row));
             option.setDescription(getSafeValue("description", row));
             option.setDefaultValue(getSafeValue("defaultValue", row));
+            option.setEnumValues(getSafeValue("enum", row));
             dataFormat.addDataFormatOption(option);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
index dde468e..435685f 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/ComponentOptionModel.java
@@ -25,6 +25,7 @@ public class ComponentOptionModel {
     private String deprecated;
     private String description;
     private String defaultValue;
+    private String enumValues;
 
     public String getName() {
         return name;
@@ -82,6 +83,14 @@ public class ComponentOptionModel {
         this.defaultValue = defaultValue;
     }
 
+    public String getEnumValues() {
+        return enumValues;
+    }
+
+    public void setEnumValues(String enumValues) {
+        this.enumValues = enumValues;
+    }
+
     public String getShortJavaType() {
         if (javaType.startsWith("java.util.Map")) {
             return "Map";

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/DataFormatOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/DataFormatOptionModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/DataFormatOptionModel.java
index 0c38e06..a194d06 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/DataFormatOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/DataFormatOptionModel.java
@@ -25,6 +25,7 @@ public class DataFormatOptionModel {
     private String deprecated;
     private String description;
     private String defaultValue;
+    private String enumValues;
 
     public String getName() {
         return name;
@@ -82,6 +83,14 @@ public class DataFormatOptionModel {
         this.defaultValue = defaultValue;
     }
 
+    public String getEnumValues() {
+        return enumValues;
+    }
+
+    public void setEnumValues(String enumValues) {
+        this.enumValues = enumValues;
+    }
+
     public String getShortJavaType() {
         if (javaType.startsWith("java.util.Map")) {
             return "Map";

http://git-wip-us.apache.org/repos/asf/camel/blob/4254d431/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
index 01ab383..5013795 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/EndpointOptionModel.java
@@ -30,6 +30,7 @@ public class EndpointOptionModel {
     private String deprecated;
     private String defaultValue;
     private String description;
+    private String enumValues;
 
     public String getName() {
         return name;
@@ -127,6 +128,14 @@ public class EndpointOptionModel {
         this.description = description;
     }
 
+    public String getEnumValues() {
+        return enumValues;
+    }
+
+    public void setEnumValues(String enumValues) {
+        this.enumValues = enumValues;
+    }
+
     public String getShortJavaType() {
         if (javaType.startsWith("java.util.Map")) {
             return "Map";


[2/2] camel git commit: CAMEL-10042: camel-spring-boot - Add default values to auto configuration

Posted by da...@apache.org.
CAMEL-10042: camel-spring-boot - Add default values to auto configuration


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/92f1eda2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/92f1eda2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/92f1eda2

Branch: refs/heads/master
Commit: 92f1eda2cc565ee7d1744487c72142fb72056399
Parents: 4254d43
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jun 11 09:57:53 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jun 11 09:57:53 2016 +0200

----------------------------------------------------------------------
 .../springboot/GsonDataFormatConfiguration.java  |  2 +-
 .../JacksonDataFormatConfiguration.java          |  2 +-
 .../SpringBootAutoConfigurationMojo.java         | 19 +++++++++++++++++--
 3 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/92f1eda2/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java b/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
index 01218f4..6954605 100644
--- a/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
+++ b/components/camel-gson/src/main/java/org/apache/camel/component/gson/springboot/GsonDataFormatConfiguration.java
@@ -40,7 +40,7 @@ public class GsonDataFormatConfiguration {
     /**
      * Which json library to use such. Is by default xstream
      */
-    private JsonLibrary library = JsonLibrary.XStream;
+    private JsonLibrary library = JsonLibrary.Gson;
     /**
      * Class name of the java type to use when unarmshalling
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/92f1eda2/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
index 4abf089..0aa5b48 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/springboot/JacksonDataFormatConfiguration.java
@@ -40,7 +40,7 @@ public class JacksonDataFormatConfiguration {
     /**
      * Which json library to use such. Is by default xstream
      */
-    private JsonLibrary library = JsonLibrary.XStream;
+    private JsonLibrary library = JsonLibrary.Jackson;
     /**
      * Class name of the java type to use when unarmshalling
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/92f1eda2/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
index f758230..42bce15 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
@@ -227,7 +227,8 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
                     prop.getField().setLiteralInitializer(option.getDefaultValue());
                 } else if (!Strings.isBlank(option.getEnumValues())) {
                     String enumShortName = type.substring(type.lastIndexOf(".") + 1);
-                    prop.getField().setLiteralInitializer(enumShortName + "." + option.getDefaultValue());
+                    String value = getDefaultValue(model.getScheme(), option.getName(), option.getDefaultValue());
+                    prop.getField().setLiteralInitializer(enumShortName + "." + value);
                     javaClass.addImport(model.getJavaType());
                 }
             }
@@ -310,7 +311,8 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
                     prop.getField().setLiteralInitializer(option.getDefaultValue());
                 } else if (!Strings.isBlank(option.getEnumValues())) {
                     String enumShortName = type.substring(type.lastIndexOf(".") + 1);
-                    prop.getField().setLiteralInitializer(enumShortName + "." + option.getDefaultValue());
+                    String value = getDefaultValue(model.getName(), option.getName(), option.getDefaultValue());
+                    prop.getField().setLiteralInitializer(enumShortName + "." + value);
                     javaClass.addImport(model.getJavaType());
                 }
             }
@@ -345,6 +347,19 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         }
     }
 
+    private String getDefaultValue(String modelName, String optionName, String defaultValue) {
+        // special for some data formats
+        if ("json-jackson".equals(modelName) && "library".equals(optionName)) {
+            return "Jackson";
+        } else if ("json-xstream".equals(modelName) && "library".equals(optionName)) {
+            return "XStream";
+        } else if ("json-gson".equals(modelName) && "library".equals(optionName)) {
+            return "Gson";
+        }
+
+        return defaultValue;
+    }
+
     private void createComponentAutoConfigurationSource(String packageName, ComponentModel model) throws MojoFailureException {
         final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);