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/10 09:55:28 UTC

[07/11] camel git commit: CAMEL-10041: Generate spring-boot auto configuration for all Camel data formats that has options that can be configured.

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java
index 0967519..9b3ac59 100644
--- a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java
+++ b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/JsonDataFormatAutoConfiguration.java
@@ -45,7 +45,8 @@ public class JsonDataFormatAutoConfiguration {
             ((CamelContextAware) dataformat).setCamelContext(camelContext);
         }
         Map<String, Object> parameters = new HashMap<>();
-        IntrospectionSupport.getProperties(configuration, parameters, null);
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
         IntrospectionSupport.setProperties(camelContext,
                 camelContext.getTypeConverter(), dataformat, parameters);
         return dataformat;

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/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 db8d83b..3107246 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
@@ -121,10 +121,6 @@ public class JsonDataFormatConfiguration {
      * org.apache.camel.xstream.permissions.
      */
     private String permissions;
-    /**
-     * Sets the value of the id property.
-     */
-    private String id;
 
     public String getObjectMapper() {
         return objectMapper;
@@ -245,12 +241,4 @@ public class JsonDataFormatConfiguration {
     public void setPermissions(String permissions) {
         this.permissions = permissions;
     }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java
index ee96c63..065a531 100644
--- a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java
+++ b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatAutoConfiguration.java
@@ -46,7 +46,8 @@ public class XStreamDataFormatAutoConfiguration {
             ((CamelContextAware) dataformat).setCamelContext(camelContext);
         }
         Map<String, Object> parameters = new HashMap<>();
-        IntrospectionSupport.getProperties(configuration, parameters, null);
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
         IntrospectionSupport.setProperties(camelContext,
                 camelContext.getTypeConverter(), dataformat, parameters);
         return dataformat;

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatConfiguration.java b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatConfiguration.java
index cf0b0ca..a8236e0 100644
--- a/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatConfiguration.java
+++ b/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/springboot/XStreamDataFormatConfiguration.java
@@ -84,10 +84,6 @@ public class XStreamDataFormatConfiguration {
      * tag.
      */
     private Map<java.lang.String, java.lang.String[]> implicitCollections;
-    /**
-     * Sets the value of the id property.
-     */
-    private String id;
 
     public String getPermissions() {
         return permissions;
@@ -160,12 +156,4 @@ public class XStreamDataFormatConfiguration {
     public void setImplicitCollections(Map<String, String[]> implicitCollections) {
         this.implicitCollections = implicitCollections;
     }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentAutoConfiguration.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentAutoConfiguration.java
index 4d38549..9dbd9839 100644
--- a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentAutoConfiguration.java
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/springboot/YammerComponentAutoConfiguration.java
@@ -42,7 +42,8 @@ public class YammerComponentAutoConfiguration {
         YammerComponent component = new YammerComponent();
         component.setCamelContext(camelContext);
         Map<String, Object> parameters = new HashMap<>();
-        IntrospectionSupport.getProperties(configuration, parameters, null);
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
         IntrospectionSupport.setProperties(camelContext,
                 camelContext.getTypeConverter(), component, parameters);
         return component;

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java
index acfd2fb..5ebea8f 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatAutoConfiguration.java
@@ -46,7 +46,8 @@ public class ZipFileDataFormatAutoConfiguration {
             ((CamelContextAware) dataformat).setCamelContext(camelContext);
         }
         Map<String, Object> parameters = new HashMap<>();
-        IntrospectionSupport.getProperties(configuration, parameters, null);
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
         IntrospectionSupport.setProperties(camelContext,
                 camelContext.getTypeConverter(), dataformat, parameters);
         return dataformat;

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
index b41176d..b12703f 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/springboot/ZipFileDataFormatConfiguration.java
@@ -32,10 +32,6 @@ public class ZipFileDataFormatConfiguration {
      * in a streaming mode.
      */
     private Boolean usingIterator;
-    /**
-     * Sets the value of the id property.
-     */
-    private String id;
 
     public Boolean getUsingIterator() {
         return usingIterator;
@@ -44,12 +40,4 @@ public class ZipFileDataFormatConfiguration {
     public void setUsingIterator(Boolean usingIterator) {
         this.usingIterator = usingIterator;
     }
-
-    public String getId() {
-        return id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java
index 7bc017e..d734f3b 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/springboot/ZooKeeperComponentAutoConfiguration.java
@@ -43,7 +43,8 @@ public class ZooKeeperComponentAutoConfiguration {
         ZooKeeperComponent component = new ZooKeeperComponent();
         component.setCamelContext(camelContext);
         Map<String, Object> parameters = new HashMap<>();
-        IntrospectionSupport.getProperties(configuration, parameters, null);
+        IntrospectionSupport.getProperties(configuration, parameters, null,
+                false);
         IntrospectionSupport.setProperties(camelContext,
                 camelContext.getTypeConverter(), component, parameters);
         return component;

http://git-wip-us.apache.org/repos/asf/camel/blob/3759e3c1/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 bd5da91..668a407 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
@@ -139,6 +139,39 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         }
     }
 
+    private void executeDataFormat() throws MojoExecutionException, MojoFailureException {
+        // find the data format names
+        List<String> dataFormatNames = findDataFormatNames();
+
+        final Set<File> jsonFiles = new TreeSet<File>();
+        // we can reuse the component model filter
+        PackageHelper.findJsonFiles(buildDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
+
+        // create auto configuration for the components
+        if (!dataFormatNames.isEmpty()) {
+            getLog().debug("Found " + dataFormatNames.size() + " dataformats");
+            for (String dataFormatName : dataFormatNames) {
+                String json = loadDataFormaatJson(jsonFiles, dataFormatName);
+                if (json != null) {
+                    DataFormatModel model = generateDataFormatModel(dataFormatName, json);
+
+                    // only create source code if the component has options that can be used in auto configuration
+                    if (!model.getDataFormatOptions().isEmpty()) {
+
+                        // use springboot as sub package name so the code is not in normal
+                        // package so the Spring Boot JARs can be optional at runtime
+                        int pos = model.getJavaType().lastIndexOf(".");
+                        String pkg = model.getJavaType().substring(0, pos) + ".springboot";
+
+                        createDataFormatConfigurationSource(pkg, model);
+                        createDataFormatAutoConfigurationSource(pkg, model);
+                        createDataFormatSpringFactorySource(pkg, model);
+                    }
+                }
+            }
+        }
+    }
+
     private void createComponentConfigurationSource(String packageName, ComponentModel model) throws MojoFailureException {
         final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
 
@@ -216,6 +249,10 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix", prefix);
 
         for (DataFormatOptionModel option : model.getDataFormatOptions()) {
+            // skip option with name id in data format as we do not need that
+            if ("id".equals(option.getName())) {
+                continue;
+            }
             // remove <?> as generic type as Roaster (Eclipse JDT) cannot use that
             String type = option.getJavaType();
             type = type.replaceAll("\\<\\?\\>", "");
@@ -400,39 +437,6 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         }
     }
 
-    private void executeDataFormat() throws MojoExecutionException, MojoFailureException {
-        // find the data format names
-        List<String> dataFormatNames = findDataFormatNames();
-
-        final Set<File> jsonFiles = new TreeSet<File>();
-        // we can reuse the component model filter
-        PackageHelper.findJsonFiles(buildDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
-
-        // create auto configuration for the components
-        if (!dataFormatNames.isEmpty()) {
-            getLog().debug("Found " + dataFormatNames.size() + " dataformats");
-            for (String dataFormatName : dataFormatNames) {
-                String json = loadDataFormaatJson(jsonFiles, dataFormatName);
-                if (json != null) {
-                    DataFormatModel model = generateDataFormatModel(dataFormatName, json);
-
-                    // only create source code if the component has options that can be used in auto configuration
-                    if (!model.getDataFormatOptions().isEmpty()) {
-
-                        // use springboot as sub package name so the code is not in normal
-                        // package so the Spring Boot JARs can be optional at runtime
-                        int pos = model.getJavaType().lastIndexOf(".");
-                        String pkg = model.getJavaType().substring(0, pos) + ".springboot";
-
-                        createDataFormatConfigurationSource(pkg, model);
-                        createDataFormatAutoConfigurationSource(pkg, model);
-                        createDataFormatSpringFactorySource(pkg, model);
-                    }
-                }
-            }
-        }
-    }
-
     private void createComponentSpringFactorySource(String packageName, ComponentModel model) throws MojoFailureException {
         StringBuilder sb = new StringBuilder();
         sb.append("org.springframework.boot.autoconfigure.EnableAutoConfiguration=\\\n");
@@ -583,7 +587,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         sb.append("component.setCamelContext(camelContext);\n");
         sb.append("\n");
         sb.append("Map<String, Object> parameters = new HashMap<>();\n");
-        sb.append("IntrospectionSupport.getProperties(configuration, parameters, null);\n");
+        sb.append("IntrospectionSupport.getProperties(configuration, parameters, null, false);\n");
         sb.append("\n");
         sb.append("IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);\n");
         sb.append("\n");
@@ -599,7 +603,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         sb.append("}\n");
         sb.append("\n");
         sb.append("Map<String, Object> parameters = new HashMap<>();\n");
-        sb.append("IntrospectionSupport.getProperties(configuration, parameters, null);\n");
+        sb.append("IntrospectionSupport.getProperties(configuration, parameters, null, false);\n");
         sb.append("\n");
         sb.append("IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);\n");
         sb.append("\n");