camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-10042: camel-spring-boot - Add default values to auto configuration
Date Sat, 11 Jun 2016 07:59:40 GMT
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 <davsclaus@apache.org>
Authored: Sat Jun 11 09:57:53 2016 +0200
Committer: Claus Ibsen <davsclaus@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);
 


Mime
View raw message