Repository: camel
Updated Branches:
  refs/heads/master 7aeb3b769 -> 12ddb0fc8


CAMEL-10799: camel-connector - Generate spring boot auto configuration


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

Branch: refs/heads/master
Commit: f897d46870baf9eacf8d32d704f4bfaf13df3fd9
Parents: 7aeb3b7
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Mar 15 20:15:44 2017 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Mar 15 20:33:49 2017 +0100

----------------------------------------------------------------------
 connectors/camel-connector-maven-plugin/pom.xml |  22 +
 .../camel/maven/connector/ConnectorMojo.java    |   2 -
 .../SpringBootAutoConfigurationMojo.java        | 416 +++++++++++++++++++
 .../camel/maven/connector/StringHelper.java     |  27 ++
 .../maven/connector/model/ComponentModel.java   | 201 +++++++++
 .../connector/model/ComponentOptionModel.java   | 146 +++++++
 .../src/main/resources/license-header-java.txt  |  16 +
 .../src/main/resources/license-header.txt       |  16 +
 connectors/camel-connector/pom.xml              |  15 +
 9 files changed, 859 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/connectors/camel-connector-maven-plugin/pom.xml 
b/connectors/camel-connector-maven-plugin/pom.xml
index 524b1be..48a8bc8 100644
--- a/connectors/camel-connector-maven-plugin/pom.xml
+++ b/connectors/camel-connector-maven-plugin/pom.xml
@@ -61,6 +61,28 @@
       <version>${jackson2-version}</version>
     </dependency>
 
