camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] camel git commit: CAMEL-10209: spring boot - Auto configuration for languages
Date Mon, 01 Aug 2016 08:16:22 GMT
CAMEL-10209: spring boot - Auto configuration for languages


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

Branch: refs/heads/master
Commit: a7dedd648ed74550871c11e273123182ceb9237b
Parents: 077a15d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Aug 1 08:46:49 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Aug 1 10:16:12 2016 +0200

----------------------------------------------------------------------
 .../SpringBootAutoConfigurationMojo.java        | 391 ++++++++++++++++++-
 .../maven/packaging/model/LanguageModel.java    | 148 +++++++
 .../packaging/model/LanguageOptionModel.java    | 110 ++++++
 3 files changed, 648 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a7dedd64/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
index bea7101..85cd583 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
@@ -35,6 +35,8 @@ import org.apache.camel.maven.packaging.model.ComponentOptionModel;
 import org.apache.camel.maven.packaging.model.DataFormatModel;
 import org.apache.camel.maven.packaging.model.DataFormatOptionModel;
 import org.apache.camel.maven.packaging.model.EndpointOptionModel;
+import org.apache.camel.maven.packaging.model.LanguageModel;
+import org.apache.camel.maven.packaging.model.LanguageOptionModel;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.AbstractMojo;
@@ -109,6 +111,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
     public void execute() throws MojoExecutionException, MojoFailureException {
         executeComponent();
         executeDataFormat();
+        executeLanguage();
     }
 
     private void executeComponent() throws MojoExecutionException, MojoFailureException {
@@ -168,7 +171,7 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         // we can reuse the component model filter
         PackageHelper.findJsonFiles(buildDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
 
-        // create auto configuration for the components
+        // create auto configuration for the data formats
         if (!dataFormatNames.isEmpty()) {
             getLog().debug("Found " + dataFormatNames.size() + " dataformats");
 
@@ -210,6 +213,56 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         }
     }
 
+    private void executeLanguage() throws MojoExecutionException, MojoFailureException {
+        // find the language names
+        List<String> languageNames = findLanguageNames();
+
+        final Set<File> jsonFiles = new TreeSet<File>();
+        // we can reuse the component model filter
+        PackageHelper.findJsonFiles(buildDir, jsonFiles, new PackageHelper.CamelComponentsModelFilter());
+
+        // create auto configuration for the languages
+        if (!languageNames.isEmpty()) {
+            getLog().debug("Found " + languageNames.size() + " languages");
+
+            List<LanguageModel> allModels = new LinkedList<>();
+            for (String languageName : languageNames) {
+                String json = loadLanguageJson(jsonFiles, languageName);
+                if (json != null) {
+                    LanguageModel model = generateLanguageModel(languageName, json);
+                    allModels.add(model);
+                }
+            }
+
+            // Group the models by implementing classes
+            Map<String, List<LanguageModel>> grModels = allModels.stream().collect(Collectors.groupingBy(m
-> m.getJavaType()));
+            for (String languageClass : grModels.keySet()) {
+                List<LanguageModel> dfModels = grModels.get(languageClass);
+                LanguageModel model = dfModels.get(0); // They should be equivalent
+                List<String> aliases = dfModels.stream().map(m -> m.getName()).sorted().collect(Collectors.toList());
+
+                // only create source code if the language has options that can be used in
auto configuration
+                if (!model.getLanguageOptions().isEmpty()) {
+
+                    // use springboot as sub package name so the code is not in normal
+                    // package so the Spring Boot JARs can be optional at runtime
+                    int pos = model.getJavaType().lastIndexOf(".");
+                    String pkg = model.getJavaType().substring(0, pos) + ".springboot";
+
+                    String overrideLanguageName = null;
+                    if (aliases.size() > 1) {
+                        // determine component name when there are multiple ones
+                        overrideLanguageName = model.getArtifactId().replace("camel-", "");
+                    }
+
+                    createLanguageConfigurationSource(pkg, model, overrideLanguageName);
+                    createLanguageAutoConfigurationSource(pkg, model, aliases);
+                    createLanguageSpringFactorySource(pkg, model);
+                }
+            }
+        }
+    }
+
     private void createComponentConfigurationSource(String packageName, ComponentModel model,
String overrideComponentName) throws MojoFailureException {
         final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
 
@@ -396,6 +449,101 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         }
     }
 
