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 2019/06/21 08:52:15 UTC

[camel] branch master updated (08a0ed5 -> 8d9f781)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 08a0ed5  nav.adoc fixed inside user-manual
     new 7657f6d  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
     new 4e52087  Regen
     new 0b13d7c  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
     new 4f1bdac  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
     new c316a27  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
     new 6f01e56  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
     new a6d02e0  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
     new 8d9f781  CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/docs/camel-main-maven-plugin.adoc     | 100 ++---
 .../org/apache/camel/maven/AbstractMainMojo.java   |  32 +-
 .../java/org/apache/camel/maven/AutowireMojo.java  | 296 --------------
 .../java/org/apache/camel/maven/GenerateMojo.java  | 443 +++++++++++++++++++++
 .../apache/camel/maven/SpringBootToolingMojo.java  | 171 --------
 .../org/apache/camel/maven/model/AutowireData.java |  30 +-
 .../apache/camel/maven/model/SpringBootData.java   |  29 +-
 .../src/main/docs/cm-sms-component.adoc            |   6 +-
 examples/camel-example-main-artemis/pom.xml        |  13 +-
 .../META-INF/spring-configuration-metadata.json    | 210 ++++++++++
 10 files changed, 766 insertions(+), 564 deletions(-)
 delete mode 100644 catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
 create mode 100644 catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
 delete mode 100644 catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
 copy core/camel-core/src/test/java/org/apache/camel/processor/resequencer/TestObject.java => catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/AutowireData.java (67%)
 copy tooling/maven/camel-main-parser/src/main/java/org/apache/camel/main/parser/ConfigurationModel.java => catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/SpringBootData.java (82%)


[camel] 04/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4f1bdac7f3a758859175749dd2b2c4fc97a5c44f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 09:21:18 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../org/apache/camel/maven/AbstractMainMojo.java   |  33 ++++++-
 .../java/org/apache/camel/maven/AutowireMojo.java  | 108 ++++++++-------------
 .../apache/camel/maven/SpringBootToolingMojo.java  |  49 +++-------
 3 files changed, 89 insertions(+), 101 deletions(-)

diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java
index 7e14948..44a8891 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java
@@ -28,13 +28,18 @@ import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.function.Function;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.catalog.JSonSchemaHelper;
 import org.apache.camel.catalog.maven.MavenVersionManager;