+    <!-- roaster to create java source for Spring Boot auto configuration 
support -->
+    <dependency>
+      <groupId>org.jboss.forge.roaster</groupId>
+      <artifactId>roaster-api</artifactId>
+      <version>${roaster-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.forge.roaster</groupId>
+      <artifactId>roaster-jdt</artifactId>
+      <version>${roaster-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot</artifactId>
+      <version>${spring-boot-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-autoconfigure</artifactId>
+      <version>${spring-boot-version}</version>
+    </dependency>
+
     <!-- logging -->
     <dependency>
       <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
index ce089d8..a9958a6 100644
--- 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
+++ 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/ConnectorMojo.java
@@ -268,8 +268,6 @@ public class ConnectorMojo extends AbstractJarMojo {
         Map values = (Map) dto.get("endpointValues");
         Map overrides = (Map) dto.get("endpointOverrides");
 
-        ObjectMapper mapper = new ObjectMapper();
-
         StringBuilder sb = new StringBuilder();
         sb.append("  \"properties\": {\n");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/SpringBootAutoConfigurationMojo.java
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/SpringBootAutoConfigurationMojo.java
 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/SpringBootAutoConfigurationMojo.java
new file mode 100644
index 0000000..a6dbd84
--- /dev/null
+++ 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/SpringBootAutoConfigurationMojo.java
@@ -0,0 +1,416 @@
+/**
+ * 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
+ * <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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.connector;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.camel.maven.connector.model.ComponentModel;
+import org.apache.camel.maven.connector.model.ComponentOptionModel;
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.plugin.AbstractMojo;
+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.jboss.forge.roaster.Roaster;
+import org.jboss.forge.roaster.model.source.AnnotationSource;
+import org.jboss.forge.roaster.model.source.Import;
+import org.jboss.forge.roaster.model.source.JavaClassSource;
+import org.jboss.forge.roaster.model.source.MethodSource;
+import org.jboss.forge.roaster.model.source.PropertySource;
+import org.jboss.forge.roaster.model.util.Formatter;
+import org.jboss.forge.roaster.model.util.Strings;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import 
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import 
org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import static org.apache.camel.maven.connector.FileHelper.loadText;
+import static org.apache.camel.maven.connector.StringHelper.getSafeValue;
+
+/**
+ * Generate Spring Boot auto configuration files for Camel connectors.
+ */
+@Mojo(name = "prepare-spring-boot-auto-configuration",
+    defaultPhase = LifecyclePhase.PACKAGE,
+    requiresProject = true, threadSafe = true)
+public class SpringBootAutoConfigurationMojo extends AbstractMojo {
+
+    @Parameter(defaultValue = "${project.build.outputDirectory}", required = 
true)
+    private File classesDirectory;
+
+    @Parameter(defaultValue = "${basedir}", required = true)
+    private File baseDir;
+
+    @Parameter(defaultValue = "true")
+    private boolean includeLicenseHeader;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        try {
+            executeConnector();
+        } catch (Exception e) {
+            throw new MojoFailureException("Error generating Spring-Boot auto 
configuration for connector", e);
+        }
+    }
+
+    private void executeConnector() throws Exception {
+
+        String javaType = null;
+        String connectorScheme = null;
+
+        File file = new File(classesDirectory, "camel-connector.json");
+        if (file.exists()) {
+            ObjectMapper mapper = new ObjectMapper();
+            Map dto = mapper.readValue(file, Map.class);
+
+            javaType = (String) dto.get("javaType");
+            connectorScheme = (String) dto.get("scheme");
+        }
+
+        // find the component dependency and get its .json file
+        file = new File(classesDirectory, "camel-component-schema.json");
+        if (file.exists() && javaType != null && connectorScheme != null) {
+            String json = loadText(new FileInputStream(file));
+            ComponentModel model = generateComponentModel(json);
+
+            // resolvePropertyPlaceholders is an option which only make sense 
to use if the component has other options
+            boolean hasOptions = 
model.getComponentOptions().stream().anyMatch(o -> 
!o.getName().equals("resolvePropertyPlaceholders"));
+
+            // use springboot as sub package name so the code is not in normal
+            // package so the Spring Boot JARs can be optional at runtime
+            int pos = javaType.lastIndexOf(".");
+            String pkg = javaType.substring(0, pos) + ".springboot";
+
+            getLog().info("Generating Spring Boot AutoConfiguration for 
Connector: " + model.getScheme());
+
+            if (hasOptions) {
+                createConnectorConfigurationSource(pkg, model, javaType, 
connectorScheme);
+            }
+            createConnectorAutoConfigurationSource(pkg, model, hasOptions, 
javaType, connectorScheme);
+            createConnectorSpringFactorySource(pkg, model);
+        } else {
+            getLog().warn("Cannot generate Spring Boot AutoConfiguration as 
camel-component-schema.json file missing");
+        }
+    }
+
+    private void createConnectorSpringFactorySource(String packageName, 
ComponentModel model) throws MojoFailureException {
+        int pos = model.getJavaType().lastIndexOf(".");
+        String name = model.getJavaType().substring(pos + 1);
+        name = name.replace("Component", "ConnectorAutoConfiguration");
+
+        writeComponentSpringFactorySource(packageName, name);
+    }
+
+    private void writeComponentSpringFactorySource(String packageName, String 
name) throws MojoFailureException {
+        StringBuilder sb = new StringBuilder();
+        
sb.append("org.springframework.boot.autoconfigure.EnableAutoConfiguration=\\\n");
+
+        String lineToAdd = packageName + "." + name + "\n";
+        sb.append(lineToAdd);
+
+        String fileName = "src/main/resources/META-INF/spring.factories";
+        File target = new File(baseDir, fileName);
+
+        // create new file
+        try {
+            String header = "";
+            if (includeLicenseHeader) {
+                InputStream is = 
getClass().getClassLoader().getResourceAsStream("license-header.txt");
+                header = loadText(is);
+            }
+            String code = sb.toString();
+            // add empty new line after header
+            code = header + "\n" + code;
+            getLog().debug("Source code generated:\n" + code);
+
+            FileUtils.write(target, code);
+            getLog().info("Created file: " + target);
+        } catch (Exception e) {
+            throw new MojoFailureException("IOError with file " + target, e);
+        }
+    }
+
+    private void createConnectorConfigurationSource(String packageName, 
ComponentModel model, String javaType, String connectorScheme) throws 
MojoFailureException {
+        final JavaClassSource javaClass = 
Roaster.create(JavaClassSource.class);
+
+        int pos = javaType.lastIndexOf(".");
+        String name = javaType.substring(pos + 1);
+        name = name.replace("Component", "ConnectorConfiguration");
+        javaClass.setPackage(packageName).setName(name);
+
+        String doc = "Generated by camel-connector-maven-plugin - do not edit 
this file!";
+        if (!Strings.isBlank(model.getDescription())) {
+            doc = model.getDescription() + "\n\n" + doc;
+        }
+        // replace Component with Connector
+        doc = doc.replaceAll("Component", "Connector");
+        doc = doc.replaceAll("component", "connector");
+        javaClass.getJavaDoc().setFullText(doc);
+
+        String prefix = "camel.connector." + model.getScheme();
+        // make sure prefix is in lower case
+        prefix = connectorScheme.toLowerCase(Locale.US);
+        
javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix",
 prefix);
+
+        for (ComponentOptionModel option : model.getComponentOptions()) {
+            String type = option.getJavaType();
+            PropertySource<JavaClassSource> prop = javaClass.addProperty(type, 
option.getName());
+
+            // TODO: only include the global options so we can configure them
+
+            if ("true".equals(option.getDeprecated())) {
+                prop.getField().addAnnotation(Deprecated.class);
+                prop.getAccessor().addAnnotation(Deprecated.class);
+                prop.getMutator().addAnnotation(Deprecated.class);
+                // DeprecatedConfigurationProperty must be on getter when 
deprecated
+                
prop.getAccessor().addAnnotation(DeprecatedConfigurationProperty.class);
+            }
+            if (!Strings.isBlank(option.getDescription())) {
+                
prop.getField().getJavaDoc().setFullText(option.getDescription());
+            }
+            if (!Strings.isBlank(option.getDefaultValue())) {
+                if ("java.lang.String".equals(option.getJavaType())) {
+                    
prop.getField().setStringInitializer(option.getDefaultValue());
+                } else if ("long".equals(option.getJavaType()) || 
"java.lang.Long".equals(option.getJavaType())) {
+                    // the value should be a Long number
+                    String value = option.getDefaultValue() + "L";
+                    prop.getField().setLiteralInitializer(value);
+                } else if ("integer".equals(option.getType()) || 
"boolean".equals(option.getType())) {
+                    
prop.getField().setLiteralInitializer(option.getDefaultValue());
+                } else if (!Strings.isBlank(option.getEnums())) {
+                    String enumShortName = 
type.substring(type.lastIndexOf(".") + 1);
+                    prop.getField().setLiteralInitializer(enumShortName + "." 
+ option.getDefaultValue());
+                    javaClass.addImport(model.getJavaType());
+                }
+            }
+        }
+
+
+        sortImports(javaClass);
+
+        String fileName = packageName.replaceAll("\\.", "\\/") + "/" + name + 
".java";
+
+        writeSourceIfChanged(javaClass, fileName);
+    }
+
+    private void createConnectorAutoConfigurationSource(String packageName, 
ComponentModel model, boolean hasOptions,
+                                                        String javaType, 
String connectorScheme) throws MojoFailureException {
+
+        final JavaClassSource javaClass = 
Roaster.create(JavaClassSource.class);
+
+        int pos = javaType.lastIndexOf(".");
+        String name = javaType.substring(pos + 1);
+        name = name.replace("Component", "ConnectorAutoConfiguration");
+
+        javaClass.setPackage(packageName).setName(name);
+
+        String doc = "Generated by camel-connector-maven-plugin - do not edit 
this file!";
+        javaClass.getJavaDoc().setFullText(doc);
+
+        javaClass.addAnnotation(Configuration.class);
+        
javaClass.addAnnotation(ConditionalOnBean.class).setStringValue("type", 
"org.apache.camel.spring.boot.CamelAutoConfiguration");
+        
javaClass.addAnnotation(AutoConfigureAfter.class).setStringValue("name", 
"org.apache.camel.spring.boot.CamelAutoConfiguration");
+
+        String configurationName = name.replace("ConnectorAutoConfiguration", 
"ConnectorConfiguration");
+        if (hasOptions) {
+            AnnotationSource<JavaClassSource> ann = 
javaClass.addAnnotation(EnableConfigurationProperties.class);
+            ann.setLiteralValue("value", configurationName + ".class");
+
+            javaClass.addImport("java.util.HashMap");
+            javaClass.addImport("java.util.Map");
+            javaClass.addImport("org.apache.camel.util.IntrospectionSupport");
+        }
+
+        javaClass.addImport(model.getJavaType());
+        javaClass.addImport("org.apache.camel.CamelContext");
+
+        // add method for auto configure
+        String body = createComponentBody(model.getShortJavaType(), 
hasOptions);
+        String methodName = "configure" + model.getShortJavaType();
+
+        MethodSource<JavaClassSource> method = javaClass.addMethod()
+            .setName(methodName)
+            .setPublic()
+            .setBody(body)
+            .setReturnType(model.getShortJavaType())
+            .addThrows(Exception.class);
+
+        method.addParameter("CamelContext", "camelContext");
+
+        if (hasOptions) {
+            method.addParameter(configurationName, "configuration");
+        }
+
+        method.addAnnotation(Bean.class).setStringValue("name", 
connectorScheme.toLowerCase(Locale.US) + "-connector");
+        
method.addAnnotation(ConditionalOnClass.class).setLiteralValue("value", 
"CamelContext.class");
+        
method.addAnnotation(ConditionalOnMissingBean.class).setLiteralValue("value", 
model.getShortJavaType() + ".class");
+
+        sortImports(javaClass);
+
+        String fileName = packageName.replaceAll("\\.", "\\/") + "/" + name + 
".java";
+        writeSourceIfChanged(javaClass, fileName);
+    }
+
+    private void writeSourceIfChanged(JavaClassSource source, String fileName) 
throws MojoFailureException {
+        File target = new File(".", "src/main/java/" + fileName);
+
+        try {
+            String header = "";
+            if (includeLicenseHeader) {
+                InputStream is = 
getClass().getClassLoader().getResourceAsStream("license-header-java.txt");
+                header = loadText(is);
+            }
+            String code = sourceToString(source);
+            code = header + code;
+            getLog().debug("Source code generated:\n" + code);
+
+            if (target.exists()) {
+                String existing = FileUtils.readFileToString(target);
+                if (!code.equals(existing)) {
+                    FileUtils.write(target, code, false);
+                    getLog().info("Updated existing file: " + target);
+                } else {
+                    getLog().debug("No changes to existing file: " + target);
+                }
+            } else {
+                FileUtils.write(target, code);
+                getLog().info("Created file: " + target);
+            }
+        } catch (Exception e) {
+            throw new MojoFailureException("IOError with file " + target, e);
+        }
+    }
+
+    private static String createComponentBody(String shortJavaType, boolean 
hasOptions) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(shortJavaType).append(" connector = new 
").append(shortJavaType).append("();").append("\n");
+        sb.append("connector.setCamelContext(camelContext);\n");
+        sb.append("\n");
+        if (hasOptions) {
+            sb.append("Map<String, Object> parameters = new HashMap<>();\n");
+            sb.append("IntrospectionSupport.getProperties(configuration, 
parameters, null, false);\n");
+            sb.append("IntrospectionSupport.setProperties(camelContext, 
camelContext.getTypeConverter(), connector, parameters);\n");
+        }
+        sb.append("\n");
+        sb.append("return connector;");
+        return sb.toString();
+    }
+
+    private static void sortImports(JavaClassSource javaClass) {
+        // sort imports
+        List<Import> imports = javaClass.getImports();
+
+        // sort imports
+        List<String> names = new ArrayList<>();
+        for (Import imp : imports) {
+            names.add(imp.getQualifiedName());
+        }
+        // sort
+        Collections.sort(names, (s1, s2) -> {
+            // java comes first
+            if (s1.startsWith("java.")) {
+                s1 = "___" + s1;
+            }
+            if (s2.startsWith("java.")) {
+                s2 = "___" + s2;
+            }
+            // then javax comes next
+            if (s1.startsWith("javax.")) {
+                s1 = "__" + s1;
+            }
+            if (s2.startsWith("javax.")) {
+                s2 = "__" + s2;
+            }
+            // org.w3c is for some odd reason also before others
+            if (s1.startsWith("org.w3c.")) {
+                s1 = "_" + s1;
+            }
+            if (s2.startsWith("org.w3c.")) {
+                s2 = "_" + s2;
+            }
+            return s1.compareTo(s2);
+        });
+
+        // remove all imports first
+        for (String name : names) {
+            javaClass.removeImport(name);
+        }
+        // and add them back in correct order
+        for (String name : names) {
+            javaClass.addImport(name);
+        }
+    }
+
+    private static String sourceToString(JavaClassSource javaClass) {
+        String code = Formatter.format(javaClass);
+        // convert tabs to 4 spaces
+        code = code.replaceAll("\\t", "    ");
+        return code;
+    }
+
+    private static ComponentModel generateComponentModel(String json) {
+        List<Map<String, String>> rows = 
JSonSchemaHelper.parseJsonSchema("component", json, false);
+
+        ComponentModel component = new ComponentModel(true);
+        component.setScheme(getSafeValue("scheme", rows));
+        component.setSyntax(getSafeValue("syntax", rows));
+        component.setAlternativeSyntax(getSafeValue("alternativeSyntax", 
rows));
+        component.setTitle(getSafeValue("title", rows));
+        component.setDescription(getSafeValue("description", rows));
+        component.setFirstVersion(getSafeValue("firstVersion", rows));
+        component.setLabel(getSafeValue("label", rows));
+        component.setDeprecated(getSafeValue("deprecated", rows));
+        component.setConsumerOnly(getSafeValue("consumerOnly", rows));
+        component.setProducerOnly(getSafeValue("producerOnly", rows));
+        component.setJavaType(getSafeValue("javaType", rows));
+        component.setGroupId(getSafeValue("groupId", rows));
+        component.setArtifactId(getSafeValue("artifactId", rows));
+        component.setVersion(getSafeValue("version", rows));
+
+        rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, 
true);
+        for (Map<String, String> row : rows) {
+            ComponentOptionModel option = new ComponentOptionModel();
+            option.setName(getSafeValue("name", row));
+            option.setDisplayName(getSafeValue("displayName", row));
+            option.setKind(getSafeValue("kind", row));
+            option.setType(getSafeValue("type", row));
+            option.setJavaType(getSafeValue("javaType", row));
+            option.setDeprecated(getSafeValue("deprecated", row));
+            option.setDescription(getSafeValue("description", row));
+            option.setDefaultValue(getSafeValue("defaultValue", row));
+            option.setEnums(getSafeValue("enum", row));
+            component.addComponentOption(option);
+        }
+
+        return component;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/StringHelper.java
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/StringHelper.java
 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/StringHelper.java
index b69de06..556cc59 100644
--- 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/StringHelper.java
+++ 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/StringHelper.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.maven.connector;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * Utility methods for String.
  */
@@ -172,4 +175,28 @@ public final class StringHelper {
         return sb.toString().trim();
     }
 
+    /**
+     * Gets the value with the key in a safe way, eg returning an empty string 
if there was no value for the key.
+     */
+    public static String getSafeValue(String key, List<Map<String, String>> 
rows) {
+        for (Map<String, String> row : rows) {
+            String value = row.get(key);
+            if (value != null) {
+                return value;
+            }
+        }
+        return "";
+    }
+
+    /**
+     * Gets the value with the key in a safe way, eg returning an empty string 
if there was no value for the key.
+     */
+    public static String getSafeValue(String key, Map<String, String> rows) {
+        String value = rows.get(key);
+        if (value != null) {
+            return value;
+        }
+        return "";
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentModel.java
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentModel.java
 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentModel.java
new file mode 100644
index 0000000..126ffb2
--- /dev/null
+++ 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentModel.java
@@ -0,0 +1,201 @@
+/**
+ * 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
+ * <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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.connector.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ComponentModel {
+
+    private final boolean coreOnly;
+
+    private String kind;
+    private String scheme;
+    private String syntax;
+    private String alternativeSyntax;
+    private String alternativeSchemes;
+    private String title;
+    private String description;
+    private String firstVersion;
+    private String label;
+    private String deprecated;
+    private String consumerOnly;
+    private String producerOnly;
+    private String javaType;
+    private String groupId;
+    private String artifactId;
+    private String version;
+    private final List<ComponentOptionModel> componentOptions = new 
ArrayList<ComponentOptionModel>();
+
+    public ComponentModel(boolean coreOnly) {
+        this.coreOnly = coreOnly;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getScheme() {
+        return scheme;
+    }
+
+    public void setScheme(String scheme) {
+        this.scheme = scheme;
+    }
+
+    public String getSyntax() {
+        return syntax;
+    }
+
+    public void setSyntax(String syntax) {
+        this.syntax = syntax;
+    }
+
+    public String getAlternativeSyntax() {
+        return alternativeSyntax;
+    }
+
+    public void setAlternativeSyntax(String alternativeSyntax) {
+        this.alternativeSyntax = alternativeSyntax;
+    }
+
+    public String getAlternativeSchemes() {
+        return alternativeSchemes;
+    }
+
+    public void setAlternativeSchemes(String alternativeSchemes) {
+        this.alternativeSchemes = alternativeSchemes;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getFirstVersion() {
+        return firstVersion;
+    }
+
+    public void setFirstVersion(String firstVersion) {
+        this.firstVersion = firstVersion;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    public void setLabel(String label) {
+        this.label = label;
+    }
+
+    public String getDeprecated() {
+        return deprecated;
+    }
+
+    public void setDeprecated(String deprecated) {
+        this.deprecated = deprecated;
+    }
+
+    public String getConsumerOnly() {
+        return consumerOnly;
+    }
+
+    public void setConsumerOnly(String consumerOnly) {
+        this.consumerOnly = consumerOnly;
+    }
+
+    public String getProducerOnly() {
+        return producerOnly;
+    }
+
+    public void setProducerOnly(String producerOnly) {
+        this.producerOnly = producerOnly;
+    }
+
+    public String getJavaType() {
+        return javaType;
+    }
+
+    public void setJavaType(String javaType) {
+        this.javaType = javaType;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId() {
+        return artifactId;
+    }
+
+    public void setArtifactId(String artifactId) {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public List<ComponentOptionModel> getComponentOptions() {
+        return componentOptions;
+    }
+
+    public void addComponentOption(ComponentOptionModel option) {
+        componentOptions.add(option);
+    }
+
+    public String getShortJavaType() {
+        if (javaType.startsWith("java.util.Map")) {
+            return "Map";
+        } else if (javaType.startsWith("java.util.Set")) {
+            return "Set";
+        } else if (javaType.startsWith("java.util.List")) {
+            return "List";
+        }
+        int pos = javaType.lastIndexOf(".");
+        if (pos != -1) {
+            return javaType.substring(pos + 1);
+        } else {
+            return javaType;
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentOptionModel.java
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentOptionModel.java
 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentOptionModel.java
new file mode 100644
index 0000000..2a717ab
--- /dev/null
+++ 
b/connectors/camel-connector-maven-plugin/src/main/java/org/apache/camel/maven/connector/model/ComponentOptionModel.java
@@ -0,0 +1,146 @@
+/**
+ * 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
+ * <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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven.connector.model;
+
+public class ComponentOptionModel {
+
+    private String name;
+    private String displayName;
+    private String kind;
+    private String group;
+    private String required;
+    private String type;
+    private String javaType;
+    private String deprecated;
+    private String secret;
+    private String description;
+    private String defaultValue;
+    private String enums;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDisplayName() {
+        return displayName;
+    }
+
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public void setGroup(String group) {
+        this.group = group;
+    }
+
+    public String getRequired() {
+        return required;
+    }
+
+    public void setRequired(String required) {
+        this.required = required;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getJavaType() {
+        return javaType;
+    }
+
+    public void setJavaType(String javaType) {
+        this.javaType = javaType;
+    }
+
+    public String getDeprecated() {
+        return deprecated;
+    }
+
+    public void setDeprecated(String deprecated) {
+        this.deprecated = deprecated;
+    }
+
+    public String getSecret() {
+        return secret;
+    }
+
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
+
+    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;
+    }
+
+    public String getEnums() {
+        return enums;
+    }
+
+    public void setEnums(String enums) {
+        this.enums = enums;
+    }
+
+    public String getShortJavaType() {
+        if (javaType.startsWith("java.util.Map")) {
+            return "Map";
+        } else if (javaType.startsWith("java.util.Set")) {
+            return "Set";
+        } else if (javaType.startsWith("java.util.List")) {
+            return "List";
+        }
+        int pos = javaType.lastIndexOf(".");
+        if (pos != -1) {
+            return javaType.substring(pos + 1);
+        } else {
+            return javaType;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/resources/license-header-java.txt
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/resources/license-header-java.txt
 
b/connectors/camel-connector-maven-plugin/src/main/resources/license-header-java.txt
new file mode 100644
index 0000000..0f49ea9
--- /dev/null
+++ 
b/connectors/camel-connector-maven-plugin/src/main/resources/license-header-java.txt
@@ -0,0 +1,16 @@
+/**
+ * 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.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector-maven-plugin/src/main/resources/license-header.txt
----------------------------------------------------------------------
diff --git 
a/connectors/camel-connector-maven-plugin/src/main/resources/license-header.txt 
b/connectors/camel-connector-maven-plugin/src/main/resources/license-header.txt
new file mode 100644
index 0000000..12bdf0d
--- /dev/null
+++ 
b/connectors/camel-connector-maven-plugin/src/main/resources/license-header.txt
@@ -0,0 +1,16 @@
+#
+# 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.
+#

http://git-wip-us.apache.org/repos/asf/camel/blob/f897d468/connectors/camel-connector/pom.xml
----------------------------------------------------------------------
diff --git a/connectors/camel-connector/pom.xml 
b/connectors/camel-connector/pom.xml
index 6f99578..e709823 100644
--- a/connectors/camel-connector/pom.xml
+++ b/connectors/camel-connector/pom.xml
@@ -35,6 +35,8 @@
   </properties>
 
   <dependencies>
+
+    <!-- camel -->
     <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core</artifactId>
@@ -43,6 +45,19 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-catalog</artifactId>
     </dependency>
+
+    <!-- to support spring-boot auto configuration in the connectors -->
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot</artifactId>
+      <version>${spring-boot-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-autoconfigure</artifactId>
+      <version>${spring-boot-version}</version>
+    </dependency>
+
   </dependencies>
 
 </project>

Reply via email to