+    private void createLanguageConfigurationSource(String packageName, LanguageModel model,
String overrideLanguageName) throws MojoFailureException {
+        final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
+
+        int pos = model.getJavaType().lastIndexOf(".");
+        String name = model.getJavaType().substring(pos + 1);
+        name = name.replace("Language", "LanguageConfiguration");
+        javaClass.setPackage(packageName).setName(name);
+
+        String doc = "Generated by camel-package-maven-plugin - do not edit this file!";
+        if (!Strings.isBlank(model.getDescription())) {
+            doc = model.getDescription() + "\n\n" + doc;
+        }
+        javaClass.getJavaDoc().setFullText(doc);
+
+        String prefix = "camel.language." + (overrideLanguageName != null ? overrideLanguageName
: model.getName());
+        // make sure prefix is in lower case
+        prefix = prefix.toLowerCase(Locale.US);
+        javaClass.addAnnotation("org.springframework.boot.context.properties.ConfigurationProperties").setStringValue("prefix",
prefix);
+
+        for (LanguageOptionModel option : model.getLanguageOptions()) {
+            // skip option with name id, expression, or resultType in language as we do not
need that
+            if ("id".equals(option.getName()) || "expression".equals(option.getName()) ||
"resultType".equals(option.getName())) {
+                continue;
+            }
+            // remove <?> as generic type as Roaster (Eclipse JDT) cannot use that
+            String type = option.getJavaType();
+            type = type.replaceAll("\\<\\?\\>", "");
+            // use wrapper types for primitive types so a null mean that the option has not
been configured
+            if ("boolean".equals(type)) {
+                type = "java.lang.Boolean";
+            } else if ("int".equals(type) || "integer".equals(type)) {
+                type = "java.lang.Integer";
+            } else if ("byte".equals(type)) {
+                type = "java.lang.Byte";
+            } else if ("short".equals(type)) {
+                type = "java.lang.Short";
+            } else if ("double".equals(type)) {
+                type = "java.lang.Double";
+            } else if ("float".equals(type)) {
+                type = "java.lang.Float";
+            }
+
+            PropertySource<JavaClassSource> prop = javaClass.addProperty(type, option.getName());
+            if ("true".equals(option.getDeprecated())) {
+                prop.getField().addAnnotation(Deprecated.class);
+                prop.getAccessor().addAnnotation(Deprecated.class);
+                prop.getMutator().addAnnotation(Deprecated.class);
+                // DeprecatedConfigurationProperty must be on getter when deprecated
+                prop.getAccessor().addAnnotation(DeprecatedConfigurationProperty.class);
+            }
+            if (!Strings.isBlank(option.getDescription())) {
+                prop.getField().getJavaDoc().setFullText(option.getDescription());
+            }
+            if (!Strings.isBlank(option.getDefaultValue())) {
+                if ("java.lang.String".equals(option.getType())) {
+                    prop.getField().setStringInitializer(option.getDefaultValue());
+                } else if ("integer".equals(option.getType()) || "boolean".equals(option.getType()))
{
+                    prop.getField().setLiteralInitializer(option.getDefaultValue());
+                } else if (!Strings.isBlank(option.getEnumValues())) {
+                    String enumShortName = type.substring(type.lastIndexOf(".") + 1);
+                    prop.getField().setLiteralInitializer(enumShortName + "." + option.getDefaultValue());
+                    javaClass.addImport(model.getJavaType());
+                }
+            }
+        }
+
+        sortImports(javaClass);
+
+        String fileName = packageName.replaceAll("\\.", "\\/") + "/" + name + ".java";
+        File target = new File(srcDir, fileName);
+
+        try {
+            InputStream is = getClass().getClassLoader().getResourceAsStream("license-header-java.txt");
+            String header = loadText(is);
+            String code = sourceToString(javaClass);
+            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 void createComponentAutoConfigurationSource(String packageName, ComponentModel
model, List<String> componentAliases) throws MojoFailureException {
         final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
 
@@ -515,7 +663,83 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         String[] springBeanAliases = dataFormatAliases.stream().map(alias -> alias + "-dataformat").toArray(size
-> new String[size]);
 
         method.addAnnotation(Bean.class).setStringArrayValue("name", springBeanAliases);
+        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";
+        File target = new File(srcDir, fileName);
+
+        try {
+            InputStream is = getClass().getClassLoader().getResourceAsStream("license-header-java.txt");
+            String header = loadText(is);
+            String code = sourceToString(javaClass);
+            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 void createLanguageAutoConfigurationSource(String packageName, LanguageModel
model, List<String> languageAliases) throws MojoFailureException {
+        final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
+
+        int pos = model.getJavaType().lastIndexOf(".");
+        String name = model.getJavaType().substring(pos + 1);
+        name = name.replace("Language", "LanguageAutoConfiguration");
+        javaClass.setPackage(packageName).setName(name);
+
+        String doc = "Generated by camel-package-maven-plugin - do not edit this file!";
+        javaClass.getJavaDoc().setFullText(doc);
+
+        javaClass.addAnnotation(Configuration.class);
+
+        String configurationName = name.replace("LanguageAutoConfiguration", "LanguageConfiguration");
+        AnnotationSource<JavaClassSource> ann = javaClass.addAnnotation(EnableConfigurationProperties.class);
+        ann.setLiteralValue("value", configurationName + ".class");
+
+        // add method for auto configure
 
+        javaClass.addImport("java.util.HashMap");
+        javaClass.addImport("java.util.Map");
+        javaClass.addImport(model.getJavaType());
+        javaClass.addImport("org.apache.camel.CamelContext");
+        javaClass.addImport("org.apache.camel.CamelContextAware");
+        javaClass.addImport("org.apache.camel.util.IntrospectionSupport");
+
+        String body = createLanguageBody(model.getShortJavaType());
+        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");
+        method.addParameter(configurationName, "configuration");
+
+
+        // Determine all the aliases
+        // adding the '-language' suffix to prevent collision with component names
+        String[] springBeanAliases = languageAliases.stream().map(alias -> alias + "-language").toArray(size
-> new String[size]);
+
+        method.addAnnotation(Bean.class).setStringArrayValue("name", springBeanAliases);
         method.addAnnotation(ConditionalOnClass.class).setLiteralValue("value", "CamelContext.class");
         method.addAnnotation(ConditionalOnMissingBean.class).setLiteralValue("value", model.getShortJavaType()
+ ".class");
 
@@ -692,6 +916,78 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         }
     }
 
+    private void createLanguageSpringFactorySource(String packageName, LanguageModel model)
throws MojoFailureException {
+        StringBuilder sb = new StringBuilder();
+        sb.append("org.springframework.boot.autoconfigure.EnableAutoConfiguration=\\\n");
+
+        int pos = model.getJavaType().lastIndexOf(".");
+        String name = model.getJavaType().substring(pos + 1);
+        name = name.replace("Language", "LanguageAutoConfiguration");
+        String lineToAdd = packageName + "." + name + "\n";
+        sb.append(lineToAdd);
+
+        String fileName = "META-INF/spring.factories";
+        File target = new File(resourcesDir, fileName);
+
+        if (target.exists()) {
+            try {
+                // is the auto configuration already in the file
+                boolean found = false;
+                List<String> lines = FileUtils.readLines(target);
+                for (String line : lines) {
+                    if (line.contains(name)) {
+                        found = true;
+                        break;
+                    }
+                }
+
+                if (found) {
+                    getLog().debug("No changes to existing file: " + target);
+                } else {
+                    // find last non empty line, so we can add our new line after that
+                    int lastLine = 0;
+                    for (int i = lines.size() - 1; i >= 0; i--) {
+                        String line = lines.get(i);
+                        if (!line.trim().isEmpty()) {
+                            // adjust existing line so its being continued
+                            line = line + ",\\";
+                            lines.set(i, line);
+                            lastLine = i;
+                            break;
+                        }
+                    }
+                    lines.add(lastLine + 1, lineToAdd);
+
+                    StringBuilder code = new StringBuilder();
+                    for (String line : lines) {
+                        code.append(line).append("\n");
+                    }
+
+                    // update
+                    FileUtils.write(target, code.toString(), false);
+                    getLog().info("Updated existing file: " + target);
+                }
+            } catch (Exception e) {
+                throw new MojoFailureException("IOError with file " + target, e);
+            }
+        } else {
+            // create new file
+            try {
+                InputStream is = getClass().getClassLoader().getResourceAsStream("license-header.txt");
+                String 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 static String createComponentBody(String shortJavaType) {
         StringBuilder sb = new StringBuilder();
         sb.append(shortJavaType).append(" component = new ").append(shortJavaType).append("();").append("\n");
@@ -722,6 +1018,22 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         return sb.toString();
     }
 
+    private static String createLanguageBody(String shortJavaType) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(shortJavaType).append(" language = new ").append(shortJavaType).append("();").append("\n");
+        sb.append("if (language instanceof CamelContextAware) {\n");
+        sb.append("    ((CamelContextAware) language).setCamelContext(camelContext);\n");
+        sb.append("}\n");
+        sb.append("\n");
+        sb.append("Map<String, Object> parameters = new HashMap<>();\n");
+        sb.append("IntrospectionSupport.getProperties(configuration, parameters, null, false);\n");
+        sb.append("\n");
+        sb.append("IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(),
language, parameters);\n");
+        sb.append("\n");
+        sb.append("return language;");
+        return sb.toString();
+    }
+
     private static void sortImports(JavaClassSource javaClass) {
         // sort imports
         List<Import> imports = javaClass.getImports();
@@ -808,6 +1120,23 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         return null;
     }
 
+    private static String loadLanguageJson(Set<File> jsonFiles, String languageName)
{
+        try {
+            for (File file : jsonFiles) {
+                if (file.getName().equals(languageName + ".json")) {
+                    String json = loadText(new FileInputStream(file));
+                    boolean isLanguage = json.contains("\"kind\": \"language\"");
+                    if (isLanguage) {
+                        return json;
+                    }
+                }
+            }
+        } catch (IOException e) {
+            // ignore
+        }
+        return null;
+    }
+
     private static ComponentModel generateComponentModel(String componentName, String json)
{
         List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("component",
json, false);
 
@@ -894,6 +1223,38 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         return dataFormat;
     }
 
+    private static LanguageModel generateLanguageModel(String languageName, String json)
{
+        List<Map<String, String>> rows = JSonSchemaHelper.parseJsonSchema("language",
json, false);
+
+        LanguageModel dataFormat = new LanguageModel();
+        dataFormat.setTitle(getSafeValue("title", rows));
+        dataFormat.setName(getSafeValue("name", rows));
+        dataFormat.setModelName(getSafeValue("modelName", rows));
+        dataFormat.setDescription(getSafeValue("description", rows));
+        dataFormat.setLabel(getSafeValue("label", rows));
+        dataFormat.setDeprecated(getSafeValue("deprecated", rows));
+        dataFormat.setJavaType(getSafeValue("javaType", rows));
+        dataFormat.setGroupId(getSafeValue("groupId", rows));
+        dataFormat.setArtifactId(getSafeValue("artifactId", rows));
+        dataFormat.setVersion(getSafeValue("version", rows));
+
+        rows = JSonSchemaHelper.parseJsonSchema("properties", json, true);
+        for (Map<String, String> row : rows) {
+            LanguageOptionModel option = new LanguageOptionModel();
+            option.setName(getSafeValue("name", 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.setEnumValues(getSafeValue("enum", row));
+            dataFormat.addLanguageOption(option);
+        }
+
+        return dataFormat;
+    }
+
     private List<String> findComponentNames() {
         List<String> componentNames = new ArrayList<String>();
         for (Resource r : project.getBuild().getResources()) {
@@ -950,4 +1311,32 @@ public class SpringBootAutoConfigurationMojo extends AbstractMojo {
         return dataFormatNames;
     }
 
+    private List<String> findLanguageNames() {
+        List<String> languageNames = new ArrayList<String>();
+        for (Resource r : project.getBuild().getResources()) {
+            File f = new File(r.getDirectory());
+            if (!f.exists()) {
+                f = new File(project.getBasedir(), r.getDirectory());
+            }
+            f = new File(f, "META-INF/services/org/apache/camel/language");
+
+            if (f.exists() && f.isDirectory()) {
+                File[] files = f.listFiles();
+                if (files != null) {
+                    for (File file : files) {
+                        // skip directories as there may be a sub .resolver directory
+                        if (file.isDirectory()) {
+                            continue;
+                        }
+                        String name = file.getName();
+                        if (name.charAt(0) != '.') {
+                            languageNames.add(name);
+                        }
+                    }
+                }
+            }
+        }
+        return languageNames;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a7dedd64/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageModel.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageModel.java
new file mode 100644
index 0000000..851e5f4
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageModel.java
@@ -0,0 +1,148 @@
+/**
+ * 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.packaging.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class LanguageModel {
+
+    private String kind;
+    private String name;
+    private String modelName;
+    private String title;
+    private String description;
+    private String label;
+    private String deprecated;
+    private String javaType;
+    private String groupId;
+    private String artifactId;
+    private String version;
+    private final List<LanguageOptionModel> languageOptions = new ArrayList<LanguageOptionModel>();
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getModelName() {
+        return modelName;
+    }
+
+    public void setModelName(String modelName) {
+        this.modelName = modelName;
+    }
+
+    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 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 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<LanguageOptionModel> getLanguageOptions() {
+        return languageOptions;
+    }
+
+    public void addLanguageOption(LanguageOptionModel option) {
+        languageOptions.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/a7dedd64/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageOptionModel.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageOptionModel.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageOptionModel.java
new file mode 100644
index 0000000..90e1a81
--- /dev/null
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/model/LanguageOptionModel.java
@@ -0,0 +1,110 @@
+/**
+ * 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.packaging.model;
+
+public class LanguageOptionModel {
+
+    private String name;
+    private String kind;
+    private String type;
+    private String javaType;
+    private String deprecated;
+    private String description;
+    private String defaultValue;
+    private String enumValues;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    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 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 getEnumValues() {
+        return enumValues;
+    }
+
+    public void setEnumValues(String enumValues) {
+        this.enumValues = enumValues;
+    }
+
+    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;
+        }
+    }
+
+}


Mime
View raw message