+import org.apache.camel.maven.model.AutowireData;
+import org.apache.camel.maven.model.SpringBootData;
 import org.apache.camel.util.IOHelper;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -91,8 +96,12 @@ public abstract class AbstractMainMojo extends AbstractExecMojo {
     @Parameter(property = "project.remoteArtifactRepositories")
     private List remoteRepositories;
 
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
+    @FunctionalInterface
+    protected interface ComponentCallback {
+        void onOption(String componentName, String name, String type, String javaType, String description, String defaultValue);
+    }
+
+    protected void doExecute(ComponentCallback callback) throws MojoExecutionException, MojoFailureException {
         catalog = new DefaultCamelCatalog();
         // add activemq as known component
         catalog.addComponent("activemq", "org.apache.activemq.camel.component.ActiveMQComponent");
@@ -145,6 +154,26 @@ public abstract class AbstractMainMojo extends AbstractExecMojo {
                 .addUrls(ClasspathHelper.forClassLoader(classLoader))
                 .addClassLoader(classLoader)
                 .setScanners(new SubTypesScanner()));
+
+        for (String componentName : camelComponentsOnClasspath) {
+            String json = catalog.componentJSonSchema(componentName);
+            if (json == null) {
+                getLog().debug("Cannot find component JSon metadata for component: " + componentName);
+                continue;
+            }
+
+            List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true);
+            Set<String> names = JSonSchemaHelper.getNames(rows);
+            for (String name : names) {
+                Map<String, String> row = JSonSchemaHelper.getRow(rows, name);
+                String type = row.get("type");
+                String javaType = safeJavaType(row.get("javaType"));
+                String desc = row.get("description");
+                String defaultValue = row.get("defaultValue");
+
+                callback.onOption(componentName, name, type, javaType, desc, defaultValue);
+            }
+        }
     }
 
     protected static String findCamelVersion(MavenProject project) {
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
index 50a7190..d46b653 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
@@ -92,9 +92,6 @@ public class AutowireMojo extends AbstractMainMojo {
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
-        // perform common tasks
-        super.execute();
-
         // load default mappings
         Properties mappingProperties = loadDefaultMappings();
         getLog().debug("Loaded default-mappings: " + mappingProperties);
@@ -115,8 +112,48 @@ public class AutowireMojo extends AbstractMainMojo {
             mappingProperties.putAll(mappingFileProperties);
         }
 
-        // find the autowire via classpath scanning
-        List<AutowireData> autowires = findAutowireComponentOptionsByClasspath(catalog, camelComponentsOnClasspath, reflections, mappingProperties);
+        final List<AutowireData> autowires = new ArrayList<>();
+        ComponentCallback callback = (componentName, name, type, javaType, description, defaultValue) -> {
+            if ("object".equals(type)) {
+                if (!isValidPropertyName(componentName, name)) {
+                    getLog().debug("Skipping property name: " + name);
+                    return;
+                }
+                try {
+                    Class clazz = classLoader.loadClass(javaType);
+                    if (clazz.isInterface() && isComplexUserType(clazz)) {
+                        Set<Class<?>> classes = reflections.getSubTypesOf(clazz);
+                        // filter classes (must not be interfaces, must be public, must not be abstract, must be top level) and also a valid autowire class
+                        classes = classes.stream().filter(
+                                c -> !c.isInterface()
+                                        && Modifier.isPublic(c.getModifiers())
+                                        && !Modifier.isAbstract(c.getModifiers())
+                                        && c.getEnclosingClass() == null
+                                        && isValidAutowireClass(c))
+                                .collect(Collectors.toSet());
+                        Class best = chooseBestKnownType(componentName, name, clazz, classes, mappingProperties);
+                        if (best != null) {
+                            String key = "camel.component." + componentName + "." + name;
+                            String value = "#class:" + best.getName();
+                            getLog().debug(key + "=" + value);
+                            autowires.add(new AutowireData(key, value));
+
+                            // TODO: get options from best class (getter/setter pairs)
+                            // we dont have documentation
+                            // add as spring boot options
+
+                        }
+                    }
+
+                } catch (Exception e) {
+                    // ignore
+                    getLog().debug("Cannot load class: " + name, e);
+                }
+            }
+        };
+
+        // perform the work with this callback
+        doExecute(callback);
 
         if (!autowires.isEmpty()) {
             outFolder.mkdirs();
@@ -164,67 +201,6 @@ public class AutowireMojo extends AbstractMainMojo {
         return mappings;
     }
 
-    protected List<AutowireData> findAutowireComponentOptionsByClasspath(CamelCatalog catalog, Set<String> components,
-                                                                   Reflections reflections, Properties mappingProperties) {
-        List<AutowireData> autowires = new ArrayList<>();
-
-        for (String componentName : components) {
-            getLog().debug("Autowiring Camel component: " + componentName);
-
-            String json = catalog.componentJSonSchema(componentName);
-            if (json == null) {
-                getLog().debug("Cannot find component JSon metadata for component: " + componentName);
-                continue;
-            }
-
-            List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true);
-            Set<String> names = JSonSchemaHelper.getNames(rows);
-            for (String name : names) {
-                Map<String, String> row = JSonSchemaHelper.getRow(rows, name);
-                String type = row.get("type");
-                String javaType = safeJavaType(row.get("javaType"));
-                if ("object".equals(type)) {
-                    if (!isValidPropertyName(componentName, name)) {
-                        getLog().debug("Skipping property name: " + name);
-                        continue;
-                    }
-                    try {
-                        Class clazz = classLoader.loadClass(javaType);
-                        if (clazz.isInterface() && isComplexUserType(clazz)) {
-                            Set<Class<?>> classes = reflections.getSubTypesOf(clazz);
-                            // filter classes (must not be interfaces, must be public, must not be abstract, must be top level) and also a valid autowire class
-                            classes = classes.stream().filter(
-                            c -> !c.isInterface()
-                                 && Modifier.isPublic(c.getModifiers())
-                                 && !Modifier.isAbstract(c.getModifiers())
-                                 && c.getEnclosingClass() == null
-                                 && isValidAutowireClass(c))
-                                 .collect(Collectors.toSet());
-                            Class best = chooseBestKnownType(componentName, name, clazz, classes, mappingProperties);
-                            if (best != null) {
-                                String key = "camel.component." + componentName + "." + name;
-                                String value = "#class:" + best.getName();
-                                getLog().debug(key + "=" + value);
-                                autowires.add(new AutowireData(key, value));
-
-                                // TODO: get options from best class (getter/setter pairs)
-                                // we dont have documentation
-                                // add as spring boot options
-
-                            }
-                        }
-
-                    } catch (Exception e) {
-                        // ignore
-                        getLog().debug("Cannot load class: " + name, e);
-                    }
-                }
-            }
-        }
-
-        return autowires;
-    }
-
     protected Class chooseBestKnownType(String componentName, String optionName, Class type, Set<Class<?>> candidates, Properties knownTypes) {
         String known = knownTypes.getProperty(type.getName());
         if (known != null) {
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
index d331108..dc56282 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
@@ -21,10 +21,7 @@ import java.io.FileOutputStream;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
-import org.apache.camel.catalog.JSonSchemaHelper;
 import org.apache.camel.maven.model.SpringBootData;
 import org.apache.camel.util.IOHelper;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -51,38 +48,17 @@ public class SpringBootToolingMojo extends AbstractMainMojo {
 
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
-        // perform common tasks
-        super.execute();
 
-        // load camel-main metadata
-        String mainJson = loadCamelMainConfigurationMetadata();
-        if (mainJson == null) {
-            getLog().warn("Cannot load camel-main-configuration-metadata.json from within the camel-main JAR from the classpath."
-                    + " Not possible to build spring boot configuration file for this project");
-            return;
-        }
-
-        List<SpringBootData> componentData = new ArrayList<>();
-        for (String componentName : camelComponentsOnClasspath) {
-            String json = catalog.componentJSonSchema(componentName);
-            if (json == null) {
-                getLog().debug("Cannot find component JSon metadata for component: " + componentName);
-                continue;
-            }
+        final List<SpringBootData> componentData = new ArrayList<>();
+        ComponentCallback callback = (componentName, name, type, javaType, description, defaultValue) -> {
+            // we want to use dash in the name
+            String dash = camelCaseToDash(name);
+            String key = "camel.component." + componentName + "." + dash;
+            componentData.add(new SpringBootData(key, springBootJavaType(javaType), description, defaultValue));
+        };
 
-            List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true);
-            Set<String> names = JSonSchemaHelper.getNames(rows);
-            for (String name : names) {
-                Map<String, String> row = JSonSchemaHelper.getRow(rows, name);
-                String javaType = springBootJavaType(safeJavaType(row.get("javaType")));
-                String desc = row.get("description");
-                String defaultValue = row.get("defaultValue");
-                // we want to use dash in the name
-                String dash = camelCaseToDash(name);
-                String key = "camel.component." + componentName + "." + dash;
-                componentData.add(new SpringBootData(key, javaType, desc, defaultValue));
-            }
-        }
+        // perform the work with this callback
+        doExecute(callback);
 
         if (!componentData.isEmpty()) {
             StringBuilder sb = new StringBuilder();
@@ -113,6 +89,13 @@ public class SpringBootToolingMojo extends AbstractMainMojo {
             sb.append("}\n");
 
             // okay then add the components into the main json at the end so they get merged together
+            // load camel-main metadata
+            String mainJson = loadCamelMainConfigurationMetadata();
+            if (mainJson == null) {
+                getLog().warn("Cannot load camel-main-configuration-metadata.json from within the camel-main JAR from the classpath."
+                        + " Not possible to build spring boot configuration file for this project");
+                return;
+            }
             int pos = mainJson.lastIndexOf("    }");
             String newJson = mainJson.substring(0, pos);
             newJson = newJson + "    },\n";


[camel] 05/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c316a27ffc80f75dc5852ebdb44eabe93722cd5c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 09:50:55 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../src/main/docs/camel-main-maven-plugin.adoc     |  98 ++++---------
 .../org/apache/camel/maven/AbstractMainMojo.java   |   5 +-
 .../java/org/apache/camel/maven/AutowireMojo.java  |   1 +
 .../maven/{AutowireMojo.java => GenerateMojo.java} | 162 +++++++++++++++++----
 .../apache/camel/maven/SpringBootToolingMojo.java  |   1 +
 examples/camel-example-main-artemis/pom.xml        |   3 +-
 6 files changed, 171 insertions(+), 99 deletions(-)

diff --git a/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc b/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc
index e8d1364..97f6eca 100644
--- a/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc
+++ b/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc
@@ -2,11 +2,9 @@
 
 The Camel Main Maven Plugin supports the following goals
 
- - camel-main:autowire - To pre-scan your project and prepare autowiring by classpath scanning
- - camel-main:spring-boot-tooling - To pre-scan your project and builds spring boot tooling metafiles
-   which fools tools to offer code completion for editing properties files.
+ - camel-main:generate - To pre-scan your project and prepare autowiring and sprint boot tooling support by classpath scanning.
 
-== camel:autowire
+== Autowiring
 
 To pre-scan your project and prepare autowiring by classpath scanning.
 The idea is to use this maven plugin at build/compile time and detect what's on the classpath
@@ -22,8 +20,28 @@ JMS client you are using. Another example is JDBC drivers etc. In other words
 its a bit like Spring Boot _starter_ JARs that also offers a similar concept, but
 without the phase of doing this during build time.
 
+== Spring Boot Tooling
+
+To pre-scan your project and builds spring boot tooling metafiles
+which fools tools to offer code completion for editing properties files.
+
+This will generate a Spring Boot tooling metadata file in `src/main/resouces/META-INF/spring-configuration-metadata.json`
+which contains all the options from Camel Main and the components from the classpath.
+
+For example if you have camel-jms on the classpath, then Java tools that has support for Spring Boot,
+can offer code completions when you edit `application.properties` file:
+
+----
+camel.component.jms.CURSOR HERE
+----
+
+Just press ctrl + space at the _CURSOR HERE_ location and you will get all the options you
+can configure on the JMS component.
+
+== Using the plugin
+
 ----
-mvn camel-main:autowire
+mvn camel-main:generate
 ----
 
 You can also enable the plugin to automatic run as part of the build to catch these errors.
@@ -37,7 +55,7 @@ You can also enable the plugin to automatic run as part of the build to catch th
     <execution>
       <phase>process-classes</phase>
       <goals>
-        <goal>autowire</goal>
+        <goal>generate</goal>
       </goals>
     </execution>
   </executions>
@@ -50,14 +68,14 @@ the compilation of the main source code.
 
 === Include and Exclude properties or components
 
-By default the `autowire` goal will scan all the detected Camel components from the classpath.
+By default the plugin will scan all the detected Camel components from the classpath.
 
 For example as shown below, there are 29 detected Camel components,
 and 1 mapping was created in the `autowire.properties` file
 
 [source,text]
 ----
-[INFO] --- camel-main-maven-plugin:3.0.0-SNAPSHOT:autowire (generate) @ camel-example-main-artemis ---
+[INFO] --- camel-main-maven-plugin:3.0.0-SNAPSHOT:generate (generate) @ camel-example-main-artemis ---
 [INFO] Detected Camel version used in project: 3.0.0-SNAPSHOT
 [INFO] Pre-scanning using Camel version: 3.0.0-SNAPSHOT
 [INFO] Discovered 29 Camel components from classpath: [bean, browse, class, controlbus, dataformat, dataset, dataset-test, direct, direct-vm, file, jms, language, log, mock, properties, quartz, quartz2, ref, rest, rest-api, saga, scheduler, seda, spring-event, stub, timer, validator, vm, xslt]
@@ -82,7 +100,7 @@ For example to only include the JMS component you can do:
     <execution>
       <phase>process-classes</phase>
       <goals>
-        <goal>autowire</goal>
+        <goal>generate</goal>
       </goals>
     </execution>
   </executions>
@@ -118,7 +136,7 @@ For example one of the default mappings is as shown:
 javax.jms.ConnectionFactory=org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;org.apache.activemq.ActiveMQConnectionFactory
 ----
 
-This tells the `autowire` goal that if the value of the property is a `javax.jms.ConnectionFactory` type
+This tells the `generate` goal that if the value of the property is a `javax.jms.ConnectionFactory` type
 then we should only accept the following implementations when scanning the classpath:
 
 - `org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory`
@@ -137,11 +155,11 @@ You can also specify the skip certain types, such as
 org.springframework.jms.core.JmsOperations=#skip#
 ----
 
-Which means the `autowire` goal skips any property values that are of type `org.springframework.jms.core.JmsOperations`.
+Which means the `generate` goal skips any property values that are of type `org.springframework.jms.core.JmsOperations`.
 
 === Options
 
-The maven plugin *autowire* goal supports the following options which can be configured from the command line (use `-D` syntax), or defined in the `pom.xml` file in the `<configuration>` tag.
+The maven plugin *generate* goal supports the following options which can be configured from the command line (use `-D` syntax), or defined in the `pom.xml` file in the `<configuration>` tag.
 
 |===
 | Parameter | Default Value | Description
@@ -155,62 +173,8 @@ The maven plugin *autowire* goal supports the following options which can be con
 | mappingsFile | | Optional mappings file loaded from classpath, with mapping that override any default mappings. Will by default load the file `camel-main-mappings.properties` from the classpath root.
 |===
 
-==== Examples
+=== Examples
 
 You can find more details and a working example at `examples/camel-example-main-artemis`.
 
 
-== camel:spring-boot-tooling
-
-To pre-scan your project and builds spring boot tooling metafiles
-which fools tools to offer code completion for editing properties files.
-
-----
-mvn camel-main:spring-boot-tooling
-----
-
-This will generate a Spring Boot tooling metadata file in `src/main/resouces/META-INF/spring-configuration-metadata.json`
-which contains all the options from Camel Main and the components from the classpath.
-
-For example if you have camel-jms on the classpath, then Java tools that has support for Spring Boot,
-can offer code completions when you edit `application.properties` file:
-
-----
-camel.component.jms.CURSOR HERE
-----
-
-Just press ctrl + space at the _CURSOR HERE_ location and you will get all the options you
-can configure on the JMS component.
-
-
-You can also enable the plugin to automatic run as part of the build to catch these errors.
-
-[source,xml]
-----
-<plugin>
-  <groupId>org.apache.camel</groupId>
-  <artifactId>camel-main-maven-plugin</artifactId>
-  <executions>
-    <execution>
-      <phase>process-classes</phase>
-      <goals>
-        <goal>spring-boot-tooling</goal>
-      </goals>
-    </execution>
-  </executions>
-</plugin>
-----
-
-The phase determines when the plugin runs. In the sample above the phase is `process-classes` which runs after
-the compilation of the main source code.
-
-=== Options
-
-The maven plugin *spring-boot-tooling* goal supports the following options which can be configured from the command line (use `-D` syntax), or defined in the `pom.xml` file in the `<configuration>` tag.
-
-|===
-| Parameter | Default Value | Description
-| logClasspath | false | Whether to log the classpath when starting
-| downloadVersion | true | Whether to allow downloading Camel catalog version from the internet.
-  This is needed if the project * uses a different Camel version than this plugin is using by default.
-|===
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java
index 44a8891..5705d47 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AbstractMainMojo.java
@@ -32,14 +32,11 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.function.Function;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.DefaultCamelCatalog;
 import org.apache.camel.catalog.JSonSchemaHelper;
 import org.apache.camel.catalog.maven.MavenVersionManager;
-import org.apache.camel.maven.model.AutowireData;
-import org.apache.camel.maven.model.SpringBootData;
 import org.apache.camel.util.IOHelper;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -293,7 +290,7 @@ public abstract class AbstractMainMojo extends AbstractExecMojo {
         return artifacts;
     }
 
-    protected String safeJavaType(String javaType) {
+    static String safeJavaType(String javaType) {
         int pos = javaType.indexOf('<');
         if (pos > 0) {
             return javaType.substring(0, pos);
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
index d46b653..a742f4a 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
@@ -48,6 +48,7 @@ import org.reflections.Reflections;
  * Pre scans your project and prepare autowiring by classpath scanning
  */
 @Mojo(name = "autowire", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE)
+@Deprecated
 public class AutowireMojo extends AbstractMainMojo {
 
     /**
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
similarity index 64%
copy from catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
copy to catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
index d46b653..c3e3b21 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
@@ -1,13 +1,13 @@
-/*
+/**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,14 +24,12 @@ import java.io.InputStream;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.JSonSchemaHelper;
 import org.apache.camel.maven.model.AutowireData;
+import org.apache.camel.maven.model.SpringBootData;
 import org.apache.camel.support.PatternHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
@@ -42,13 +40,14 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.reflections.Reflections;
+
+import static org.apache.camel.util.StringHelper.camelCaseToDash;
 
 /**
- * Pre scans your project and prepare autowiring by classpath scanning
+ * Pre scans your project and prepares autowiring and spring-boot tooling support by classpath scanning.
  */
-@Mojo(name = "autowire", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE)
-public class AutowireMojo extends AbstractMainMojo {
+@Mojo(name = "generate", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE)
+public class GenerateMojo extends AbstractMainMojo {
 
     /**
      * When autowiring has detected multiple implementations (2 or more) of a given interface, which
@@ -61,7 +60,13 @@ public class AutowireMojo extends AbstractMainMojo {
      * The output directory for generated autowire file
      */
     @Parameter(readonly = true, defaultValue = "${project.build.directory}/classes/META-INF/services/org/apache/camel/")
-    protected File outFolder;
+    protected File outAutowireFolder;
+
+    /**
+     * The output directory for generated spring boot tooling file
+     */
+    @Parameter(readonly = true, defaultValue = "${project.build.directory}/../src/main/resources/META-INF/")
+    protected File outSpringBootFolder;
 
     /**
      * To exclude autowiring specific properties with these key names.
@@ -90,6 +95,7 @@ public class AutowireMojo extends AbstractMainMojo {
     @Parameter(defaultValue = "${project.build.directory}/classes/camel-main-mappings.properties")
     protected File mappingsFile;
 
+
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         // load default mappings
@@ -112,10 +118,19 @@ public class AutowireMojo extends AbstractMainMojo {
             mappingProperties.putAll(mappingFileProperties);
         }
 
-        final List<AutowireData> autowires = new ArrayList<>();
+        final List<AutowireData> autowireData = new ArrayList<>();
+        final List<SpringBootData> springBootData = new ArrayList<>();
+
         ComponentCallback callback = (componentName, name, type, javaType, description, defaultValue) -> {
+            // gather spring boot data
+            // we want to use dash in the name
+            String dash = camelCaseToDash(name);
+            String key = "camel.component." + componentName + "." + dash;
+            springBootData.add(new SpringBootData(key, springBootJavaType(javaType), description, defaultValue));
+
+            // check if we can do automatic autowire to complex singleton objects from classes in the classpath
             if ("object".equals(type)) {
-                if (!isValidPropertyName(componentName, name)) {
+                if (!isValidAutowirePropertyName(componentName, name)) {
                     getLog().debug("Skipping property name: " + name);
                     return;
                 }
@@ -133,15 +148,14 @@ public class AutowireMojo extends AbstractMainMojo {
                                 .collect(Collectors.toSet());
                         Class best = chooseBestKnownType(componentName, name, clazz, classes, mappingProperties);
                         if (best != null) {
-                            String key = "camel.component." + componentName + "." + name;
+                            key = "camel.component." + componentName + "." + name;
                             String value = "#class:" + best.getName();
                             getLog().debug(key + "=" + value);
-                            autowires.add(new AutowireData(key, value));
+                            autowireData.add(new AutowireData(key, value));
 
                             // TODO: get options from best class (getter/setter pairs)
                             // we dont have documentation
                             // add as spring boot options
-
                         }
                     }
 
@@ -152,23 +166,84 @@ public class AutowireMojo extends AbstractMainMojo {
             }
         };
 
-        // perform the work with this callback
+        // execute with the callback
         doExecute(callback);
 
-        if (!autowires.isEmpty()) {
-            outFolder.mkdirs();
-            File file = new File(outFolder, "autowire.properties");
+        // write the output files
+        writeAutowireFile(autowireData);
+        writeSpringBootFile(springBootData);
+    }
+
+    protected void writeSpringBootFile(List<SpringBootData> springBootData) throws MojoFailureException {
+        if (!springBootData.isEmpty()) {
+            StringBuilder sb = new StringBuilder();
+
+            for (int i = 0; i < springBootData.size(); i++) {
+                SpringBootData row = springBootData.get(i);
+                sb.append("    {\n");
+                sb.append("      \"name\": \"" + row.getName() + "\",\n");
+                sb.append("      \"type\": \"" + row.getJavaType() + "\",\n");
+                sb.append("      \"description\": \"" + row.getDescription() + "\"");
+                if (row.getDefaultValue() != null) {
+                    sb.append(",\n");
+                    if (springBootDefaultValueQuotes(row.getJavaType())) {
+                        sb.append("      \"defaultValue\": \"" + row.getDefaultValue() + "\"\n");
+                    } else {
+                        sb.append("      \"defaultValue\": " + row.getDefaultValue() + "\n");
+                    }
+                } else {
+                    sb.append("\n");
+                }
+                if (i < springBootData.size() - 1) {
+                    sb.append("    },\n");
+                } else {
+                    sb.append("    }\n");
+                }
+            }
+            sb.append("  ]\n");
+            sb.append("}\n");
+
+            // okay then add the components into the main json at the end so they get merged together
+            // load camel-main metadata
+            String mainJson = loadCamelMainConfigurationMetadata();
+            if (mainJson == null) {
+                getLog().warn("Cannot load camel-main-configuration-metadata.json from within the camel-main JAR from the classpath."
+                        + " Not possible to build spring boot configuration file for this project");
+                return;
+            }
+            int pos = mainJson.lastIndexOf("    }");
+            String newJson = mainJson.substring(0, pos);
+            newJson = newJson + "    },\n";
+            newJson = newJson + sb.toString();
+
+            outSpringBootFolder.mkdirs();
+            File file = new File(outSpringBootFolder, "spring-configuration-metadata.json");
+            try {
+                FileOutputStream fos = new FileOutputStream(file, false);
+                fos.write(newJson.getBytes());
+                IOHelper.close(fos);
+                getLog().info("Created file: " + file);
+            } catch (Throwable e) {
+                throw new MojoFailureException("Cannot write to file " + file + " due " + e.getMessage(), e);
+            }
+        }
+    }
+
+    protected void writeAutowireFile(List<AutowireData> autowireData) throws MojoFailureException {
+        if (!autowireData.isEmpty()) {
+            outAutowireFolder.mkdirs();
+            File file = new File(outAutowireFolder, "autowire.properties");
             try {
                 FileOutputStream fos = new FileOutputStream(file, false);
                 fos.write("# Generated by camel build tools\n".getBytes());
-                for (AutowireData data : autowires) {
+                for (AutowireData data : autowireData) {
                     fos.write(data.getKey().getBytes());
                     fos.write('=');
                     fos.write(data.getValue().getBytes());
                     fos.write('\n');
                 }
                 IOHelper.close(fos);
-                getLog().info("Created file: " + file + " (autowire by classpath: " + autowires.size() + ")");
+                getLog().info("Created file: " + file + " (autowire by classpath: " + autowireData.size() + ")");
             } catch (Throwable e) {
                 throw new MojoFailureException("Cannot write to file " + file + " due " + e.getMessage(), e);
             }
@@ -178,7 +253,7 @@ public class AutowireMojo extends AbstractMainMojo {
     protected Properties loadDefaultMappings() throws MojoFailureException {
         Properties mappings = new OrderedProperties();
         try {
-            InputStream is = AutowireMojo.class.getResourceAsStream("/default-mappings.properties");
+            InputStream is = GenerateMojo.class.getResourceAsStream("/default-mappings.properties");
             if (is != null) {
                 mappings.load(is);
             }
@@ -231,7 +306,7 @@ public class AutowireMojo extends AbstractMainMojo {
         return null;
     }
 
-    protected boolean isValidPropertyName(String componentName, String name) {
+    protected boolean isValidAutowirePropertyName(String componentName, String name) {
         // we want to regard names as the same if they are using dash or not, and also to be case insensitive.
         String prefix = "camel.component." + componentName + ".";
         name = StringHelper.dashToCamelCase(name);
@@ -273,9 +348,44 @@ public class AutowireMojo extends AbstractMainMojo {
         return type != null && !type.isPrimitive() && !type.getName().startsWith("java.");
     }
 
-    protected boolean isValidAutowireClass(Class clazz) {
+    private static boolean isValidAutowireClass(Class clazz) {
         // skip all from Apache Camel and regular JDK as they would be default anyway
         return !clazz.getName().startsWith("org.apache.camel");
     }
 
+    private String loadCamelMainConfigurationMetadata() throws MojoFailureException {
+        try {
+            InputStream is = classLoader.getResourceAsStream("META-INF/camel-main-configuration-metadata.json");
+            String text = IOHelper.loadText(is);
+            IOHelper.close(is);
+            return text;
+        } catch (Throwable e) {
+            throw new MojoFailureException("Error during discovering camel-main from classpath due " + e.getMessage(), e);
+        }
+    }
+
+    private static String springBootJavaType(String javaType) {
+        if ("boolean".equalsIgnoreCase(javaType)) {
+            return "java.lang.Boolean";
+        } else if ("int".equalsIgnoreCase(javaType)) {
+            return "java.lang.Integer";
+        } else if ("long".equalsIgnoreCase(javaType)) {
+            return "java.lang.Long";
+        } else if ("string".equalsIgnoreCase(javaType)) {
+            return "java.lang.String";
+        }
+        return javaType;
+    }
+
+    private static boolean springBootDefaultValueQuotes(String javaType) {
+        if ("java.lang.Boolean".equalsIgnoreCase(javaType)) {
+            return false;
+        } else if ("java.lang.Integer".equalsIgnoreCase(javaType)) {
+            return false;
+        } else if ("java.lang.Long".equalsIgnoreCase(javaType)) {
+            return false;
+        }
+        return true;
+    }
+
 }
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
index dc56282..9691afc 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
@@ -38,6 +38,7 @@ import static org.apache.camel.util.StringHelper.camelCaseToDash;
  * offer code completion for editing properties files.
  */
 @Mojo(name = "spring-boot-tooling", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE)
+@Deprecated
 public class SpringBootToolingMojo extends AbstractMainMojo {
 
     /**
diff --git a/examples/camel-example-main-artemis/pom.xml b/examples/camel-example-main-artemis/pom.xml
index e1cad5a..f77c46b 100644
--- a/examples/camel-example-main-artemis/pom.xml
+++ b/examples/camel-example-main-artemis/pom.xml
@@ -115,8 +115,7 @@
                     <execution>
                         <id>generate</id>
                         <goals>
-                            <goal>autowire</goal>
-                            <goal>spring-boot-tooling</goal>
+                            <goal>generate</goal>
                         </goals>
                         <phase>process-classes</phase>
                     </execution>


[camel] 01/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 7657f6dabbac7efa1c4f1e878bdf93714540f4d6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jun 20 15:05:42 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../src/main/java/org/apache/camel/maven/AutowireMojo.java          | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
index 63f0c61..947c5a7 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.JSonSchemaHelper;
+import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PatternHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
@@ -202,6 +203,11 @@ public class AutowireMojo extends AbstractMainMojo {
                                 String line = "camel.component." + componentName + "." + name + "=#class:" + best.getName();
                                 getLog().debug(line);
                                 autowires.add(line);
+
+                                // TODO: get options from best class (getter/setter pairs)
+                                // we dont have documentation
+                                // add as spring boot options
+
                             }
                         }
 


[camel] 03/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0b13d7ca9dcc9fc92d936a183390d976e8237fde
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 09:06:23 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../java/org/apache/camel/maven/AutowireMojo.java  | 23 ++++----
 .../apache/camel/maven/SpringBootToolingMojo.java  | 25 ++++-----
 .../org/apache/camel/maven/model/AutowireData.java | 44 +++++++++++++++
 .../apache/camel/maven/model/SpringBootData.java   | 64 ++++++++++++++++++++++
 4 files changed, 132 insertions(+), 24 deletions(-)

diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
index 947c5a7..50a7190 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
@@ -31,7 +31,7 @@ import java.util.stream.Collectors;
 
 import org.apache.camel.catalog.CamelCatalog;
 import org.apache.camel.catalog.JSonSchemaHelper;
-import org.apache.camel.support.IntrospectionSupport;
+import org.apache.camel.maven.model.AutowireData;
 import org.apache.camel.support.PatternHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
@@ -116,7 +116,7 @@ public class AutowireMojo extends AbstractMainMojo {
         }
 
         // find the autowire via classpath scanning
-        List<String> autowires = findAutowireComponentOptionsByClasspath(catalog, camelComponentsOnClasspath, reflections, mappingProperties);
+        List<AutowireData> autowires = findAutowireComponentOptionsByClasspath(catalog, camelComponentsOnClasspath, reflections, mappingProperties);
 
         if (!autowires.isEmpty()) {
             outFolder.mkdirs();
@@ -124,9 +124,11 @@ public class AutowireMojo extends AbstractMainMojo {
             try {
                 FileOutputStream fos = new FileOutputStream(file, false);
                 fos.write("# Generated by camel build tools\n".getBytes());
-                for (String line : autowires) {
-                    fos.write(line.getBytes());
-                    fos.write("\n".getBytes());
+                for (AutowireData data : autowires) {
+                    fos.write(data.getKey().getBytes());
+                    fos.write('=');
+                    fos.write(data.getValue().getBytes());
+                    fos.write('\n');
                 }
                 IOHelper.close(fos);
                 getLog().info("Created file: " + file + " (autowire by classpath: " + autowires.size() + ")");
@@ -162,9 +164,9 @@ public class AutowireMojo extends AbstractMainMojo {
         return mappings;
     }
 
-    protected List<String> findAutowireComponentOptionsByClasspath(CamelCatalog catalog, Set<String> components,
+    protected List<AutowireData> findAutowireComponentOptionsByClasspath(CamelCatalog catalog, Set<String> components,
                                                                    Reflections reflections, Properties mappingProperties) {
-        List<String> autowires = new ArrayList<>();
+        List<AutowireData> autowires = new ArrayList<>();
 
         for (String componentName : components) {
             getLog().debug("Autowiring Camel component: " + componentName);
@@ -200,9 +202,10 @@ public class AutowireMojo extends AbstractMainMojo {
                                  .collect(Collectors.toSet());
                             Class best = chooseBestKnownType(componentName, name, clazz, classes, mappingProperties);
                             if (best != null) {
-                                String line = "camel.component." + componentName + "." + name + "=#class:" + best.getName();
-                                getLog().debug(line);
-                                autowires.add(line);
+                                String key = "camel.component." + componentName + "." + name;
+                                String value = "#class:" + best.getName();
+                                getLog().debug(key + "=" + value);
+                                autowires.add(new AutowireData(key, value));
 
                                 // TODO: get options from best class (getter/setter pairs)
                                 // we dont have documentation
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
index a5d8cb0..d331108 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.camel.catalog.JSonSchemaHelper;
+import org.apache.camel.maven.model.SpringBootData;
 import org.apache.camel.util.IOHelper;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -61,7 +62,7 @@ public class SpringBootToolingMojo extends AbstractMainMojo {
             return;
         }
 
-        List<String[]> componentData = new ArrayList<>();
+        List<SpringBootData> componentData = new ArrayList<>();
         for (String componentName : camelComponentsOnClasspath) {
             String json = catalog.componentJSonSchema(componentName);
             if (json == null) {
@@ -79,7 +80,7 @@ public class SpringBootToolingMojo extends AbstractMainMojo {
                 // we want to use dash in the name
                 String dash = camelCaseToDash(name);
                 String key = "camel.component." + componentName + "." + dash;
-                componentData.add(new String[]{key, javaType, desc, defaultValue});
+                componentData.add(new SpringBootData(key, javaType, desc, defaultValue));
             }
         }
 
@@ -87,21 +88,17 @@ public class SpringBootToolingMojo extends AbstractMainMojo {
             StringBuilder sb = new StringBuilder();
 
             for (int i = 0; i < componentData.size(); i++) {
-                String[] row = componentData.get(i);
-                String name = row[0];
-                String javaType = row[1];
-                String desc = row[2];
-                String defaultValue = row[3];
+                SpringBootData row = componentData.get(i);
                 sb.append("    {\n");
-                sb.append("      \"name\": \"" + name + "\",\n");
-                sb.append("      \"type\": \"" + javaType + "\",\n");
-                sb.append("      \"description\": \"" + desc + "\"");
-                if (defaultValue != null) {
+                sb.append("      \"name\": \"" + row.getName() + "\",\n");
+                sb.append("      \"type\": \"" + row.getJavaType() + "\",\n");
+                sb.append("      \"description\": \"" + row.getDescription() + "\"");
+                if (row.getDefaultValue() != null) {
                     sb.append(",\n");
-                    if (springBootDefaultValueQuotes(javaType)) {
-                        sb.append("      \"defaultValue\": \"" + defaultValue + "\"\n");
+                    if (springBootDefaultValueQuotes(row.getJavaType())) {
+                        sb.append("      \"defaultValue\": \"" + row.getDefaultValue() + "\"\n");
                     } else {
-                        sb.append("      \"defaultValue\": " + defaultValue + "\n");
+                        sb.append("      \"defaultValue\": " + row.getDefaultValue() + "\n");
                     }
                 } else {
                     sb.append("\n");
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/AutowireData.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/AutowireData.java
new file mode 100644
index 0000000..ab7019a
--- /dev/null
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/AutowireData.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.model;
+
+public final class AutowireData {
+
+    private String key;
+    private String value;
+
+    public AutowireData(String key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/SpringBootData.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/SpringBootData.java
new file mode 100644
index 0000000..e10ae5a
--- /dev/null
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/model/SpringBootData.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.model;
+
+public final class SpringBootData {
+
+    private String name;
+    private String javaType;
+    private String description;
+    private String defaultValue;
+
+    public SpringBootData(String name, String javaType, String description, String defaultValue) {
+        this.name = name;
+        this.javaType = javaType;
+        this.description = description;
+        this.defaultValue = defaultValue;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getJavaType() {
+        return javaType;
+    }
+
+    public void setJavaType(String javaType) {
+        this.javaType = javaType;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+}


[camel] 07/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a6d02e0737f7de2017de746acc9999b415c81405
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 10:25:00 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../src/main/docs/camel-main-maven-plugin.adoc     |   2 +
 .../java/org/apache/camel/maven/GenerateMojo.java  |  61 +++++-
 .../META-INF/spring-configuration-metadata.json    | 210 +++++++++++++++++++++
 3 files changed, 265 insertions(+), 8 deletions(-)

diff --git a/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc b/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc
index 97f6eca..34f9007 100644
--- a/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc
+++ b/catalog/camel-main-maven-plugin/src/main/docs/camel-main-maven-plugin.adoc
@@ -163,6 +163,8 @@ The maven plugin *generate* goal supports the following options which can be con
 
 |===
 | Parameter | Default Value | Description
+| autowireEnabled | true | Whether generating autowiring is enabled.
+| springBootEnabled | true | Whether generating spring boot tooling support is enabled.
 | logClasspath | false | Whether to log the classpath when starting
 | logUnmapped | false | When autowiring has detected multiple implementations (2 or more) of a given interface, which cannot be mapped, should they be logged so you can see and add manual mapping if needed.
 | downloadVersion | true | Whether to allow downloading Camel catalog version from the internet.
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
index c3e3b21..04d5567 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
@@ -21,6 +21,7 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.List;
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
 
 import org.apache.camel.maven.model.AutowireData;
 import org.apache.camel.maven.model.SpringBootData;
+import org.apache.camel.support.IntrospectionSupport;
 import org.apache.camel.support.PatternHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.OrderedProperties;
@@ -50,6 +52,18 @@ import static org.apache.camel.util.StringHelper.camelCaseToDash;
 public class GenerateMojo extends AbstractMainMojo {
 
     /**
+     * Whether generating autowiring is enabled.
+     */
+    @Parameter(property = "camel.autowireEnabled", defaultValue = "true")
+    protected boolean autowireEnabled;
+
+    /**
+     * Whether generating spring boot tooling support is enabled.
+     */
+    @Parameter(property = "camel.springBootEnabled", defaultValue = "true")
+    protected boolean springBootEnabled;
+
+    /**
      * When autowiring has detected multiple implementations (2 or more) of a given interface, which
      * cannot be mapped, should they be logged so you can see and add manual mapping if needed.
      */
@@ -126,10 +140,13 @@ public class GenerateMojo extends AbstractMainMojo {
             // we want to use dash in the name
             String dash = camelCaseToDash(name);
             String key = "camel.component." + componentName + "." + dash;
-            springBootData.add(new SpringBootData(key, springBootJavaType(javaType), description, defaultValue));
+            if (springBootEnabled) {
+                getLog().debug("Spring Boot option: " + key);
+                springBootData.add(new SpringBootData(key, springBootJavaType(javaType), description, defaultValue));
+            }
 
             // check if we can do automatic autowire to complex singleton objects from classes in the classpath
-            if ("object".equals(type)) {
+            if (autowireEnabled && "object".equals(type)) {
                 if (!isValidAutowirePropertyName(componentName, name)) {
                     getLog().debug("Skipping property name: " + name);
                     return;
@@ -148,14 +165,28 @@ public class GenerateMojo extends AbstractMainMojo {
                                 .collect(Collectors.toSet());
                         Class best = chooseBestKnownType(componentName, name, clazz, classes, mappingProperties);
                         if (best != null) {
-                            key = "camel.component." + componentName + "." + name;
+                            key = "camel.component." + componentName + "." + dash;
                             String value = "#class:" + best.getName();
-                            getLog().debug(key + "=" + value);
+                            getLog().debug("Autowire: " + key + "=" + value);
                             autowireData.add(new AutowireData(key, value));
 
-                            // TODO: get options from best class (getter/setter pairs)
-                            // we dont have documentation
-                            // add as spring boot options
+                            if (springBootEnabled) {
+                                // gather additional spring boot data for this class
+                                // we dont have documentation or default values
+                                List<Method> setters = new ArrayList<>();
+                                extraSetterMethods(best, setters);
+                                // sort the setters
+                                setters.sort((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
+                                for (Method m : setters) {
+                                    String shortHand = IntrospectionSupport.getSetterShorthandName(m);
+                                    String bootName = camelCaseToDash(shortHand);
+                                    String bootKey = "camel.component." + componentName + "." + dash + "." + bootName;
+                                    String bootJavaType = m.getParameterTypes()[0].getName();
+                                    getLog().debug("Spring Boot option: " + bootKey);
+                                    String desc = "Auto discovered option from class: " + best.getName() + " to set the option via setter: " + m.getName();
+                                    springBootData.add(new SpringBootData(bootKey, springBootJavaType(bootJavaType), desc, null));
+                                }
+                            }
                         }
                     }
 
@@ -183,7 +214,9 @@ public class GenerateMojo extends AbstractMainMojo {
                 sb.append("    {\n");
                 sb.append("      \"name\": \"" + row.getName() + "\",\n");
                 sb.append("      \"type\": \"" + row.getJavaType() + "\",\n");
-                sb.append("      \"description\": \"" + row.getDescription() + "\"");
+                if (row.getDescription() != null) {
+                    sb.append("      \"description\": \"" + row.getDescription() + "\"");
+                }
                 if (row.getDefaultValue() != null) {
                     sb.append(",\n");
                     if (springBootDefaultValueQuotes(row.getJavaType())) {
@@ -388,4 +421,16 @@ public class GenerateMojo extends AbstractMainMojo {
         return true;
     }
 
+    private static void extraSetterMethods(Class<?> clazz, List<Method> answer) {
+        if (clazz == null || clazz == Object.class) {
+            return;
+        }
+        Method[] methods = clazz.getMethods();
+        for (Method m : methods) {
+            if (IntrospectionSupport.isSetter(m)) {
+                answer.add(m);
+            }
+        }
+    }
+
 }
diff --git a/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json b/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
index 03f8ff8..75835f7 100644
--- a/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
+++ b/examples/camel-example-main-artemis/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -662,6 +662,216 @@
       "description": "The connection factory to be use. A connection factory must be configured either on the component or endpoint."
     },
     {
+      "name": "camel.component.jms.connection-factory.auto-group",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setAutoGroup"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.block-on-acknowledge",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setBlockOnAcknowledge"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.block-on-durable-send",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setBlockOnDurableSend"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.block-on-non-durable-send",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setBlockOnNonDurableSend"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.cache-destinations",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setCacheDestinations"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.cache-large-messages-client",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setCacheLargeMessagesClient"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.call-failover-timeout",
+      "type": "java.lang.Long",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setCallFailoverTimeout"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.call-timeout",
+      "type": "java.lang.Long",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setCallTimeout"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.client-failure-check-period",
+      "type": "java.lang.Long",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setClientFailureCheckPeriod"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.client-id",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setClientID"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.compress-large-message",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setCompressLargeMessage"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.confirmation-window-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setConfirmationWindowSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.connection-load-balancing-policy-class-name",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setConnectionLoadBalancingPolicyClassName"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.connection-ttl",
+      "type": "java.lang.Long",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setConnectionTTL"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.consumer-max-rate",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setConsumerMaxRate"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.consumer-window-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setConsumerWindowSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.deserialization-black-list",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setDeserializationBlackList"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.deserialization-white-list",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setDeserializationWhiteList"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.dups-ok-batch-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setDupsOKBatchSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.enable1x-prefixes",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setEnable1xPrefixes"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.enable-shared-client-id",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setEnableSharedClientID"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.failover-on-initial-connection",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setFailoverOnInitialConnection"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.group-id",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setGroupID"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.ignore-jta",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setIgnoreJTA"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.incoming-interceptor-list",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setIncomingInterceptorList"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.initial-connect-attempts",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setInitialConnectAttempts"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.initial-message-packet-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setInitialMessagePacketSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.max-retry-interval",
+      "type": "java.lang.Long",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setMaxRetryInterval"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.min-large-message-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setMinLargeMessageSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.outgoing-interceptor-list",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setOutgoingInterceptorList"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.pre-acknowledge",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setPreAcknowledge"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.producer-max-rate",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setProducerMaxRate"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.producer-window-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setProducerWindowSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.protocol-manager-factory-str",
+      "type": "java.lang.String",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setProtocolManagerFactoryStr"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.reconnect-attempts",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setReconnectAttempts"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.retry-interval",
+      "type": "java.lang.Long",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setRetryInterval"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.retry-interval-multiplier",
+      "type": "double",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setRetryIntervalMultiplier"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.scheduled-thread-pool-max-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setScheduledThreadPoolMaxSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.thread-pool-max-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setThreadPoolMaxSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.transaction-batch-size",
+      "type": "java.lang.Integer",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setTransactionBatchSize"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.use-global-pools",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setUseGlobalPools"
+    },
+    {
+      "name": "camel.component.jms.connection-factory.use-topology-for-load-balancing",
+      "type": "java.lang.Boolean",
+      "description": "Auto discovered option from class: org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory to set the option via setter: setUseTopologyForLoadBalancing"
+    },
+    {
       "name": "camel.component.jms.username",
       "type": "java.lang.String",
       "description": "Username to use with the ConnectionFactory. You can also configure username/password directly on the ConnectionFactory."


[camel] 02/08: Regen

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4e52087d5955d42d54eb2a5b81cc9093c287c959
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 05:37:47 2019 +0200

    Regen
---
 components/camel-cm-sms/src/main/docs/cm-sms-component.adoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/components/camel-cm-sms/src/main/docs/cm-sms-component.adoc b/components/camel-cm-sms/src/main/docs/cm-sms-component.adoc
index d40ba67..4470bc5 100644
--- a/components/camel-cm-sms/src/main/docs/cm-sms-component.adoc
+++ b/components/camel-cm-sms/src/main/docs/cm-sms-component.adoc
@@ -71,10 +71,10 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *defaultFrom* (producer) | This is the sender name. The maximum length is 11 characters. |  | String)
-| *defaultMaxNumberOfParts* (producer) | If it is a multipart message forces the max number. Message can be truncated. Technically the gateway will first check if a message is larger than 160 characters, if so, the message will be cut into multiple 153 characters parts limited by these parameters. | 8 | Max(8L)::Int)
+| *defaultFrom* (producer) | This is the sender name. The maximum length is 11 characters. |  | String
+| *defaultMaxNumberOfParts* (producer) | If it is a multipart message forces the max number. Message can be truncated. Technically the gateway will first check if a message is larger than 160 characters, if so, the message will be cut into multiple 153 characters parts limited by these parameters. | 8 | Max(8L)Int
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
-| *productToken* (producer) | *Required* The unique token to use |  | String)
+| *productToken* (producer) | *Required* The unique token to use |  | String
 | *testConnectionOnStartup* (producer) | Whether to test the connection to the SMS Gateway on startup | false | boolean
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean


[camel] 08/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8d9f781a7f1f788454c29f8339fd6cbbc8f01e9f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 10:42:46 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../src/main/java/org/apache/camel/maven/GenerateMojo.java     |  9 ++++++++-
 examples/camel-example-main-artemis/pom.xml                    | 10 ++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
index 04d5567..bf80dba 100644
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
+++ b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/GenerateMojo.java
@@ -317,7 +317,14 @@ public class GenerateMojo extends AbstractMainMojo {
                 if ("#skip#".equals(k)) {
                     return null;
                 }
-                Class found = candidates.stream().filter(c -> c.getName().equals(k)).findFirst().orElse(null);
+                // jump to after the leading prefix to have the classname
+                if (k.startsWith("#class:")) {
+                    k = k.substring(7);
+                } else if (k.startsWith("#type:")) {
+                    k = k.substring(6);
+                }
+                final String candiateName = k;
+                Class found = candidates.stream().filter(c -> c.getName().equals(candiateName)).findFirst().orElse(null);
                 if (found != null) {
                     return found;
                 }
diff --git a/examples/camel-example-main-artemis/pom.xml b/examples/camel-example-main-artemis/pom.xml
index f77c46b..f1ea8df 100644
--- a/examples/camel-example-main-artemis/pom.xml
+++ b/examples/camel-example-main-artemis/pom.xml
@@ -39,6 +39,14 @@
 
     <dependencies>
 
+        <!-- to have spring boot tooling support in IDEA you need spring-boot JARs on the classpath -->
+<!--
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+        </dependency>
+-->
+
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-core</artifactId>
@@ -110,6 +118,8 @@
                     <!-- <logUnmapped>true</logUnmapped> -->
                     <!-- just include only the jms component -->
                     <!-- <include>jms</include> -->
+                    <!-- to use spring caching connection factory instead of the default -->
+                    <!-- <mappings>javax.jms.ConnectionFactory=#class:org.springframework.jms.connection.CachingConnectionFactory</mappings> -->
                 </configuration>
                 <executions>
                     <execution>


[camel] 06/08: CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 6f01e564794cef5a3dad6365a86c3c335b2cedc5
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jun 21 09:51:40 2019 +0200

    CAMEL-13663: camel-main-maven-plugin to generte spring-boot tooling metadata to fool Java editors to have code completions for Camel Main application.properties files.
---
 .../java/org/apache/camel/maven/AutowireMojo.java  | 282 ---------------------
 .../apache/camel/maven/SpringBootToolingMojo.java  | 152 -----------
 2 files changed, 434 deletions(-)

diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
deleted file mode 100644
index a742f4a..0000000
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/AutowireMojo.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.maven;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.apache.camel.catalog.CamelCatalog;
-import org.apache.camel.catalog.JSonSchemaHelper;
-import org.apache.camel.maven.model.AutowireData;
-import org.apache.camel.support.PatternHelper;
-import org.apache.camel.util.IOHelper;
-import org.apache.camel.util.OrderedProperties;
-import org.apache.camel.util.StringHelper;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.reflections.Reflections;
-
-/**
- * Pre scans your project and prepare autowiring by classpath scanning
- */
-@Mojo(name = "autowire", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE)
-@Deprecated
-public class AutowireMojo extends AbstractMainMojo {
-
-    /**
-     * When autowiring has detected multiple implementations (2 or more) of a given interface, which
-     * cannot be mapped, should they be logged so you can see and add manual mapping if needed.
-     */
-    @Parameter(property = "camel.logUnmapped", defaultValue = "false")
-    protected boolean logUnmapped;
-
-    /**
-     * The output directory for generated autowire file
-     */
-    @Parameter(readonly = true, defaultValue = "${project.build.directory}/classes/META-INF/services/org/apache/camel/")
-    protected File outFolder;
-
-    /**
-     * To exclude autowiring specific properties with these key names.
-     * You can also configure a single entry and separate the excludes with comma
-     */
-    @Parameter(property = "camel.exclude")
-    protected String[] exclude;
-
-    /**
-     * To include autowiring specific properties or component with these key names.
-     * You can also configure a single entry and separate the includes with comma
-     */
-    @Parameter(property = "camel.include")
-    protected String[] include;
-
-    /**
-     * To setup special mappings between known types as key=value pairs.
-     * You can also configure a single entry and separate the mappings with comma
-     */
-    @Parameter(property = "camel.mappings")
-    protected String[] mappings;
-
-    /**
-     * Optional mappings file loaded from classpath, with mapping that override any default mappings
-     */
-    @Parameter(defaultValue = "${project.build.directory}/classes/camel-main-mappings.properties")
-    protected File mappingsFile;
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        // load default mappings
-        Properties mappingProperties = loadDefaultMappings();
-        getLog().debug("Loaded default-mappings: " + mappingProperties);
-        // add extra mappings
-        if (this.mappings != null) {
-            for (String m : this.mappings) {
-                String key = StringHelper.before(m, "=");
-                String value = StringHelper.after(m, "=");
-                if (key != null && value != null) {
-                    mappingProperties.setProperty(key, value);
-                    getLog().debug("Added mapping from pom.xml: " + key + "=" + value);
-                }
-            }
-        }
-        Properties mappingFileProperties = loadMappingsFile();
-        if (!mappingFileProperties.isEmpty()) {
-            getLog().debug("Loaded mappings file: " + mappingsFile + " with mappings: " + mappingFileProperties);
-            mappingProperties.putAll(mappingFileProperties);
-        }
-
-        final List<AutowireData> autowires = new ArrayList<>();
-        ComponentCallback callback = (componentName, name, type, javaType, description, defaultValue) -> {
-            if ("object".equals(type)) {
-                if (!isValidPropertyName(componentName, name)) {
-                    getLog().debug("Skipping property name: " + name);
-                    return;
-                }
-                try {
-                    Class clazz = classLoader.loadClass(javaType);
-                    if (clazz.isInterface() && isComplexUserType(clazz)) {
-                        Set<Class<?>> classes = reflections.getSubTypesOf(clazz);
-                        // filter classes (must not be interfaces, must be public, must not be abstract, must be top level) and also a valid autowire class
-                        classes = classes.stream().filter(
-                                c -> !c.isInterface()
-                                        && Modifier.isPublic(c.getModifiers())
-                                        && !Modifier.isAbstract(c.getModifiers())
-                                        && c.getEnclosingClass() == null
-                                        && isValidAutowireClass(c))
-                                .collect(Collectors.toSet());
-                        Class best = chooseBestKnownType(componentName, name, clazz, classes, mappingProperties);
-                        if (best != null) {
-                            String key = "camel.component." + componentName + "." + name;
-                            String value = "#class:" + best.getName();
-                            getLog().debug(key + "=" + value);
-                            autowires.add(new AutowireData(key, value));
-
-                            // TODO: get options from best class (getter/setter pairs)
-                            // we dont have documentation
-                            // add as spring boot options
-
-                        }
-                    }
-
-                } catch (Exception e) {
-                    // ignore
-                    getLog().debug("Cannot load class: " + name, e);
-                }
-            }
-        };
-
-        // perform the work with this callback
-        doExecute(callback);
-
-        if (!autowires.isEmpty()) {
-            outFolder.mkdirs();
-            File file = new File(outFolder, "autowire.properties");
-            try {
-                FileOutputStream fos = new FileOutputStream(file, false);
-                fos.write("# Generated by camel build tools\n".getBytes());
-                for (AutowireData data : autowires) {
-                    fos.write(data.getKey().getBytes());
-                    fos.write('=');
-                    fos.write(data.getValue().getBytes());
-                    fos.write('\n');
-                }
-                IOHelper.close(fos);
-                getLog().info("Created file: " + file + " (autowire by classpath: " + autowires.size() + ")");
-            } catch (Throwable e) {
-                throw new MojoFailureException("Cannot write to file " + file + " due " + e.getMessage(), e);
-            }
-        }
-    }
-
-    protected Properties loadDefaultMappings() throws MojoFailureException {
-        Properties mappings = new OrderedProperties();
-        try {
-            InputStream is = AutowireMojo.class.getResourceAsStream("/default-mappings.properties");
-            if (is != null) {
-                mappings.load(is);
-            }
-        } catch (IOException e) {
-            throw new MojoFailureException("Cannot load default-mappings.properties from classpath");
-        }
-        return mappings;
-    }
-
-    protected Properties loadMappingsFile() throws MojoFailureException {
-        Properties mappings = new OrderedProperties();
-        if (mappingsFile.exists() && mappingsFile.isFile()) {
-            try {
-                InputStream is = new FileInputStream(mappingsFile);
-                mappings.load(is);
-            } catch (IOException e) {
-                throw new MojoFailureException("Cannot load file: " + mappingsFile);
-            }
-        }
-        return mappings;
-    }
-
-    protected Class chooseBestKnownType(String componentName, String optionName, Class type, Set<Class<?>> candidates, Properties knownTypes) {
-        String known = knownTypes.getProperty(type.getName());
-        if (known != null) {
-            for (String k : known.split(";")) {
-                // special as we should skip this option
-                if ("#skip#".equals(k)) {
-                    return null;
-                }
-                Class found = candidates.stream().filter(c -> c.getName().equals(k)).findFirst().orElse(null);
-                if (found != null) {
-                    return found;
-                }
-            }
-        }
-
-        if (candidates.size() == 1) {
-            return candidates.iterator().next();
-        } else if (candidates.size() > 1) {
-            if (logUnmapped) {
-                getLog().debug("Cannot chose best type: " + type.getName() + " among " + candidates.size() + " implementations: " + candidates);
-                getLog().info("Cannot autowire option camel.component." + componentName + "." + optionName
-                        + " as the interface: " + type.getName() + " has " + candidates.size() + " implementations in the classpath:");
-                for (Class c : candidates) {
-                    getLog().info("\t\t" + c.getName());
-                }
-            }
-        }
-        return null;
-    }
-
-    protected boolean isValidPropertyName(String componentName, String name) {
-        // we want to regard names as the same if they are using dash or not, and also to be case insensitive.
-        String prefix = "camel.component." + componentName + ".";
-        name = StringHelper.dashToCamelCase(name);
-
-        if (exclude != null && exclude.length > 0) {
-            // works on components too
-            for (String pattern : exclude) {
-                pattern = pattern.trim();
-                pattern = StringHelper.dashToCamelCase(pattern);
-                if (PatternHelper.matchPattern(componentName, pattern)) {
-                    return false;
-                }
-                if (PatternHelper.matchPattern(name, pattern) || PatternHelper.matchPattern(prefix + name, pattern)) {
-                    return false;
-                }
-            }
-        }
-
-        if (include != null && include.length > 0) {
-            for (String pattern : include) {
-                pattern = pattern.trim();
-                pattern = StringHelper.dashToCamelCase(pattern);
-                if (PatternHelper.matchPattern(componentName, pattern)) {
-                    return true;
-                }
-                if (PatternHelper.matchPattern(name, pattern) || PatternHelper.matchPattern(prefix + name, pattern)) {
-                    return true;
-                }
-            }
-            // we have include enabled and none matched so it should be false
-            return false;
-        }
-
-        return true;
-    }
-
-    private static boolean isComplexUserType(Class type) {
-        // lets consider all non java, as complex types
-        return type != null && !type.isPrimitive() && !type.getName().startsWith("java.");
-    }
-
-    protected boolean isValidAutowireClass(Class clazz) {
-        // skip all from Apache Camel and regular JDK as they would be default anyway
-        return !clazz.getName().startsWith("org.apache.camel");
-    }
-
-}
diff --git a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java b/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
deleted file mode 100644
index 9691afc..0000000
--- a/catalog/camel-main-maven-plugin/src/main/java/org/apache/camel/maven/SpringBootToolingMojo.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.maven;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.maven.model.SpringBootData;
-import org.apache.camel.util.IOHelper;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-
-import static org.apache.camel.util.StringHelper.camelCaseToDash;
-
-/**
- * Pre scans your project and builds spring boot tooling metafiles which fools tools to
- * offer code completion for editing properties files.
- */
-@Mojo(name = "spring-boot-tooling", defaultPhase = LifecyclePhase.PROCESS_CLASSES, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE)
-@Deprecated
-public class SpringBootToolingMojo extends AbstractMainMojo {
-
-    /**
-     * The output directory for generated spring boot tooling file
-     */
-    @Parameter(readonly = true, defaultValue = "${project.build.directory}/../src/main/resources/META-INF/")
-    protected File outFolder;
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-
-        final List<SpringBootData> componentData = new ArrayList<>();
-        ComponentCallback callback = (componentName, name, type, javaType, description, defaultValue) -> {
-            // we want to use dash in the name
-            String dash = camelCaseToDash(name);
-            String key = "camel.component." + componentName + "." + dash;
-            componentData.add(new SpringBootData(key, springBootJavaType(javaType), description, defaultValue));
-        };
-
-        // perform the work with this callback
-        doExecute(callback);
-
-        if (!componentData.isEmpty()) {
-            StringBuilder sb = new StringBuilder();
-
-            for (int i = 0; i < componentData.size(); i++) {
-                SpringBootData row = componentData.get(i);
-                sb.append("    {\n");
-                sb.append("      \"name\": \"" + row.getName() + "\",\n");
-                sb.append("      \"type\": \"" + row.getJavaType() + "\",\n");
-                sb.append("      \"description\": \"" + row.getDescription() + "\"");
-                if (row.getDefaultValue() != null) {
-                    sb.append(",\n");
-                    if (springBootDefaultValueQuotes(row.getJavaType())) {
-                        sb.append("      \"defaultValue\": \"" + row.getDefaultValue() + "\"\n");
-                    } else {
-                        sb.append("      \"defaultValue\": " + row.getDefaultValue() + "\n");
-                    }
-                } else {
-                    sb.append("\n");
-                }
-                if (i < componentData.size() - 1) {
-                    sb.append("    },\n");
-                } else {
-                    sb.append("    }\n");
-                }
-            }
-            sb.append("  ]\n");
-            sb.append("}\n");
-
-            // okay then add the components into the main json at the end so they get merged together
-            // load camel-main metadata
-            String mainJson = loadCamelMainConfigurationMetadata();
-            if (mainJson == null) {
-                getLog().warn("Cannot load camel-main-configuration-metadata.json from within the camel-main JAR from the classpath."
-                        + " Not possible to build spring boot configuration file for this project");
-                return;
-            }
-            int pos = mainJson.lastIndexOf("    }");
-            String newJson = mainJson.substring(0, pos);
-            newJson = newJson + "    },\n";
-            newJson = newJson + sb.toString();
-
-            outFolder.mkdirs();
-            File file = new File(outFolder, "spring-configuration-metadata.json");
-            try {
-                FileOutputStream fos = new FileOutputStream(file, false);
-                fos.write(newJson.getBytes());
-                IOHelper.close(fos);
-                getLog().info("Created file: " + file);
-            } catch (Throwable e) {
-                throw new MojoFailureException("Cannot write to file " + file + " due " + e.getMessage(), e);
-            }
-        }
-    }
-    
-    private static String springBootJavaType(String javaType) {
-        if ("boolean".equalsIgnoreCase(javaType)) {
-            return "java.lang.Boolean";
-        } else if ("int".equalsIgnoreCase(javaType)) {
-            return "java.lang.Integer";
-        } else if ("long".equalsIgnoreCase(javaType)) {
-            return "java.lang.Long";
-        } else if ("string".equalsIgnoreCase(javaType)) {
-            return "java.lang.String";
-        }
-        return javaType;
-    }
-
-    private static boolean springBootDefaultValueQuotes(String javaType) {
-        if ("java.lang.Boolean".equalsIgnoreCase(javaType)) {
-            return false;
-        } else if ("java.lang.Integer".equalsIgnoreCase(javaType)) {
-            return false;
-        } else if ("java.lang.Long".equalsIgnoreCase(javaType)) {
-            return false;
-        }
-        return true;
-    }
-
-    protected String loadCamelMainConfigurationMetadata() throws MojoFailureException {
-        try {
-            InputStream is = classLoader.getResourceAsStream("META-INF/camel-main-configuration-metadata.json");
-            String text = IOHelper.loadText(is);
-            IOHelper.close(is);
-            return text;
-        } catch (Throwable e) {
-            throw new MojoFailureException("Error during discovering camel-main from classpath due " + e.getMessage(), e);
-        }
-    }
-}