You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2014/06/10 21:51:29 UTC

[01/35] git commit: Removed redundant test class

Repository: camel
Updated Branches:
  refs/heads/master c59a0ff4f -> 0c9fbb62b


Removed redundant test class


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

Branch: refs/heads/master
Commit: cd89e14c2fc47e0bc3bc43e9269158f5c33d1528
Parents: 7c1a35f
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 23 18:38:10 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:29 2014 -0700

----------------------------------------------------------------------
 .../apache/camel/maven/TestProxyApiMethod.java  | 48 --------------------
 1 file changed, 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/cd89e14c/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java
deleted file mode 100644
index 2a5bee2..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Camel ApiMethod Enumeration generated by camel-component-util-maven-plugin
- * Generated on: Fri May 23 17:35:21 PDT 2014
- */
-package org.apache.camel.maven;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import org.apache.camel.maven.TestProxy;
-
-import org.apache.camel.util.component.ApiMethod;
-import org.apache.camel.util.component.ApiMethodImpl;
-
-/**
- * Camel {@link ApiMethod} Enumeration for org.apache.camel.maven.TestProxy
- */
-public enum TestProxyApiMethod implements ApiMethod {
-
-    GREETALL(java.lang.String.class, "greetAll", new java.lang.String[0].getClass(), "names"),
-    GREETALL_1(java.lang.String.class, "greetAll", java.util.List.class, "namesList"),
-    GREETME(java.lang.String.class, "greetMe", java.lang.String.class, "name"),
-    GREETTIMES(new java.lang.String[0].getClass(), "greetTimes", java.lang.String.class, "name", int.class, "times"),
-    GREETUS(java.lang.String.class, "greetUs", java.lang.String.class, "name1", java.lang.String.class, "name2"),
-    SAYHI(java.lang.String.class, "sayHi"),
-    SAYHI_1(java.lang.String.class, "sayHi", java.lang.String.class, "name");
-
-    private final ApiMethod apiMethod;
-
-    private TestProxyApiMethod(Class<?> resultType, String name, Object... args) {
-        this.apiMethod = new ApiMethodImpl(TestProxy.class, resultType, name, args);
-    }
-
-    @Override
-    public String getName() { return apiMethod.getName(); }
-
-    @Override
-    public Class<?> getResultType() { return apiMethod.getResultType(); }
-
-    @Override
-    public List<String> getArgNames() { return apiMethod.getArgNames(); }
-
-    @Override
-    public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); }
-
-    @Override
-    public Method getMethod() { return apiMethod.getMethod(); }
-}


[28/35] git commit: Fixed endpoint configuration, added component default ctor

Posted by dh...@apache.org.
Fixed endpoint configuration, added component default ctor


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

Branch: refs/heads/master
Commit: d35d71fc6480deb73395c22cc327b739795fedb6
Parents: b79eb69
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 19:05:45 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:34 2014 -0700

----------------------------------------------------------------------
 .../__artifactId__-component/pom.xml                |  8 ++++++++
 .../src/main/java/__name__Component.java            | 16 +++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d35d71fc/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index af32397..2490084 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -70,6 +70,14 @@
       <scope>test</scope>
     </dependency>
 
+    <!-- Camel annotations in provided scope to avoid compile errors in IDEs -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>spi-annotations</artifactId>
+      <version>${camel-version}</version>
+      <scope>provided</scope>
+    </dependency>
+
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/d35d71fc/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
index 7226fef..d249203 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
@@ -41,12 +41,12 @@ public class ${name}Component extends UriEndpointComponent {
 
     private final ${name}ApiCollection collection = ${name}ApiCollection.getCollection();
 
-    public ${name}Component(Class<? extends Endpoint> endpointClass) {
-        super(endpointClass);
+    public ${name}Component() {
+        super(${name}Endpoint.class);
     }
 
-    public ${name}Component(CamelContext context, Class<? extends Endpoint> endpointClass) {
-        super(context, endpointClass);
+    public ${name}Component(CamelContext context) {
+        super(context, ${name}Endpoint.class);
     }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
@@ -81,12 +81,18 @@ public class ${name}Component extends UriEndpointComponent {
 
         // set endpoint property inBody
         setProperties(endpoint, parameters);
+
+        // configure endpoint properties and initialize state
+        endpoint.configureProperties(parameters);
+
         return endpoint;
     }
 
     private ${name}Configuration createEndpointConfiguration(${name}ApiName name) throws Exception {
         final Map<String, Object> componentProperties = new HashMap<String, Object>();
-        IntrospectionSupport.getProperties(configuration, componentProperties, null, false);
+        if (configuration != null) {
+            IntrospectionSupport.getProperties(configuration, componentProperties, null, false);
+        }
 
         // create endpoint configuration with component properties
         final ${name}Configuration endpointConfiguration = collection.getEndpointConfiguration(name);


[31/35] git commit: Fixed error message on invalid endpoint URI

Posted by dh...@apache.org.
Fixed error message on invalid endpoint URI


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

Branch: refs/heads/master
Commit: 4b079790b03ee702bf04ef07c0e8367a1fbbc46e
Parents: e309bf8
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Thu Jun 5 11:59:00 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:35 2014 -0700

----------------------------------------------------------------------
 .../__artifactId__-component/src/main/java/__name__Component.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4b079790/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
index d249203..6694b4e 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
@@ -72,7 +72,7 @@ public class ${name}Component extends UriEndpointComponent {
         try {
             apiName = ${name}ApiName.fromValue(apiNameStr);
         } catch (IllegalArgumentException e) {
-            throw new CamelException("Invalid URI path [" + apiNameStr +
+            throw new CamelException("Invalid URI path prefix [" + remaining +
                 "], must be one of " + collection.getApiNames());
         }
 


[02/35] git commit: Initial version of component util maven plugin

Posted by dh...@apache.org.
Initial version of component util maven plugin


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

Branch: refs/heads/master
Commit: 7c1a35fcaf0ead8da52b333136647a47e7dd24e8
Parents: 7431e7e
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 23 18:35:56 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:29 2014 -0700

----------------------------------------------------------------------
 .../camel-component-util-maven-plugin/pom.xml   | 111 +++++++++++
 .../camel/maven/ApiMethodGeneratorMojo.java     | 197 +++++++++++++++++++
 .../camel/maven/FileApiMethodGeneratorMojo.java |  82 ++++++++
 .../org/apache/camel/maven/Substitution.java    |  67 +++++++
 .../src/main/resources/api-method-enum.vm       |  62 ++++++
 .../apache/camel/maven/ApiMethodEnumTest.java   |  71 +++++++
 .../java/org/apache/camel/maven/TestProxy.java  |  64 ++++++
 .../src/test/resources/log4j.properties         |  36 ++++
 tooling/maven/pom.xml                           |   1 +
 9 files changed, 691 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/pom.xml b/tooling/maven/camel-component-util-maven-plugin/pom.xml
new file mode 100644
index 0000000..d6159f1
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/pom.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>maven-plugins</artifactId>
+    <version>2.14-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-component-util-maven-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Camel :: Maven Plugins :: Camel Component Utilities</name>
+  <description>Maven plugin to generate Camel Components for APIs</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-descriptor</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>${velocity-version}</version>
+    </dependency>
+
+    <!-- add some logging to the classpath -->
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-plugin-plugin</artifactId>
+          <version>3.3</version>
+          <configuration>
+            <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
+            <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+          </configuration>
+          <executions>
+            <execution>
+              <id>mojo-descriptor</id>
+              <goals>
+                  <goal>descriptor</goal>
+              </goals>
+            </execution>
+            <execution>
+              <id>help-goal</id>
+              <goals>
+                  <goal>helpmojo</goal>
+              </goals>
+            </execution>
+          </executions>
+          </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..ff0d7f9
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java
@@ -0,0 +1,197 @@
+/**
+ * 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.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.camel.util.component.ApiMethodParser;
+import org.apache.log4j.Logger;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.Log4JLogChute;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+/**
+ * Base Mojo class for ApiMethod generators.
+ */
+public abstract class ApiMethodGeneratorMojo extends AbstractMojo {
+
+    protected static final String PREFIX = "camel.component.util.";
+
+    // used for velocity logging, to avoid creating velocity.log
+    private final Logger LOG = Logger.getLogger(this.getClass());
+
+    @Parameter(defaultValue = "${project}", readonly = true)
+    MavenProject project;
+
+    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camelComponent")
+    protected File outDir;
+
+    @Parameter(defaultValue = "org.apache.camel.util.component")
+    protected String outPackage;
+
+    @Parameter(required = true, property = PREFIX + "proxyClass")
+    protected String proxyClass;
+
+    // cached fields
+    private Class<?> proxyType;
+    private ClassLoader projectClassLoader;
+    private VelocityEngine engine;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+
+        // initialize velocity
+        initVelocityEngine();
+
+        // load proxy class and get enumeration file to generate
+        final Class proxyType = getProxyType();
+
+        // create parser
+        ApiMethodParser parser = createAdapterParser(proxyType);
+        parser.setSignatures(getSignatureList());
+        parser.setClassLoader(getProjectClassLoader());
+
+        // parse signatures
+        final List<ApiMethodParser.ApiMethodModel> models = parser.parse();
+
+        // generate enumeration from model
+        generateEnum(models);
+    }
+
+    protected ApiMethodParser createAdapterParser(Class proxyType) {
+        return new ApiMethodParser(proxyType){};
+    }
+
+    private void initVelocityEngine() {
+        // initialize velocity to load resources from class loader and use Log4J
+        Properties velocityProperties = new Properties();
+        velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
+        velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
+        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
+        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
+        engine = new VelocityEngine(velocityProperties);
+        engine.init();
+    }
+
+    private void generateEnum(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        final File apiMethodFile = getApiMethodFile();
+        // ensure parent directories exist
+        apiMethodFile.getParentFile().mkdirs();
+
+        // set template parameters
+        VelocityContext context = new VelocityContext();
+        context.put("generatedDate", new Date().toString());
+        context.put("packageName", outPackage);
+        context.put("enumName", getEnumName());
+        context.put("models", models);
+        context.put("proxyType", getProxyType());
+        context.put("helper", getClass());
+
+        // load velocity template
+        final Template template = engine.getTemplate("/api-method-enum.vm", "UTF-8");
+
+        // generate Enumeration
+        BufferedWriter writer = null;
+        try {
+            writer = new BufferedWriter(new FileWriter(apiMethodFile));
+            template.merge(context, writer);
+        } catch (IOException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.close();
+                } catch (IOException ignore) {}
+            }
+        }
+    }
+
+    public abstract List<String> getSignatureList() throws MojoExecutionException;
+
+    public Class getProxyType() throws MojoExecutionException {
+        if (proxyType == null) {
+            // load proxy class from Project runtime dependencies
+            try {
+                proxyType = getProjectClassLoader().loadClass(proxyClass);
+            } catch (ClassNotFoundException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+        return proxyType;
+    }
+
+    private ClassLoader getProjectClassLoader() throws MojoExecutionException {
+        if (projectClassLoader == null)  {
+            final List classpathElements;
+            try {
+                classpathElements = project.getRuntimeClasspathElements();
+            } catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+            final URL[] urls = new URL[classpathElements.size()];
+            int i = 0;
+            for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
+                try {
+                    urls[i] = new File((String) it.next()).toURI().toURL();
+                } catch (MalformedURLException e) {
+                    throw new MojoExecutionException(e.getMessage(), e);
+                }
+            }
+            projectClassLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
+        }
+        return projectClassLoader;
+    }
+
+    public File getApiMethodFile() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getEnumName()).append(".java");
+        return new File(outDir, fileName.toString());
+    }
+
+    private String getEnumName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "ApiMethod";
+    }
+
+    public static String getType(Class<?> clazz) {
+        if (clazz.isArray()) {
+            // create a zero length array and get the class from the instance
+            return "new " + clazz.getCanonicalName().replaceAll("\\[\\]", "[0]") + ".getClass()";
+        } else {
+            return clazz.getCanonicalName() + ".class";
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..8ce2cf2
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
@@ -0,0 +1,82 @@
+/**
+ * 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.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.util.component.ApiMethodParser;
+import org.apache.camel.util.component.ArgumentSubstitutionParser;
+import org.apache.maven.plugin.MojoExecutionException;
+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;
+
+/**
+ * Parses ApiMethod signatures from a File.
+ */
+@Mojo(name = "fromFile", requiresDependencyResolution = ResolutionScope.RUNTIME, requiresProject = true,
+        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class FileApiMethodGeneratorMojo extends ApiMethodGeneratorMojo {
+
+    @Parameter(required = true, property = "camel.component.util.signatures")
+    protected File signatures;
+
+    @Parameter(property = "camel.component.util.substitutions")
+    protected Substitution[] substitutions;
+
+    @Override
+    protected ApiMethodParser createAdapterParser(Class proxyType) {
+        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
+    }
+
+    @Override
+    public List<String> getSignatureList() throws MojoExecutionException {
+        // get signatures as a list of Strings
+        List<String> result = new ArrayList<String>();
+        try {
+            BufferedReader reader = new BufferedReader(new FileReader(this.signatures));
+            String line = reader.readLine();
+            while (line != null) {
+                result.add(line);
+            }
+        } catch (FileNotFoundException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        } catch (IOException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+        if (result.isEmpty()) {
+            throw new MojoExecutionException("Signature file " + signatures.getPath() + " is empty");
+        }
+        return result;
+    }
+
+    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
+        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
+        for (int i = 0; i < substitutions.length; i++) {
+            subs[i] = new ArgumentSubstitutionParser.Substitution(substitutions[i].getMethod(),
+                    substitutions[i].getArgName(), substitutions[i].getArgType(), substitutions[i].getReplacement());
+        }
+        return subs;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
new file mode 100644
index 0000000..c0772a7
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
@@ -0,0 +1,67 @@
+/**
+ * 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;
+
+/**
+ * Argument name substitution for {@link FileApiMethodGeneratorMojo}.
+ */
+public class Substitution {
+
+    public String method;
+    private String argName;
+    private String argType;
+    private String replacement;
+
+    public Substitution(String method, String argName, String argType, String replacement) {
+        this.method = method;
+        this.argName = argName;
+        this.argType = argType;
+        this.replacement = replacement;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public String getArgName() {
+        return argName;
+    }
+
+    public void setArgName(String argName) {
+        this.argName = argName;
+    }
+
+    public String getArgType() {
+        return argType;
+    }
+
+    public void setArgType(String argType) {
+        this.argType = argType;
+    }
+
+    public String getReplacement() {
+        return replacement;
+    }
+
+    public void setReplacement(String replacement) {
+        this.replacement = replacement;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
new file mode 100644
index 0000000..9dab27c
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
@@ -0,0 +1,62 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-method-enum.vm
+/*
+ * Camel ApiMethod Enumeration generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import $proxyType.Name;
+
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodImpl;
+
+/**
+ * Camel {@link ApiMethod} Enumeration for $proxyType.Name
+ */
+public enum $enumName implements ApiMethod {
+
+#foreach ( $model in $models )
+    ${model.UniqueName}($helper.getType($model.ResultType), "$model.Name"#foreach ( $arg in $model.Arguments ), $helper.getType($arg.Type), "$arg.Name"#end)#if ( $foreach.hasNext ),#else;#end
+
+#end
+
+    private final ApiMethod apiMethod;
+
+    private ${enumName}(Class<?> resultType, String name, Object... args) {
+        this.apiMethod = new ApiMethodImpl(${proxyType.SimpleName}.class, resultType, name, args);
+    }
+
+    @Override
+    public String getName() { return apiMethod.getName(); }
+
+    @Override
+    public Class<?> getResultType() { return apiMethod.getResultType(); }
+
+    @Override
+    public List<String> getArgNames() { return apiMethod.getArgNames(); }
+
+    @Override
+    public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); }
+
+    @Override
+    public Method getMethod() { return apiMethod.getMethod(); }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java
new file mode 100644
index 0000000..b224a6e
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.junit.Test;
+
+/**
+ * Tests api-method-enum.vm
+ */
+public class ApiMethodEnumTest {
+
+    @Test
+    public void testTemplate() throws IOException, MojoFailureException, MojoExecutionException {
+
+        final FileApiMethodGeneratorMojo mojo = new FileApiMethodGeneratorMojo() {
+
+            @Override
+            public List<String> getSignatureList() throws MojoExecutionException {
+                final ArrayList<String> signatures = new ArrayList<String>();
+                signatures.add("public String sayHi();");
+                signatures.add("public String sayHi(final String name);");
+                signatures.add("public final String greetMe(final String name);");
+                signatures.add("public final String greetUs(final String name1, String name2);");
+                signatures.add("public final String greetAll(String[] names);");
+                signatures.add("public final String greetAll(java.util.List<String> names);");
+                signatures.add("public final String[] greetTimes(String name, int times);");
+                return signatures;
+            }
+        };
+        mojo.substitutions = new Substitution[1];
+        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
+
+        mojo.outDir = new File("target/generated-test-sources/camelComponent");
+        mojo.outPackage = "org.apache.camel.component.util";
+        mojo.proxyClass = TestProxy.class.getCanonicalName();
+        mojo.project = new MavenProject((Model) null) {
+            @Override
+            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
+                return Collections.EMPTY_LIST;
+            }
+        };
+
+        mojo.execute();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java
new file mode 100644
index 0000000..ced2058
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestProxy {
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String sayHi(final String name) {
+        return "Hello " + name;
+    }
+
+    public final String greetMe(final String name) {
+        return "Greetings " + name;
+    }
+
+    public final String greetUs(final String name1, String name2) {
+        return "Greetings " + name1 + ", " + name2;
+    }
+
+    public final String greetAll(final String[] names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String greetAll(List<String> names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String[] greetTimes(String name, int times) {
+        final List<String> result = new ArrayList<String>();
+        for (int i = 0; i < times; i++) {
+            result.add("Greetings " + name);
+        }
+        return result.toArray(new String[result.size()]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties
new file mode 100644
index 0000000..3d544fc
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
+
+#log4j.logger.org.apache.camel.maven=DEBUG
+#log4j.logger.org.apache.http=DEBUG
+#log4j.logger.org.apache.camel.util.component=TRACE

http://git-wip-us.apache.org/repos/asf/camel/blob/7c1a35fc/tooling/maven/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/pom.xml b/tooling/maven/pom.xml
index de5078a..fbd883e 100644
--- a/tooling/maven/pom.xml
+++ b/tooling/maven/pom.xml
@@ -33,6 +33,7 @@
     <module>camel-package-maven-plugin</module>
     <module>camel-maven-plugin</module>
     <module>guice-maven-plugin</module>
+    <module>camel-component-util-maven-plugin</module>
   </modules>
 
   <dependencies>


[15/35] git commit: Added check to exclude static methods in proxies

Posted by dh...@apache.org.
Added check to exclude static methods in proxies


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

Branch: refs/heads/master
Commit: e47e53c013706f1adea1faa39c4c51886cab84a6
Parents: 99ccd37
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:22:26 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../apache/camel/maven/JavadocApiMethodGeneratorMojo.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e47e53c0/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
index b94aab7..fe8b5ac 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -134,7 +134,9 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
         }
         try {
             final Method method = aClass.getMethod(name, argTypes);
-            if ((method.getModifiers() & Modifier.PUBLIC) != 0) {
+            // only include non-static public methods
+            int modifiers = method.getModifiers();
+            if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
                 return method.getReturnType().getCanonicalName();
             } else {
                 return null;
@@ -191,11 +193,6 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
         }
 
         @Override
-        protected void endTag(boolean omitted) {
-            super.endTag(omitted);    //To change body of overridden methods use File | Settings | File Templates.
-        }
-
-        @Override
         protected void handleEmptyTag(TagElement tag) {
             if (parserState == ParserState.METHOD && HTML.Tag.CODE.equals(tag.getHTMLTag())) {
                 if (methodWithTypes != null) {


[26/35] git commit: Renamed test API classes for clarity

Posted by dh...@apache.org.
Renamed test API classes for clarity


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

Branch: refs/heads/master
Commit: 161b21689744271966a1e9d6e207fb30a5ebdbcb
Parents: d35d71f
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 19:28:24 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:34 2014 -0700

----------------------------------------------------------------------
 .../src/main/java/__name__FileHello.java        | 31 ++++++++++++++++++++
 .../src/main/java/__name__FileSigApi.java       | 31 --------------------
 .../src/main/java/__name__JavadocHello.java     | 31 ++++++++++++++++++++
 .../src/main/java/__name__JavadocSigApi.java    | 31 --------------------
 .../__artifactId__-component/pom.xml            | 12 ++++----
 .../src/main/java/__name__Endpoint.java         |  4 +--
 6 files changed, 70 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/161b2168/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileHello.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileHello.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileHello.java
new file mode 100644
index 0000000..fb9bc52
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileHello.java
@@ -0,0 +1,31 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+/**
+ * Sample API used by ${name} Component whose method signatures are read from File.
+ */
+public class ${name}FileHello {
+
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String greetMe(String name) {
+        return "Hello " + name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/161b2168/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java
deleted file mode 100644
index 4c86927..0000000
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java
+++ /dev/null
@@ -1,31 +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 ${package};
-
-/**
- * Sample API used by ${name} Component whose method signatures are read from File.
- */
-public class ${name}FileSigApi {
-
-    public String sayHi() {
-        return "Hello!";
-    }
-
-    public String greetMe(String name) {
-        return "Hello " + name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/161b2168/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocHello.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocHello.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocHello.java
new file mode 100644
index 0000000..72e55ca
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocHello.java
@@ -0,0 +1,31 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+/**
+ * Sample API used by ${name} Component whose method signatures are read from Javadoc.
+ */
+public class ${name}JavadocHello {
+
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String greetMe(String name) {
+        return "Hello " + name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/161b2168/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java
deleted file mode 100644
index 3ab3f82..0000000
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java
+++ /dev/null
@@ -1,31 +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 ${package};
-
-/**
- * Sample API used by ${name} Component whose method signatures are read from Javadoc.
- */
-public class ${name}JavadocSigApi {
-
-    public String sayHi() {
-        return "Hello!";
-    }
-
-    public String greetMe(String name) {
-        return "Hello " + name;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/161b2168/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index 2490084..31cf249 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -149,7 +149,7 @@
               <componentPackage>${componentPackage}</componentPackage>
               <scheme>${schemeName}</scheme>
               <componentName>${componentName}</componentName>
-              <proxyClass>${package}.${name}FileSigApi</proxyClass>
+              <proxyClass>${package}.${name}FileHello</proxyClass>
               <!-- Use substitutions to manipulate parameter names and avoid name clashes
               <substitutions>
                 <substitution>
@@ -173,7 +173,7 @@
               <componentPackage>${componentPackage}</componentPackage>
               <scheme>${schemeName}</scheme>
               <componentName>${componentName}</componentName>
-              <proxyClass>${package}.${name}JavadocSigApi</proxyClass>
+              <proxyClass>${package}.${name}JavadocHello</proxyClass>
               <!-- Use substitutions to manipulate parameter names and avoid name clashes
               <substitutions>
                 <substitution>
@@ -203,8 +203,8 @@
               <componentName>${componentName}</componentName>
               <apis>
                 <api>
-                  <apiName>hello1</apiName>
-                  <proxyClass>${package}.${name}FileSigApi</proxyClass>
+                  <apiName>hello-file</apiName>
+                  <proxyClass>${package}.${name}FileHello</proxyClass>
                   <!-- Use method aliases in endpoint URIs, e.g. support 'widget' as alias for getWidget or setWidget
                   <aliases>
                     <alias>
@@ -219,8 +219,8 @@
                   -->
                 </api>
                 <api>
-                  <apiName>hello2</apiName>
-                  <proxyClass>${package}.${name}JavadocSigApi</proxyClass>
+                  <apiName>hello-javadoc</apiName>
+                  <proxyClass>${package}.${name}JavadocHello</proxyClass>
                 </api>
               </apis>
             </configuration>

http://git-wip-us.apache.org/repos/asf/camel/blob/161b2168/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
index 73b87a6..84917b3 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
@@ -81,8 +81,8 @@ public class ${name}Endpoint extends DefaultEndpoint {
 
         // TODO manage API proxies
         proxyCache = new HashMap<${name}ApiName, Object>();
-        proxyCache.put(${name}ApiName.HELLO1, new ${name}FileSigApi());
-        proxyCache.put(${name}ApiName.HELLO2, new ${name}JavadocSigApi());
+        proxyCache.put(${name}ApiName.HELLO_FILE, new ${name}FileHello());
+        proxyCache.put(${name}ApiName.HELLO_JAVADOC, new ${name}JavadocHello());
     }
 
     public Producer createProducer() throws Exception {


[19/35] git commit: Added support for generating integration tests, fixed JavadocApiMethodGeneratorMojoTest, refactored ApiComponentGeneratorMojo to only generate component classes, refactored plugin tests

Posted by dh...@apache.org.
Added support for generating integration tests, fixed JavadocApiMethodGeneratorMojoTest, refactored ApiComponentGeneratorMojo to only generate component classes, refactored plugin tests


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

Branch: refs/heads/master
Commit: 3d46cbf327d2bd209ae80718192570e55304fec5
Parents: 0f67b18
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Thu May 29 18:00:49 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:32 2014 -0700

----------------------------------------------------------------------
 .../camel-component-util-maven-plugin/pom.xml   |   5 +
 .../maven/AbstractApiMethodGeneratorMojo.java   | 119 ++++++++++++++++---
 .../camel/maven/AbstractGeneratorMojo.java      |  26 ++--
 .../camel/maven/ApiComponentGeneratorMojo.java  |  37 +-----
 .../java/org/apache/camel/maven/ApiProxy.java   |  40 -------
 .../maven/JavadocApiMethodGeneratorMojo.java    |  57 +++++----
 .../src/main/resources/api-route-test.vm        | 100 ++++++++++++++++
 .../camel/maven/AbstractGeneratorMojoTest.java  |  32 +++++
 .../maven/ApiComponentGeneratorMojoTest.java    |  33 +----
 .../maven/FileApiMethodGeneratorMojoTest.java   |  14 +--
 .../JavadocApiMethodGeneratorMojoTest.java      |  22 +---
 11 files changed, 304 insertions(+), 181 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/pom.xml b/tooling/maven/camel-component-util-maven-plugin/pom.xml
index 90a9aea..ffda9c4 100644
--- a/tooling/maven/camel-component-util-maven-plugin/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/pom.xml
@@ -79,6 +79,11 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
index 856a286..3064824 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -17,10 +17,13 @@
 package org.apache.camel.maven;
 
 import java.io.File;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.camel.util.component.ApiMethodParser;
 import org.apache.camel.util.component.ArgumentSubstitutionParser;
+import org.apache.commons.lang.ClassUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.Parameter;
@@ -56,22 +59,19 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
 
         // generate enumeration from model
         mergeTemplate(getApiMethodContext(models), getApiMethodFile(), "/api-method-enum.vm");
+
+        // generate junit test if it doesn't already exist under test source directory
+        // i.e. it may have been generated then moved there and populated with test values
+        final String testFilePath = getTestFilePath();
+        if (!new File(project.getBuild().getTestSourceDirectory(), testFilePath).exists()) {
+            mergeTemplate(getApiTestContext(models), new File(generatedTestDir, testFilePath), "/api-route-test.vm");
+        }
     }
 
     protected ApiMethodParser createAdapterParser(Class proxyType) {
         return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions()){};
     }
 
-    private VelocityContext getApiMethodContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
-        VelocityContext context = new VelocityContext();
-        context.put("packageName", outPackage);
-        context.put("enumName", getEnumName());
-        context.put("models", models);
-        context.put("proxyType", getProxyType());
-        context.put("helper", getClass());
-        return context;
-    }
-
     public abstract List<String> getSignatureList() throws MojoExecutionException;
 
     public Class getProxyType() throws MojoExecutionException {
@@ -86,17 +86,58 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         return proxyType;
     }
 
+    private VelocityContext getApiMethodContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = getCommonContext(models);
+        context.put("enumName", getEnumName());
+        return context;
+    }
+
     public File getApiMethodFile() throws MojoExecutionException {
         final StringBuilder fileName = new StringBuilder();
         fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
         fileName.append(getEnumName()).append(".java");
-        return new File(outDir, fileName.toString());
+        return new File(generatedSrcDir, fileName.toString());
     }
 
     private String getEnumName() throws MojoExecutionException {
         return getProxyType().getSimpleName() + "ApiMethod";
     }
 
+    private VelocityContext getApiTestContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = getCommonContext(models);
+        context.put("testName", getUnitTestName());
+        context.put("scheme", scheme);
+        return context;
+    }
+
+    private String getTestFilePath() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getUnitTestName()).append(".java");
+        return fileName.toString();
+    }
+
+    private String getUnitTestName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "IntegrationTest";
+    }
+
+    private VelocityContext getCommonContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = new VelocityContext();
+        context.put("models", models);
+        context.put("proxyType", getProxyType());
+        context.put("helper", this);
+        return context;
+    }
+
+    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
+        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
+        for (int i = 0; i < substitutions.length; i++) {
+            subs[i] = new ArgumentSubstitutionParser.Substitution(substitutions[i].getMethod(),
+                    substitutions[i].getArgName(), substitutions[i].getArgType(), substitutions[i].getReplacement());
+        }
+        return subs;
+    }
+
     public static String getType(Class<?> clazz) {
         if (clazz.isArray()) {
             // create a zero length array and get the class from the instance
@@ -106,12 +147,56 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         }
     }
 
-    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
-        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
-        for (int i = 0; i < substitutions.length; i++) {
-            subs[i] = new ArgumentSubstitutionParser.Substitution(substitutions[i].getMethod(),
-                    substitutions[i].getArgName(), substitutions[i].getArgType(), substitutions[i].getReplacement());
+    public static String getTestName(ApiMethodParser.ApiMethodModel model) {
+        final StringBuilder builder = new StringBuilder();
+        final String name = model.getMethod().getName();
+        builder.append(Character.toUpperCase(name.charAt(0)));
+        builder.append(name.substring(1));
+        // find overloaded method suffix from unique name
+        final String uniqueName = model.getUniqueName();
+        if (uniqueName.length() > name.length()) {
+            builder.append(uniqueName.substring(name.length()));
+        }
+        return builder.toString();
+    }
+
+    public static boolean isVoidType(Class<?> resultType) {
+        return resultType == Void.TYPE;
+    }
+
+    public String getPropertyPrefix() {
+        return componentName + ".";
+    }
+
+    public static String getResultDeclaration(Class<?> resultType) {
+        if (resultType.isPrimitive()) {
+            return ClassUtils.primitiveToWrapper(resultType).getSimpleName();
+        } else {
+            return resultType.getCanonicalName();
+        }
+    }
+
+    private static final Map<Class<?>, String> PRIMITIVE_VALUES;
+
+    static {
+        PRIMITIVE_VALUES = new HashMap<Class<?>, String>();
+        PRIMITIVE_VALUES.put(Boolean.TYPE, "Boolean.FALSE");
+        PRIMITIVE_VALUES.put(Byte.TYPE, "(byte) 0");
+        PRIMITIVE_VALUES.put(Character.TYPE, "(char) 0");
+        PRIMITIVE_VALUES.put(Short.TYPE, "(short) 0");
+        PRIMITIVE_VALUES.put(Integer.TYPE, "0");
+        PRIMITIVE_VALUES.put(Long.TYPE, "0L");
+        PRIMITIVE_VALUES.put(Float.TYPE, "0.0f");
+        PRIMITIVE_VALUES.put(Double.TYPE, "0.0d");
+    }
+
+    public static String getDefaultArgValue(Class<?> aClass) {
+        if (aClass.isPrimitive()) {
+            // lookup default primitive value string
+            return PRIMITIVE_VALUES.get(aClass);
+        } else {
+            // return type cast null string
+            return "null";
         }
-        return subs;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
index 0e29a96..eee09ea 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
@@ -36,6 +36,7 @@ import org.apache.maven.project.MavenProject;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.log.Log4JLogChute;
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
@@ -56,18 +57,23 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
     MavenProject project;
 
     @Parameter(defaultValue = "${project.build.directory}/generated-sources/camel")
-    protected File outDir;
+    protected File generatedSrcDir;
+
+    @Parameter(defaultValue = "${project.build.directory}/generated-test-sources/camel")
+    protected File generatedTestDir;
 
     @Parameter(defaultValue = OUT_PACKAGE)
     protected String outPackage;
 
+    @Parameter(required = true, property = PREFIX + "scheme")
+    protected String scheme;
+
+    @Parameter(required = true, property = PREFIX + "componentName")
+    protected String componentName;
+
     private VelocityEngine engine;
     private ClassLoader projectClassLoader;
 
-    public void setEngine(VelocityEngine engine) {
-        this.engine = engine;
-    }
-
     public VelocityEngine getEngine() {
         if (engine == null) {
             // initialize velocity to load resources from class loader and use Log4J
@@ -82,15 +88,11 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
         return engine;
     }
 
-    protected void setProjectClassLoader(ClassLoader projectClassLoader) {
-        this.projectClassLoader = projectClassLoader;
-    }
-
     protected ClassLoader getProjectClassLoader() throws MojoExecutionException {
         if (projectClassLoader == null)  {
             final List classpathElements;
             try {
-                classpathElements = project.getRuntimeClasspathElements();
+                classpathElements = project.getTestClasspathElements();
             } catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
                 throw new MojoExecutionException(e.getMessage(), e);
             }
@@ -115,6 +117,8 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
 
         // add generated date
         context.put("generatedDate", new Date().toString());
+        // add output package
+        context.put("packageName", outPackage);
 
         // load velocity template
         final Template template = getEngine().getTemplate(templateName, "UTF-8");
@@ -126,6 +130,8 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
             template.merge(context, writer);
         } catch (IOException e) {
             throw new MojoExecutionException(e.getMessage(), e);
+        } catch (VelocityException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
         } finally {
             if (writer != null) {
                 try {

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
index 7a90b81..b967817 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
@@ -18,7 +18,6 @@ package org.apache.camel.maven;
 
 import java.io.File;
 
-import org.apache.maven.plugin.AbstractMojoExecutionException;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
@@ -35,9 +34,6 @@ import org.apache.velocity.VelocityContext;
 public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
 
     @Parameter(required = true)
-    protected String componentName;
-
-    @Parameter(required = true)
     protected ApiProxy[] apis;
 
     @Override
@@ -46,37 +42,6 @@ public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
             throw new MojoExecutionException("One or more API proxies are required");
         }
 
-        // generate ApiMethods
-        for (int i = 0; i < apis.length; i++) {
-            apis[i].validate();
-
-            AbstractApiMethodGeneratorMojo generator;
-            if (apis[i].getSignatureFile() != null) {
-                generator = new FileApiMethodGeneratorMojo();
-                ((FileApiMethodGeneratorMojo)generator).signatureFile = apis[i].getSignatureFile();
-            } else {
-                generator = new JavadocApiMethodGeneratorMojo();
-                ((JavadocApiMethodGeneratorMojo)generator).excludePackages = apis[i].getExcludePackages();
-                ((JavadocApiMethodGeneratorMojo)generator).excludeClasses = apis[i].getExcludeClasses();
-            }
-            // set API properties
-            generator.proxyClass = apis[i].getProxyClass();
-            generator.substitutions = apis[i].getSubstitutions();
-            // set shared properties
-            generator.outDir = outDir;
-            generator.outPackage = outPackage;
-            // set shared state
-            generator.setEngine(getEngine());
-            generator.setProjectClassLoader(getProjectClassLoader());
-
-            try {
-                generator.execute();
-            } catch (AbstractMojoExecutionException e) {
-                throw new MojoExecutionException("Error generating ApiMethod for " +
-                        apis[i].getProxyClass() + ": " + e.getMessage(), e);
-            }
-        }
-
         // TODO generate Component classes
         // generate ApiCollection
         mergeTemplate(getApiCollectionContext(), getApiCollectionFile(), "/api-collection.vm");
@@ -96,7 +61,7 @@ public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
         final StringBuilder fileName = new StringBuilder();
         fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
         fileName.append(getApiCollectionName()).append(".java");
-        return new File(outDir, fileName.toString());
+        return new File(generatedSrcDir, fileName.toString());
     }
 
     private String getApiCollectionName() {

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
index 54e5b80..5751dbd 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.maven;
 
-import java.io.File;
 import java.util.Collections;
 import java.util.Map;
 
@@ -27,13 +26,6 @@ public class ApiProxy {
     private String apiName;
     private String proxyClass;
 
-    private Substitution[] substitutions = new Substitution[0];
-
-    private String excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
-    private String excludeClasses;
-
-    private File signatureFile;
-
     private Map<String, String> aliases = Collections.EMPTY_MAP;
 
     public String getApiName() {
@@ -52,38 +44,6 @@ public class ApiProxy {
         this.proxyClass = proxyClass;
     }
 
-    public Substitution[] getSubstitutions() {
-        return substitutions;
-    }
-
-    public void setSubstitutions(Substitution[] substitutions) {
-        this.substitutions = substitutions;
-    }
-
-    public String getExcludePackages() {
-        return excludePackages;
-    }
-
-    public void setExcludePackages(String excludePackages) {
-        this.excludePackages = excludePackages;
-    }
-
-    public String getExcludeClasses() {
-        return excludeClasses;
-    }
-
-    public void setExcludeClasses(String excludeClasses) {
-        this.excludeClasses = excludeClasses;
-    }
-
-    public File getSignatureFile() {
-        return signatureFile;
-    }
-
-    public void setSignatureFile(File signatureFile) {
-        this.signatureFile = signatureFile;
-    }
-
     public Map<String, String> getAliases() {
         return aliases;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
index fe8b5ac..677d400 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -40,11 +40,12 @@ 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.codehaus.plexus.util.IOUtil;
 
 /**
  * Parses ApiMethod signatures from Javadoc.
  */
-@Mojo(name = "fromJavaDoc", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
+@Mojo(name = "fromJavaDoc", requiresDependencyResolution = ResolutionScope.TEST, requiresProject = true,
         defaultPhase = LifecyclePhase.GENERATE_SOURCES)
 public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
 
@@ -63,8 +64,8 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
 
     @Override
     public List<String> getSignatureList() throws MojoExecutionException {
-        // get signatures as a list of Strings
-        List<String> result = new ArrayList<String>();
+        // signatures as map from signature with no arg names to arg names from JavadocParser
+        Map<String, String> result = new HashMap<String, String>();
 
         final Pattern packages = Pattern.compile(excludePackages);
         Pattern classes = null;
@@ -74,16 +75,19 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
 
         // for proxy class and super classes not matching excluded packages or classes
         for (Class aClass = getProxyType();
-             !packages.matcher(aClass.getPackage().getName()).matches() && (classes == null ||
-                     !classes.matcher(aClass.getSimpleName()).matches()); aClass = aClass.getSuperclass()) {
+             aClass != null && !packages.matcher(aClass.getPackage().getName()).matches() &&
+                     (classes == null || !classes.matcher(aClass.getSimpleName()).matches());
+             aClass = aClass.getSuperclass()) {
 
             final String javaDocPath = aClass.getName().replaceAll("\\.", "/") + ".html";
 
             // read javadoc html text for class
+            InputStream inputStream = null;
             try {
-                final InputStream inputStream = getProjectClassLoader().getResourceAsStream(javaDocPath);
+                inputStream = getProjectClassLoader().getResourceAsStream(javaDocPath);
                 if (inputStream == null) {
-                    throw new MojoExecutionException("JavaDoc not found using classpath for " + aClass.getName());
+                    LOG.debug("JavaDoc not found on classpath for " + aClass.getName());
+                    break;
                 }
                 // transform the HTML to get method summary as text
                 // dummy DTD
@@ -94,28 +98,37 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
                 // get public method signature
                 final Map<String, String> methodMap = htmlParser.getMethodText();
                 for (String method : htmlParser.getMethods()) {
-                    final int leftBracket = method.indexOf('(');
-                    final String name = method.substring(0, leftBracket);
-                    final String args = method.substring(leftBracket + 1, method.length() - 1);
-                    String[] types;
-                    if (args.isEmpty()) {
-                        types = new String[0];
-                    } else {
-                        types = args.split(",");
-                    }
-                    final String resultType = getResultType(aClass, name, types);
-                    if (resultType != null) {
-                        final StringBuilder signature = new StringBuilder(resultType);
-                        signature.append(" ").append(name).append(methodMap.get(method));
-                        result.add(signature.toString());
+                    if (!result.containsKey(method)) {
+
+                        final int leftBracket = method.indexOf('(');
+                        final String name = method.substring(0, leftBracket);
+                        final String args = method.substring(leftBracket + 1, method.length() - 1);
+                        String[] types;
+                        if (args.isEmpty()) {
+                            types = new String[0];
+                        } else {
+                            types = args.split(",");
+                        }
+                        final String resultType = getResultType(aClass, name, types);
+                        if (resultType != null) {
+                            final StringBuilder signature = new StringBuilder(resultType);
+                            signature.append(" ").append(name).append(methodMap.get(method));
+                            result.put(method, signature.toString());
+                        }
                     }
                 }
             } catch (IOException e) {
                 throw new MojoExecutionException(e.getMessage(), e);
+            } finally {
+                IOUtil.close(inputStream);
             }
         }
 
-        return result;
+        if (result.isEmpty()) {
+            throw new MojoExecutionException("No public non-static methods found, " +
+                    "make sure Javadoc is available as project test dependency");
+        }
+        return new ArrayList<String>(result.values());
     }
 
     private String getResultType(Class<?> aClass, String name, String[] types) throws MojoExecutionException {

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
new file mode 100644
index 0000000..160e920
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
@@ -0,0 +1,100 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-route-test.vm
+/*
+ * Camel Api Route test generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import java.util.HashMap;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for $proxyType.Name APIs.
+ * TODO Copy the file to src/test/java, populate parameter values, and remove @Ignore annotations.
+ */
+public class ${testName} extends CamelTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(${testName}.class);
+
+#foreach ( $model in $models )
+#set ( $testName = $helper.getTestName($model) )
+#set ( $args = $model.Arguments )
+#set ( $resultType = $model.ResultType )
+#set ( $voidResult = $helper.isVoidType($resultType) )
+## are parameter values needed
+#if ( !$args.isEmpty() )
+    // TODO provide parameter values for $model.Name
+#end
+    @Ignore
+    @Test
+    public void test${testName}() throws Exception {
+## single argument, use as body
+#if ( $args.size() == 1 )
+#set ( $argType = $args.get(0).Type )
+        // using $argType.CanonicalName message body for single parameter "$args.get(0).Name"
+## multiple arguments, pass them as headers
+#elseif ( $args.size() > 1 )
+        final HashMap<String, Object> headers = new HashMap<String, Object>();
+#foreach ( $arg in $args )
+#if ( !$arg.Type.isPrimitive() )
+        // parameter type is $arg.Type.CanonicalName
+        headers.put("${helper.getPropertyPrefix()}${arg.Name}", null);
+#else
+        headers.put("${helper.getPropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
+#end
+#end
+#end
+## method invocation result
+        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) ) $type result = (${type})#end
+## actual template call
+#if ( $args.isEmpty() )
+template().requestBody("direct://${model.UniqueName}", (java.lang.Object)null);
+#elseif ( $args.size() == 1 )
+## typecast body to avoid requestBody() conflict
+template().requestBody("direct://${model.UniqueName}", (${argType.CanonicalName}) $helper.getDefaultArgValue($argType));
+#else
+template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
+#end
+#if ( !$voidResult )
+
+        LOG.debug("${model.Name} :" + result);
+#end
+    }
+
+#end
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+#foreach ( $model in $models )
+                // test route for $name
+                from("direct://${model.UniqueName}")
+                  .to("${scheme}://${model.Name}");
+
+#end
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
index 0e781d8..aa7f7b7 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
@@ -17,7 +17,13 @@
 package org.apache.camel.maven;
 
 import java.io.File;
+import java.util.Collections;
+import java.util.List;
 
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.MavenProject;
 import static org.junit.Assert.assertTrue;
 
 /**
@@ -26,8 +32,34 @@ import static org.junit.Assert.assertTrue;
 public class AbstractGeneratorMojoTest {
     protected static final String OUT_DIR = "target/generated-test-sources/camelComponent";
     protected static final String PACKAGE_PATH = AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/") + "/";
+    protected static final String COMPONENT_NAME = "TestComponent";
+    protected static final String SCHEME = "testComponent";
 
     protected void assertExists(File outFile) {
         assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
     }
+
+    protected void configureMojo(AbstractGeneratorMojo mojo) {
+        mojo.componentName = COMPONENT_NAME;
+        mojo.scheme = SCHEME;
+        mojo.generatedSrcDir = new File(OUT_DIR);
+        mojo.generatedTestDir = new File(OUT_DIR);
+        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        mojo.project = new MavenProject((Model) null) {
+            @Override
+            public List getTestClasspathElements() throws DependencyResolutionRequiredException {
+                return Collections.EMPTY_LIST;
+            }
+
+            @Override
+            public Build getBuild() {
+                return new Build() {
+                    @Override
+                    public String getTestSourceDirectory() {
+                        return OUT_DIR;
+                    }
+                };
+            }
+        };
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
index b0f8168..fb738a1 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
@@ -17,14 +17,8 @@
 package org.apache.camel.maven;
 
 import java.io.File;
-import java.util.Collections;
-import java.util.List;
 
-import org.apache.camel.util.FileUtil;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Model;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.VelocityContext;
 import org.junit.Test;
 
 /**
@@ -32,27 +26,16 @@ import org.junit.Test;
  */
 public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
 
-    private static final String COMPONENT_NAME = "TestComponent";
-
     @Test
     public void testExecute() throws Exception {
 
-        // delete target files to begin
-        final File outDir = new File(OUT_DIR);
-        FileUtil.removeDir(outDir);
-
         final File collectionFile = new File(OUT_DIR, PACKAGE_PATH + COMPONENT_NAME + "ApiCollection.java");
 
+        // delete target files to begin
+        collectionFile.delete();
+
         final ApiComponentGeneratorMojo mojo = new ApiComponentGeneratorMojo();
-        mojo.componentName = COMPONENT_NAME;
-        mojo.outDir = new File(OUT_DIR);
-        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
-        mojo.project = new MavenProject((Model) null) {
-            @Override
-            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
-                return Collections.EMPTY_LIST;
-            }
-        };
+        configureMojo(mojo);
 
         final ApiProxy[] proxies = new ApiProxy[2];
         mojo.apis = proxies;
@@ -60,15 +43,11 @@ public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
         proxies[0] = apiProxy;
         apiProxy.setApiName("test");
         apiProxy.setProxyClass(TestProxy.class.getName());
-        apiProxy.setSignatureFile(new File("src/test/resources/test-proxy-signatures.txt"));
-        Substitution[] substitutions = new Substitution[1];
-        substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
-        apiProxy.setSubstitutions(substitutions);
 
         apiProxy = new ApiProxy();
         proxies[1] = apiProxy;
         apiProxy.setApiName("velocity");
-        apiProxy.setProxyClass(VelocityEngine.class.getName());
+        apiProxy.setProxyClass(VelocityContext.class.getName());
 
         mojo.execute();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
index 20c4a5a..7a8af42 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
@@ -18,14 +18,9 @@ package org.apache.camel.maven;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
 
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Model;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
 import org.junit.Test;
 import static org.junit.Assert.assertTrue;
 
@@ -47,15 +42,8 @@ public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
         mojo.substitutions = new Substitution[1];
         mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
 
-        mojo.outDir = new File(OUT_DIR);
-        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        configureMojo(mojo);
         mojo.proxyClass = TestProxy.class.getCanonicalName();
-        mojo.project = new MavenProject((Model) null) {
-            @Override
-            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
-                return Collections.EMPTY_LIST;
-            }
-        };
         mojo.signatureFile = new File("src/test/resources/test-proxy-signatures.txt");
 
         mojo.execute();

http://git-wip-us.apache.org/repos/asf/camel/blob/3d46cbf3/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
index dd252f2..f90b8ae 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -18,15 +18,10 @@ package org.apache.camel.maven;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
 
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Model;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.VelocityContext;
 import org.junit.Test;
 
 /**
@@ -38,23 +33,17 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
     public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
 
         // delete target file to begin
-        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "VelocityEngineApiMethod.java");
+        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "VelocityContextApiMethod.java");
         if (outFile.exists()) {
             outFile.delete();
         }
 
         final JavadocApiMethodGeneratorMojo mojo = new JavadocApiMethodGeneratorMojo();
 
-        mojo.outDir = new File(OUT_DIR);
-        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        configureMojo(mojo);
+
         // use VelocityEngine javadoc
-        mojo.proxyClass = VelocityEngine.class.getCanonicalName();
-        mojo.project = new MavenProject((Model) null) {
-            @Override
-            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
-                return Collections.EMPTY_LIST;
-            }
-        };
+        mojo.proxyClass = VelocityContext.class.getCanonicalName();
         mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
         Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey");
         mojo.substitutions = new Substitution[]{ substitution };
@@ -64,4 +53,5 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
         // check target file was generated
         assertExists(outFile);
     }
+
 }


[32/35] Renamed component-util plugin to api-component

Posted by dh...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
deleted file mode 100644
index 28bd958..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
+++ /dev/null
@@ -1,276 +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.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-import javax.swing.text.ChangedCharSetException;
-import javax.swing.text.SimpleAttributeSet;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.parser.DTD;
-import javax.swing.text.html.parser.Parser;
-import javax.swing.text.html.parser.TagElement;
-
-import org.apache.camel.util.component.ApiMethodParser;
-import org.apache.camel.util.component.ArgumentSubstitutionParser;
-import org.apache.maven.plugin.MojoExecutionException;
-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.codehaus.plexus.util.IOUtil;
-
-/**
- * Parses ApiMethod signatures from Javadoc.
- */
-@Mojo(name = "fromJavadoc", requiresDependencyResolution = ResolutionScope.TEST, requiresProject = true,
-        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
-public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
-
-    static {
-        // set Java AWT to headless before using Swing HTML parser
-        System.setProperty("java.awt.headless", "true");
-    }
-
-    protected static final String DEFAULT_EXCLUDE_PACKAGES = "javax?\\.lang.*";
-
-    @Parameter(property = "camel.component.util.excludePackages", defaultValue = DEFAULT_EXCLUDE_PACKAGES)
-    protected String excludePackages;
-
-    @Parameter(property = "camel.component.util.excludeClasses")
-    protected String excludeClasses;
-
-    @Parameter(property = "camel.component.util.excludeMethods")
-    protected String excludeMethods;
-
-    @Override
-    protected ApiMethodParser createAdapterParser(Class proxyType) {
-        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
-    }
-
-    @Override
-    public List<String> getSignatureList() throws MojoExecutionException {
-        // signatures as map from signature with no arg names to arg names from JavadocParser
-        Map<String, String> result = new HashMap<String, String>();
-
-        final Pattern packagePatterns = Pattern.compile(excludePackages);
-        Pattern classPatterns = null;
-        if (excludeClasses != null) {
-            classPatterns = Pattern.compile(excludeClasses);
-        }
-        Pattern methodPatterns = null;
-        if (excludeMethods != null) {
-            methodPatterns = Pattern.compile(excludeMethods);
-        }
-
-        // for proxy class and super classes not matching excluded packages or classes
-        for (Class aClass = getProxyType();
-             aClass != null && !packagePatterns.matcher(aClass.getPackage().getName()).matches() &&
-                     (classPatterns == null || !classPatterns.matcher(aClass.getSimpleName()).matches());
-             aClass = aClass.getSuperclass()) {
-
-            LOG.debug("Processing " + aClass.getName());
-            final String javaDocPath = aClass.getName().replaceAll("\\.", "/") + ".html";
-
-            // read javadoc html text for class
-            InputStream inputStream = null;
-            try {
-                inputStream = getProjectClassLoader().getResourceAsStream(javaDocPath);
-                if (inputStream == null) {
-                    LOG.debug("JavaDoc not found on classpath for " + aClass.getName());
-                    break;
-                }
-                // transform the HTML to get method summary as text
-                // dummy DTD
-                final DTD dtd = DTD.getDTD("html.dtd");
-                final JavadocParser htmlParser = new JavadocParser(dtd, javaDocPath);
-                htmlParser.parse(new InputStreamReader(inputStream, "UTF-8"));
-
-                // get public method signature
-                final Map<String, String> methodMap = htmlParser.getMethodText();
-                for (String method : htmlParser.getMethods()) {
-                    if (!result.containsKey(method) &&
-                            (methodPatterns == null || !methodPatterns.matcher(method).find())) {
-
-                        final int leftBracket = method.indexOf('(');
-                        final String name = method.substring(0, leftBracket);
-                        final String args = method.substring(leftBracket + 1, method.length() - 1);
-                        String[] types;
-                        if (args.isEmpty()) {
-                            types = new String[0];
-                        } else {
-                            types = args.split(",");
-                        }
-                        final String resultType = getResultType(aClass, name, types);
-                        if (resultType != null) {
-                            final StringBuilder signature = new StringBuilder(resultType);
-                            signature.append(" ").append(name).append(methodMap.get(method));
-                            result.put(method, signature.toString());
-                        }
-                    }
-                }
-            } catch (IOException e) {
-                throw new MojoExecutionException(e.getMessage(), e);
-            } finally {
-                IOUtil.close(inputStream);
-            }
-        }
-
-        if (result.isEmpty()) {
-            throw new MojoExecutionException("No public non-static methods found, " +
-                    "make sure Javadoc is available as project test dependency");
-        }
-        return new ArrayList<String>(result.values());
-    }
-
-    private String getResultType(Class<?> aClass, String name, String[] types) throws MojoExecutionException {
-        Class<?>[] argTypes = new Class<?>[types.length];
-        final ClassLoader classLoader = getProjectClassLoader();
-        for (int i = 0; i < types.length; i++) {
-            try {
-                try {
-                    argTypes[i] = ApiMethodParser.forName(types[i].trim(), classLoader);
-                } catch (ClassNotFoundException e) {
-                    throw new MojoExecutionException(e.getMessage(), e);
-                }
-            } catch (IllegalArgumentException e) {
-                throw new MojoExecutionException(e.getCause().getMessage(), e.getCause());
-            }
-        }
-        try {
-            final Method method = aClass.getMethod(name, argTypes);
-            // only include non-static public methods
-            int modifiers = method.getModifiers();
-            if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
-                return method.getReturnType().getCanonicalName();
-            } else {
-                return null;
-            }
-        } catch (NoSuchMethodException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        }
-    }
-
-    private class JavadocParser extends Parser {
-        private String hrefPattern;
-
-        private ParserState parserState;
-        private String methodWithTypes;
-        private StringBuilder methodTextBuilder = new StringBuilder();
-
-        private List<String> methods = new ArrayList<String>();
-        private Map<String, String> methodText = new HashMap<String, String>();
-
-        public JavadocParser(DTD dtd, String docPath) {
-            super(dtd);
-            this.hrefPattern = docPath + "#";
-        }
-
-        @Override
-        protected void startTag(TagElement tag) throws ChangedCharSetException {
-            super.startTag(tag);
-
-            final HTML.Tag htmlTag = tag.getHTMLTag();
-            if (htmlTag != null) {
-                if (HTML.Tag.A.equals(htmlTag)) {
-                    final SimpleAttributeSet attributes = getAttributes();
-                    final Object name = attributes.getAttribute(HTML.Attribute.NAME);
-                    if (name != null) {
-                        final String nameAttr = (String) name;
-                        if (parserState == null && "method_summary".equals(nameAttr)) {
-                            parserState = ParserState.METHOD_SUMMARY;
-                        } else if (parserState == ParserState.METHOD_SUMMARY && nameAttr.startsWith("methods_inherited_from_class_")) {
-                            parserState = null;
-                        } else if (parserState == ParserState.METHOD && methodWithTypes == null) {
-                            final Object href = attributes.getAttribute(HTML.Attribute.HREF);
-                            if (href != null) {
-                                String hrefAttr = (String) href;
-                                if (hrefAttr.contains(hrefPattern)) {
-                                    methodWithTypes = hrefAttr.substring(hrefAttr.indexOf('#') + 1);
-                                }
-                            }
-                        }
-                    }
-                } else if (parserState == ParserState.METHOD_SUMMARY && HTML.Tag.CODE.equals(htmlTag)) {
-                    parserState = ParserState.METHOD;
-                }
-            }
-        }
-
-        @Override
-        protected void handleEmptyTag(TagElement tag) {
-            if (parserState == ParserState.METHOD && HTML.Tag.CODE.equals(tag.getHTMLTag())) {
-                if (methodWithTypes != null) {
-                    // process collected method data
-                    methods.add(methodWithTypes);
-                    this.methodText.put(methodWithTypes, getArgSignature());
-
-                    // clear the text builder for next method
-                    methodTextBuilder.delete(0, methodTextBuilder.length());
-                    methodWithTypes = null;
-                }
-
-                parserState = ParserState.METHOD_SUMMARY;
-            }
-        }
-
-        private String getArgSignature() {
-            final String typeString = methodWithTypes.substring(methodWithTypes.indexOf('(') + 1, methodWithTypes.indexOf(')'));
-            if (typeString.isEmpty()) {
-                return "()";
-            }
-            final String[] types = typeString.split(",");
-            String argText = methodTextBuilder.toString().replaceAll("&nbsp;", " ").replaceAll("&nbsp", " ");
-            final String[] args = argText.substring(argText.indexOf('(') + 1, argText.indexOf(')')).split(",");
-            StringBuilder builder = new StringBuilder("(");
-            for (int i = 0; i < types.length; i++) {
-                final String[] arg = args[i].trim().split(" ");
-                builder.append(types[i]).append(" ").append(arg[1].trim()).append(",");
-            }
-            builder.deleteCharAt(builder.length() - 1);
-            builder.append(")");
-            return builder.toString();
-        }
-
-        @Override
-        protected void handleText(char[] text) {
-            if (parserState == ParserState.METHOD && methodWithTypes != null) {
-                methodTextBuilder.append(text);
-            }
-        }
-
-        private List<String> getMethods() {
-            return methods;
-        }
-
-        private Map<String, String> getMethodText() {
-            return methodText;
-        }
-    }
-
-    private static enum ParserState {
-        METHOD_SUMMARY, METHOD;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
deleted file mode 100644
index d16e041..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
+++ /dev/null
@@ -1,80 +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;
-
-/**
- * Argument name substitution for {@link FileApiMethodGeneratorMojo}.
- */
-public class Substitution {
-
-    public String method;
-    private String argName;
-    private String argType;
-    private String replacement;
-    private boolean replaceWithType;
-
-    public Substitution() {
-    }
-
-    public Substitution(String method, String argName, String argType, String replacement, boolean replaceWithType) {
-        this.method = method;
-        this.argName = argName;
-        this.argType = argType;
-        this.replacement = replacement;
-        this.replaceWithType = replaceWithType;
-    }
-
-    public String getMethod() {
-        return method;
-    }
-
-    public void setMethod(String method) {
-        this.method = method;
-    }
-
-    public String getArgName() {
-        return argName;
-    }
-
-    public void setArgName(String argName) {
-        this.argName = argName;
-    }
-
-    public String getArgType() {
-        return argType;
-    }
-
-    public void setArgType(String argType) {
-        this.argType = argType;
-    }
-
-    public String getReplacement() {
-        return replacement;
-    }
-
-    public void setReplacement(String replacement) {
-        this.replacement = replacement;
-    }
-
-    public boolean isReplaceWithType() {
-        return replaceWithType;
-    }
-
-    public void setReplaceWithType(boolean replaceWithType) {
-        this.replaceWithType = replaceWithType;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
deleted file mode 100644
index 0774366..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ /dev/null
@@ -1,76 +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.
-## ------------------------------------------------------------------------
-## api-collection.vm
-/*
- * Camel ApiCollection generated by camel-component-util-maven-plugin
- * Generated on: $generatedDate
- */
-package $packageName;
-
-import java.util.Map;
-import java.util.HashMap;
-
-#set( $componentConfig = "${componentName}Configuration" )
-import ${componentPackage}.${componentConfig};
-#foreach ( $api in $apis )
-import ${componentPackage}.${helper.getEndpointConfig($api.ProxyClass)};
-#end
-
-import org.apache.camel.util.component.ApiCollection;
-import org.apache.camel.util.component.ApiMethodHelper;
-
-/**
- * Camel {@link ApiCollection} for $componentName
- */
-public final class $collectionName extends ApiCollection<${apiNameEnum}, ${componentConfig}> {
-
-    private static $collectionName collection;
-
-    private ${collectionName}() {
-        final Map<String, String> aliases = new HashMap<String, String>();
-#foreach( $api in $apis )
-
-        aliases.clear();
-#foreach( $alias in $api.Aliases )
-        aliases.put("$alias.MethodPattern", "$alias.MethodAlias");
-#end
-#set( $apiMethod = ${helper.getApiMethod($api.ProxyClass)} )
-#set( $apiName = "${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}" )
-        apis.put($apiName, new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
-        apiMethods.put(${apiMethod}.class, ${apiName});
-#end
-    }
-
-    public $componentConfig getEndpointConfiguration(${apiNameEnum} apiName) {
-        $componentConfig result = null;
-        switch (apiName) {
-#foreach( $api in $apis )
-        case ${helper.getEnumConstant($api.ApiName)}:
-            result = new ${helper.getEndpointConfig($api.ProxyClass)}();
-            break;
-#end
-        }
-        return result;
-    }
-
-    public static synchronized $collectionName getCollection() {
-        if (collection == null) {
-            collection = new $collectionName();
-        }
-        return collection;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
deleted file mode 100644
index f01d29e..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
+++ /dev/null
@@ -1,47 +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.
-## ------------------------------------------------------------------------
-## api-endpoint-config.vm
-/*
- * Camel EndpointConfiguration generated by camel-component-util-maven-plugin
- * Generated on: $generatedDate
- */
-package ${componentPackage};
-
-/**
- * Camel EndpointConfiguration for $proxyType.Name
- */
-@SuppressWarnings("unused")
-public final class $configName extends ${componentName}Configuration {
-
-#foreach( $parameter in $parameters.entrySet() )
-    private $helper.getCanonicalName($parameter.Value) $parameter.Key;
-#end
-## getters and setters
-#foreach( $parameter in $parameters.entrySet() )
-#set ( $name = $parameter.Key )
-#set ( $type = $helper.getCanonicalName($parameter.Value) )
-#set ( $suffix = $helper.getBeanPropertySuffix($name) )
-
-    public $type get${suffix}() {
-        return $name;
-    }
-
-    public void set${suffix}($type $name) {
-        this.$name = $name;
-    }
-#end
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
deleted file mode 100644
index 0bc3056..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
+++ /dev/null
@@ -1,63 +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.
-## ------------------------------------------------------------------------
-## api-method-enum.vm
-/*
- * Camel ApiMethod Enumeration generated by camel-component-util-maven-plugin
- * Generated on: $generatedDate
- */
-package $packageName;
-
-import java.lang.reflect.Method;
-import java.util.List;
-
-import $proxyType.Name;
-
-import org.apache.camel.util.component.ApiMethod;
-import org.apache.camel.util.component.ApiMethodImpl;
-
-/**
- * Camel {@link ApiMethod} Enumeration for $proxyType.Name
- */
-@SuppressWarnings("unused")
-public enum $enumName implements ApiMethod {
-
-#foreach ( $model in $models )
-    ${model.UniqueName}($helper.getType($model.ResultType), "$model.Name"#foreach ( $arg in $model.Arguments ), $helper.getType($arg.Type), "$arg.Name"#end)#if ( $foreach.hasNext ),#else;#end
-
-#end
-
-    private final ApiMethod apiMethod;
-
-    private ${enumName}(Class<?> resultType, String name, Object... args) {
-        this.apiMethod = new ApiMethodImpl(${proxyType.SimpleName}.class, resultType, name, args);
-    }
-
-    @Override
-    public String getName() { return apiMethod.getName(); }
-
-    @Override
-    public Class<?> getResultType() { return apiMethod.getResultType(); }
-
-    @Override
-    public List<String> getArgNames() { return apiMethod.getArgNames(); }
-
-    @Override
-    public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); }
-
-    @Override
-    public Method getMethod() { return apiMethod.getMethod(); }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
deleted file mode 100644
index e0d558d..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
+++ /dev/null
@@ -1,56 +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.
-## ------------------------------------------------------------------------
-## api-name-enum.vm
-/*
- * Camel ApiName Enumeration generated by camel-component-util-maven-plugin
- * Generated on: $generatedDate
- */
-package $packageName;
-
-import org.apache.camel.util.component.ApiName;
-
-/**
- * Camel {@link ApiName} Enumeration for Component $componentName
- */
-public enum $apiNameEnum implements ApiName {
-
-#foreach ( $api in $apis )
-#set ( $apiName = $api.ApiName )
-    ${helper.getEnumConstant($apiName)}("$apiName")#if ( $foreach.hasNext ),#else;#end
-
-#end
-
-    private final String name;
-
-    private ${apiNameEnum}(String name) {
-        this.name = name;
-    }
-
-    @Override
-    public String getName() {
-        return name;
-    }
-
-    public static $apiNameEnum fromValue(String value) throws IllegalArgumentException {
-        for ($apiNameEnum api : ${apiNameEnum}.values()) {
-            if (api.name.equals(value)) {
-                return api;
-            }
-        }
-        throw new IllegalArgumentException("Invalid value " + value);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
deleted file mode 100644
index a3acad1..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
+++ /dev/null
@@ -1,109 +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.
-## ------------------------------------------------------------------------
-## api-route-test.vm
-/*
- * Camel Api Route test generated by camel-component-util-maven-plugin
- * Generated on: $generatedDate
- */
-package $packageName;
-
-import java.util.HashMap;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Test class for $proxyType.Name APIs.
- * TODO Move the file to src/test/java, populate parameter values, and remove @Ignore annotations.
- * The class source won't be generated again if the generator MOJO finds it under src/test/java.
- */
-public class ${testName} extends CamelTestSupport {
-
-    private static final Logger LOG = LoggerFactory.getLogger(${testName}.class);
-    private static final String PATH_PREFIX = ${componentName}ApiCollection.getCollection().getApiName(${enumName}.class).getName();
-
-#foreach ( $model in $models )
-#set ( $testName = $helper.getTestName($model) )
-#set ( $args = $model.Arguments )
-#set ( $resultType = $model.ResultType )
-#set ( $voidResult = $helper.isVoidType($resultType) )
-## are parameter values needed
-#if ( !$args.isEmpty() )
-    // TODO provide parameter values for $model.Name
-#end
-    @Ignore
-    @Test
-    public void test${testName}() throws Exception {
-## single argument, use as body
-#if ( $args.size() == 1 )
-#set ( $argType = $args.get(0).Type )
-        // using $helper.getCanonicalName($argType) message body for single parameter "$args.get(0).Name"
-## multiple arguments, pass them as headers
-#elseif ( $args.size() > 1 )
-        final HashMap<String, Object> headers = new HashMap<String, Object>();
-#foreach ( $arg in $args )
-#if ( !$arg.Type.isPrimitive() )
-        // parameter type is $helper.getCanonicalName($arg.Type)
-        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", null);
-#else
-        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
-#end
-#end
-#end
-## method invocation result
-        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) )$type result = (${type})#end
-## actual template call
-#if ( $args.isEmpty() )
-template().requestBody("direct://${model.UniqueName}", (Object)null);
-#elseif ( $args.size() == 1 )
-## typecast body to avoid requestBody() conflict
-template().requestBody("direct://${model.UniqueName}", (${helper.getCanonicalName($argType)}) $helper.getDefaultArgValue($argType));
-#else
-template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
-#end
-#if ( !$voidResult )
-
-        LOG.debug("${model.Name} :" + result);
-#end
-    }
-
-#end
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() {
-#foreach ( $model in $models )
-#set ( $args = $model.Arguments )
-                // test route for $model.Name
-                from("direct://${model.UniqueName}")
-                  .to("${scheme}://" + PATH_PREFIX + "/${model.Name}#if ( $args.size() == 1 )?inBody=${args.get(0).Name}#end");
-
-#end
-            }
-        };
-    }
-
-    @Override
-    public boolean isCreateCamelContextPerClass() {
-        // only create the context once for this class
-        return true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties
deleted file mode 100644
index 3d544fc..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,36 +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.
-#
-
-#
-# The logging properties used
-#
-log4j.rootLogger=INFO, out
-
-# uncomment the following line to turn on Camel debugging
-#log4j.logger.org.apache.camel=DEBUG
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-
-log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
-
-#log4j.logger.org.apache.camel.maven=DEBUG
-#log4j.logger.org.apache.http=DEBUG
-#log4j.logger.org.apache.camel.util.component=TRACE

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
deleted file mode 100644
index de22f82..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
+++ /dev/null
@@ -1,23 +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.component.test;
-
-/**
- * Dummy component configuration.
- */
-public class TestConfiguration {
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
deleted file mode 100644
index 48eb11b..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
+++ /dev/null
@@ -1,68 +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.component.test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class TestProxy {
-    public String sayHi() {
-        return "Hello!";
-    }
-
-    public String sayHi(boolean hello) {
-        return hello ? "Hello!" : "Hi!";
-    }
-
-    public String sayHi(final String name) {
-        return "Hello " + name;
-    }
-
-    public final String greetMe(final String name) {
-        return "Greetings " + name;
-    }
-
-    public final String greetUs(final String name1, String name2) {
-        return "Greetings " + name1 + ", " + name2;
-    }
-
-    public final String greetAll(final String[] names) {
-        StringBuilder builder = new StringBuilder("Greetings ");
-        for (String name : names) {
-            builder.append(name).append(", ");
-        }
-        builder.delete(builder.length() - 2, builder.length());
-        return builder.toString();
-    }
-
-    public final String greetAll(List<String> names) {
-        StringBuilder builder = new StringBuilder("Greetings ");
-        for (String name : names) {
-            builder.append(name).append(", ");
-        }
-        builder.delete(builder.length() - 2, builder.length());
-        return builder.toString();
-    }
-
-    public final String[] greetTimes(String name, int times) {
-        final List<String> result = new ArrayList<String>();
-        for (int i = 0; i < times; i++) {
-            result.add("Greetings " + name);
-        }
-        return result.toArray(new String[result.size()]);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
deleted file mode 100644
index 641b34e..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
+++ /dev/null
@@ -1,72 +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.util.Collections;
-import java.util.List;
-
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Model;
-import org.apache.maven.project.MavenProject;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Base class for Generator MOJO tests.
- */
-public class AbstractGeneratorMojoTest {
-    protected static final String OUT_DIR = "target/generated-test-sources/camel-component";
-
-    private static final String COMPONENT_PACKAGE = "org.apache.camel.component.test";
-    private static final String OUT_PACKAGE = COMPONENT_PACKAGE + ".internal";
-
-    protected static final String PACKAGE_PATH = OUT_PACKAGE.replaceAll("\\.", "/") + "/";
-    protected static final String COMPONENT_PACKAGE_PATH = COMPONENT_PACKAGE.replaceAll("\\.", "/") + "/";
-
-    protected static final String COMPONENT_NAME = "Test";
-    protected static final String SCHEME = "testComponent";
-
-    protected void assertExists(File outFile) {
-        assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
-    }
-
-    protected void configureMojo(AbstractGeneratorMojo mojo) {
-        mojo.componentName = COMPONENT_NAME;
-        mojo.scheme = SCHEME;
-        mojo.generatedSrcDir = new File(OUT_DIR);
-        mojo.generatedTestDir = new File(OUT_DIR);
-        mojo.outPackage = OUT_PACKAGE;
-        mojo.componentPackage = COMPONENT_PACKAGE;
-        mojo.project = new MavenProject((Model) null) {
-            @Override
-            public List getTestClasspathElements() throws DependencyResolutionRequiredException {
-                return Collections.EMPTY_LIST;
-            }
-
-            @Override
-            public Build getBuild() {
-                return new Build() {
-                    @Override
-                    public String getTestSourceDirectory() {
-                        return OUT_DIR;
-                    }
-                };
-            }
-        };
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
deleted file mode 100644
index 3e9400c..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
+++ /dev/null
@@ -1,55 +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.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.component.test.TestProxy;
-import org.apache.velocity.VelocityContext;
-import org.junit.Test;
-
-/**
- * Tests {@link ApiComponentGeneratorMojo}
- */
-public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
-
-    @Test
-    public void testExecute() throws Exception {
-
-        final File collectionFile = new File(OUT_DIR, PACKAGE_PATH + COMPONENT_NAME + "ApiCollection.java");
-
-        // delete target files to begin
-        collectionFile.delete();
-
-        final ApiComponentGeneratorMojo mojo = new ApiComponentGeneratorMojo();
-        configureMojo(mojo);
-
-        mojo.apis = new ApiProxy[2];
-        mojo.apis[0] = new ApiProxy("test", TestProxy.class.getName());
-        List<ApiMethodAlias> aliases = new ArrayList<ApiMethodAlias>();
-        aliases.add(new ApiMethodAlias("get(.+)", "$1"));
-        aliases.add(new ApiMethodAlias("set(.+)", "$1"));
-        mojo.apis[1] = new ApiProxy("velocity", VelocityContext.class.getName(), aliases);
-
-        mojo.execute();
-
-        // check target file was generated
-        assertExists(collectionFile);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
deleted file mode 100644
index d77bad7..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
+++ /dev/null
@@ -1,57 +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.IOException;
-
-import org.apache.camel.component.test.TestProxy;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests {@link FileApiMethodGeneratorMojo}
- */
-public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
-
-    @Test
-    public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
-
-        // delete target file to begin
-        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "TestProxyApiMethod.java");
-        if (outFile.exists()) {
-            outFile.delete();
-        }
-
-        final FileApiMethodGeneratorMojo mojo = new FileApiMethodGeneratorMojo();
-        mojo.substitutions = new Substitution[2];
-        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List", false);
-        mojo.substitutions[1] = new Substitution(".+", "(.+)", ".*?(\\w++)\\[\\]", "$1Array", true);
-
-        configureMojo(mojo);
-        mojo.proxyClass = TestProxy.class.getCanonicalName();
-        mojo.signatureFile = new File("src/test/resources/test-proxy-signatures.txt");
-
-        mojo.execute();
-
-        // check target file was generated
-        assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
deleted file mode 100644
index ded66dd..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
+++ /dev/null
@@ -1,58 +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.IOException;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.velocity.VelocityContext;
-import org.junit.Test;
-
-/**
- * Tests {@link JavadocApiMethodGeneratorMojo}
- */
-public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
-
-    @Test
-    public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
-
-        // delete target file to begin
-        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "VelocityContextApiMethod.java");
-        if (outFile.exists()) {
-            outFile.delete();
-        }
-
-        final JavadocApiMethodGeneratorMojo mojo = new JavadocApiMethodGeneratorMojo();
-
-        configureMojo(mojo);
-
-        // use VelocityEngine javadoc
-        mojo.proxyClass = VelocityContext.class.getCanonicalName();
-        Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey", false);
-        mojo.substitutions = new Substitution[]{ substitution };
-        mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
-        mojo.excludeMethods = "clone|Current|internal|icache";
-
-        mojo.execute();
-
-        // check target file was generated
-        assertExists(outFile);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
deleted file mode 100644
index 4c47474..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-public String sayHi();
-public String sayHi(boolean hello);
-public String sayHi(final String name);
-public final String greetMe(final String name);
-public final String greetUs(final String name1, String name2);
-public final String greetAll(String[] names);
-public final String greetAll(java.util.List<String> names);
-public final String[] greetTimes(String name, int times);

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/pom.xml b/tooling/maven/pom.xml
index fbd883e..3bb5092 100644
--- a/tooling/maven/pom.xml
+++ b/tooling/maven/pom.xml
@@ -33,7 +33,7 @@
     <module>camel-package-maven-plugin</module>
     <module>camel-maven-plugin</module>
     <module>guice-maven-plugin</module>
-    <module>camel-component-util-maven-plugin</module>
+    <module>camel-api-component-maven-plugin</module>
   </modules>
 
   <dependencies>


[22/35] git commit: Updated archetype files to first real implementation

Posted by dh...@apache.org.
Updated archetype files to first real implementation


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

Branch: refs/heads/master
Commit: 911e541323c16386371faedeb0a55f35b7ed3e9b
Parents: 96c8ec0
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 13:55:36 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:33 2014 -0700

----------------------------------------------------------------------
 .../META-INF/maven/archetype-metadata.xml       |   3 +
 .../__artifactId__-api/pom.xml                  |   8 +
 .../__artifactId__-component/pom.xml            |  12 ++
 .../src/main/java/__name__Component.java        |  76 ++++++++-
 .../src/main/java/__name__Configuration.java    |  28 ++++
 .../src/main/java/__name__Consumer.java         | 119 +++++++++++++-
 .../src/main/java/__name__Endpoint.java         | 160 ++++++++++++++++++-
 .../src/main/java/__name__Producer.java         | 155 +++++++++++++++++-
 .../main/java/internal/__name__Constants.java   |  29 ++++
 .../java/internal/__name__PropertiesHelper.java |  40 +++++
 10 files changed, 609 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
index 96b096c..f597ef5 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -37,6 +37,9 @@
     <requiredProperty key="maven-bundle-plugin-version">
       <defaultValue>${maven-bundle-plugin-version}</defaultValue>
     </requiredProperty>
+    <requiredProperty key="maven-javadoc-plugin-version">
+      <defaultValue>${maven-javadoc-plugin-version}</defaultValue>
+    </requiredProperty>
     <requiredProperty key="build-helper-maven-plugin-version">
       <defaultValue>${build-helper-maven-plugin-version}</defaultValue>
     </requiredProperty>

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
index 632a897..c4af2c8 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
@@ -50,6 +50,14 @@
             <goals>
               <goal>jar</goal>
             </goals>
+            <configuration>
+              <attach>true</attach>
+              <source>1.6</source>
+              <quiet>true</quiet>
+              <detectOfflineLinks>false</detectOfflineLinks>
+              <javadocVersion>1.6</javadocVersion>
+              <encoding>UTF-8</encoding>
+            </configuration>
           </execution>
         </executions>
       </plugin>

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index f724e37..af32397 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -197,6 +197,18 @@
                 <api>
                   <apiName>hello1</apiName>
                   <proxyClass>${package}.${name}FileSigApi</proxyClass>
+                  <!-- Use method aliases in endpoint URIs, e.g. support 'widget' as alias for getWidget or setWidget
+                  <aliases>
+                    <alias>
+                      <methodPattern>get(.+)</methodPattern>
+                      <methodAlias>$1</methodAlias>
+                    </alias>
+                    <alias>
+                      <methodPattern>set(.+)</methodPattern>
+                      <methodAlias>$1</methodAlias>
+                    </alias>
+                  </aliases>
+                  -->
                 </api>
                 <api>
                   <apiName>hello2</apiName>

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
index a87f1f4..7226fef 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
@@ -16,19 +16,89 @@
 ## ------------------------------------------------------------------------
 package ${package};
 
+import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelException;
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.IntrospectionSupport;
+
+import ${package}.internal.${name}ApiCollection;
+import ${package}.internal.${name}ApiName;
 
 /**
  * Represents the component that manages {@link ${name}Endpoint}.
  */
-public class ${name}Component extends DefaultComponent {
+@UriEndpoint(scheme = "${scheme}", consumerClass = ${name}Consumer.class, consumerPrefix = "consumer")
+public class ${name}Component extends UriEndpointComponent {
+
+    @UriParam
+    private ${name}Configuration configuration;
+
+    private final ${name}ApiCollection collection = ${name}ApiCollection.getCollection();
+
+    public ${name}Component(Class<? extends Endpoint> endpointClass) {
+        super(endpointClass);
+    }
+
+    public ${name}Component(CamelContext context, Class<? extends Endpoint> endpointClass) {
+        super(context, endpointClass);
+    }
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        Endpoint endpoint = new ${name}Endpoint(uri, this);
+        // split remaining path to get API name and method
+        final String[] pathElements = remaining.split("/");
+        String apiNameStr;
+        String methodName;
+        switch (pathElements.length) {
+            case 1:
+                apiNameStr = "";
+                methodName = pathElements[0];
+                break;
+            case 2:
+                apiNameStr = pathElements[0];
+                methodName = pathElements[1];
+                break;
+            default:
+                throw new CamelException("Invalid URI path [" + remaining +
+                "], must be of the format " + collection.getApiNames() + "/<operation-apiName>");
+        }
+        // get API enum from apiName string
+        final ${name}ApiName apiName;
+        try {
+            apiName = ${name}ApiName.fromValue(apiNameStr);
+        } catch (IllegalArgumentException e) {
+            throw new CamelException("Invalid URI path [" + apiNameStr +
+                "], must be one of " + collection.getApiNames());
+        }
+
+        final ${name}Configuration endpointConfiguration = createEndpointConfiguration(apiName);
+        final Endpoint endpoint = new ${name}Endpoint(uri, this, apiName, methodName, endpointConfiguration);
+
+        // set endpoint property inBody
         setProperties(endpoint, parameters);
         return endpoint;
     }
+
+    private ${name}Configuration createEndpointConfiguration(${name}ApiName name) throws Exception {
+        final Map<String, Object> componentProperties = new HashMap<String, Object>();
+        IntrospectionSupport.getProperties(configuration, componentProperties, null, false);
+
+        // create endpoint configuration with component properties
+        final ${name}Configuration endpointConfiguration = collection.getEndpointConfiguration(name);
+        IntrospectionSupport.setProperties(endpointConfiguration, componentProperties);
+        return endpointConfiguration;
+    }
+
+    public ${name}Configuration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(${name}Configuration configuration) {
+        this.configuration = configuration;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java
new file mode 100644
index 0000000..ce8e9c4
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java
@@ -0,0 +1,28 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+import org.apache.camel.spi.UriParams;
+
+/**
+ * Component configuration for ${name} component.
+ */
+@UriParams
+public class ${name}Configuration {
+
+    // TODO add component configuration properties
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
index 340fb68..db8201d 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
@@ -16,36 +16,125 @@
 ## ------------------------------------------------------------------------
 package ${package};
 
-import java.util.Date;
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.ScheduledPollConsumer;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ${package}.internal.${name}PropertiesHelper;
 
 /**
  * The ${name} consumer.
  */
 public class ${name}Consumer extends ScheduledPollConsumer {
 
+    private static final Logger LOG = LoggerFactory.getLogger(${name}Consumer.class);
+
     private final ${name}Endpoint endpoint;
 
+    // helpers
+    private final ${name}PropertiesHelper propertiesHelper;
+    private final ApiMethodHelper methodHelper;
+
+    // API method to invoke
+    private final Enum<? extends ApiMethod> method;
+
+    // properties used to invoke
+    private final Map<String, Object> endpointProperties;
+
     public ${name}Consumer(${name}Endpoint endpoint, Processor processor) {
         super(endpoint, processor);
+
+        // cache variables
         this.endpoint = endpoint;
+        this.propertiesHelper = ${name}PropertiesHelper.getHelper();
+        this.methodHelper = endpoint.getMethodHelper();
+
+        // determine the consumer method to invoke
+        this.method = findMethod();
+
+        // get endpoint properties in a map
+        final HashMap<String, Object> properties = new HashMap<String, Object>();
+        propertiesHelper.getEndpointProperties(endpoint.getConfiguration(), properties);
+        this.endpointProperties = Collections.unmodifiableMap(properties);
+    }
+
+    @Override
+    public boolean isGreedy() {
+        // make this consumer not greedy to avoid making too many ${name} calls
+        return false;
+    }
+
+    private Enum<? extends ApiMethod> findMethod() {
+
+        Enum<? extends ApiMethod> result;
+        // find one that takes the largest subset of endpoint parameters
+        final Set<String> argNames = new HashSet<String>();
+        argNames.addAll(propertiesHelper.getEndpointPropertyNames(endpoint.getConfiguration()));
+
+        final String[] argNamesArray = argNames.toArray(new String[argNames.size()]);
+        List<Enum<? extends ApiMethod>> filteredMethods = methodHelper.filterMethods(
+                endpoint.getCandidates(), ApiMethodHelper.MatchType.SUPER_SET, argNamesArray);
+
+        if (filteredMethods.isEmpty()) {
+            throw new IllegalArgumentException(
+                    String.format("Missing properties for %s/%s, need one or more from %s",
+                            endpoint.getApiName().getName(), endpoint.getMethodName(),
+                            methodHelper.getMissingProperties(endpoint.getMethodName(), argNames)));
+        } else if (filteredMethods.size() == 1) {
+            // single match
+            result = filteredMethods.get(0);
+        } else {
+            result = methodHelper.getHighestPriorityMethod(filteredMethods);
+            LOG.warn("Using highest priority operation {} from operations {}", method, filteredMethods);
+        }
+        return result;
     }
 
     @Override
     protected int poll() throws Exception {
-        Exchange exchange = endpoint.createExchange();
+        // invoke the consumer method
+        final Map<String, Object> args = getMethodArguments();
+        try {
+            Object result = methodHelper.invokeMethod(endpoint.getApiProxy(), method, args);
 
-        // create a message body
-        Date now = new Date();
-        exchange.getIn().setBody("Hello World! The time is " + now);
+            // process result according to type
+            if (result != null && (result instanceof Collection || result.getClass().isArray())) {
+                // create an exchange for every element
+                final Object array = getResultAsArray(result);
+                final int length = Array.getLength(array);
+                for (int i = 0; i < length; i++) {
+                    processResult(Array.get(array, i));
+                }
+                return length;
+            } else {
+                processResult(result);
+                return 1; // number of messages polled
+            }
+        } catch (Throwable t) {
+            throw ObjectHelper.wrapRuntimeCamelException(t);
+        }
+    }
 
+    private void processResult(Object result) throws Exception {
+        Exchange exchange = getEndpoint().createExchange();
+        exchange.getIn().setBody(result);
         try {
             // send message to next processor in the route
             getProcessor().process(exchange);
-            return 1; // number of messages polled
         } finally {
             // log exception if an exception occurred and was not handled
             if (exchange.getException() != null) {
@@ -53,4 +142,22 @@ public class ${name}Consumer extends ScheduledPollConsumer {
             }
         }
     }
+
+    private Object getResultAsArray(Object result) {
+        if (result.getClass().isArray()) {
+            // no conversion needed
+            return result;
+        }
+        // must be a Collection
+        Collection<?> collection = (Collection<?>) result;
+        return collection.toArray(new Object[collection.size()]);
+    }
+
+    private Map<String, Object> getMethodArguments() {
+        Map<String, Object> arguments = new HashMap<String, Object>();
+        arguments.putAll(endpointProperties);
+
+        // TODO do consumer specific argument manipulation, such as setting constants or per poll properties
+        return arguments;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
index 9c25c8e..73b87a6 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
@@ -16,25 +16,73 @@
 ## ------------------------------------------------------------------------
 package ${package};
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.EndpointHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ${package}.internal.${name}ApiCollection;
+import ${package}.internal.${name}ApiName;
+import ${package}.internal.${name}PropertiesHelper;
 
 /**
  * Represents a ${name} endpoint.
  */
+@UriEndpoint(scheme = "${scheme}", consumerClass = ${name}Consumer.class, consumerPrefix = "consumer")
 public class ${name}Endpoint extends DefaultEndpoint {
 
-    public ${name}Endpoint() {
-    }
+    private static final Logger LOG = LoggerFactory.getLogger(${name}Endpoint.class);
+
+    @UriParam
+    private final ${name}Configuration configuration;
+
+    // property name for Exchange 'In' message body
+    @UriParam
+    private String inBody;
+
+    // API name
+    private final ${name}ApiName apiName;
 
-    public ${name}Endpoint(String uri, ${name}Component component) {
+    // API method name
+    private final String methodName;
+
+    // API method helper
+    private final ApiMethodHelper methodHelper;
+
+    // candidate methods based on method name and endpoint configuration
+    private List<Enum<? extends ApiMethod>> candidates;
+
+    // TODO create and manage API proxies
+    private final Map<${name}ApiName, Object> proxyCache;
+
+    public ${name}Endpoint(String uri, ${name}Component component, ${name}ApiName apiName, String methodName, ${name}Configuration endpointConfiguration) {
         super(uri, component);
-    }
+        this.apiName = apiName;
+        this.methodName = methodName;
+        this.configuration = endpointConfiguration;
 
-    public ${name}Endpoint(String endpointUri) {
-        super(endpointUri);
+        methodHelper = ${name}ApiCollection.getCollection().getHelper(apiName);
+
+        // TODO manage API proxies
+        proxyCache = new HashMap<${name}ApiName, Object>();
+        proxyCache.put(${name}ApiName.HELLO1, new ${name}FileSigApi());
+        proxyCache.put(${name}ApiName.HELLO2, new ${name}JavadocSigApi());
     }
 
     public Producer createProducer() throws Exception {
@@ -42,10 +90,108 @@ public class ${name}Endpoint extends DefaultEndpoint {
     }
 
     public Consumer createConsumer(Processor processor) throws Exception {
-        return new ${name}Consumer(this, processor);
+        // make sure inBody is not set for consumers
+        if (inBody != null) {
+            throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
+        }
+        final ${name}Consumer consumer = new ${name}Consumer(this, processor);
+        // also set consumer.* properties
+        configureConsumer(consumer);
+        return consumer;
     }
 
     public boolean isSingleton() {
         return true;
     }
+
+    @Override
+    public void configureProperties(Map<String, Object> options) {
+        super.configureProperties(options);
+
+        // set configuration properties first
+        try {
+            EndpointHelper.setReferenceProperties(getCamelContext(), configuration, options);
+            EndpointHelper.setProperties(getCamelContext(), configuration, options);
+        } catch (Exception e) {
+            throw new IllegalArgumentException(e.getMessage(), e);
+        }
+
+        // validate and initialize state
+        initState();
+    }
+
+    private void initState() {
+
+        // get endpoint property names
+        final Set<String> arguments = new HashSet<String>();
+        arguments.addAll(${name}PropertiesHelper.getHelper().getEndpointPropertyNames(configuration));
+
+        // add inBody argument for producers
+        if (inBody != null) {
+            arguments.add(inBody);
+        }
+        final String[] argNames = arguments.toArray(new String[arguments.size()]);
+
+        // create a list of candidate methods
+        candidates = new ArrayList<Enum<? extends ApiMethod>>();
+        candidates.addAll(methodHelper.getCandidateMethods(methodName, argNames));
+
+        // error if there are no candidates
+        if (candidates.isEmpty()) {
+            throw new IllegalArgumentException(
+                    String.format("No matching method for %s/%s, with arguments %s",
+                            apiName.getName(), methodName, arguments));
+        }
+
+        // log missing/extra properties for debugging
+        if (LOG.isDebugEnabled()) {
+            final Set<String> missing = methodHelper.getMissingProperties(methodName, arguments);
+            if (!missing.isEmpty()) {
+                LOG.debug("Method {} could use one or more properties from {}", methodName, missing);
+            }
+        }
+    }
+
+    @Override
+    public ${name}Component getComponent() {
+        return (${name}Component) super.getComponent();
+    }
+
+    public ${name}Configuration getConfiguration() {
+        return configuration;
+    }
+
+    public ${name}ApiName getApiName() {
+        return apiName;
+    }
+
+    public String getMethodName() {
+        return methodName;
+    }
+
+    public ApiMethodHelper getMethodHelper() {
+        return methodHelper;
+    }
+
+    public List<Enum<? extends ApiMethod>> getCandidates() {
+        return Collections.unmodifiableList(candidates);
+    }
+
+    public String getInBody() {
+        return inBody;
+    }
+
+    public void setInBody(String inBody) {
+        // validate property name
+        ObjectHelper.notNull(inBody, "inBody");
+        if (!${name}PropertiesHelper.getHelper().getValidEndpointProperties(configuration).contains(inBody)) {
+            throw new IllegalArgumentException("Unknown property " + inBody);
+        }
+        this.inBody = inBody;
+    }
+
+    public Object getApiProxy() {
+        // TODO manage API proxies
+        return proxyCache.get(apiName);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
index 3fd064a..ece4283 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
@@ -16,25 +16,170 @@
 ## ------------------------------------------------------------------------
 package ${package};
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultAsyncProducer;
+import org.apache.camel.spi.ExecutorServiceManager;
+import org.apache.camel.spi.ThreadPoolProfile;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import ${package}.internal.${name}Constants;
+import ${package}.internal.${name}PropertiesHelper;
+
 /**
  * The ${name} producer.
  */
-public class ${name}Producer extends DefaultProducer {
-    private static final Logger LOG = LoggerFactory.getLogger(${name}Producer.class);
+public class ${name}Producer extends DefaultAsyncProducer {
+    private static final transient Logger LOG = LoggerFactory.getLogger(${name}Producer.class);
+
+    // thread pool executor
+    private static ExecutorService executorService;
+
     private ${name}Endpoint endpoint;
 
+    private final ${name}PropertiesHelper propertiesHelper;
+    private final ApiMethodHelper methodHelper;
+
     public ${name}Producer(${name}Endpoint endpoint) {
         super(endpoint);
         this.endpoint = endpoint;
+
+        // cache helpers
+        this.propertiesHelper = ${name}PropertiesHelper.getHelper();
+        this.methodHelper = endpoint.getMethodHelper();
     }
 
-    public void process(Exchange exchange) throws Exception {
-        System.out.println(exchange.getIn().getBody());    
+    @Override
+    public boolean process(final Exchange exchange, final AsyncCallback callback) {
+        // properties for method arguments
+        final Map<String, Object> properties = new HashMap<String, Object>();
+        propertiesHelper.getEndpointProperties(endpoint.getConfiguration(), properties);
+        propertiesHelper.getExchangeProperties(exchange, properties);
+
+        // decide which method to invoke
+        final Enum<? extends ApiMethod> method = findMethod(exchange, properties);
+        if (method == null) {
+            // synchronous failure
+            callback.done(true);
+            return true;
+        }
+
+        // create a runnable invocation task to be submitted on a background thread pool
+        // this way we avoid blocking the current thread for long running methods
+        Runnable invocation = new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Invoking operation {} with {}", ((ApiMethod)method).getName(), properties.keySet());
+                    }
+
+                    // also check whether we need to get Raw JSON
+                    Object result = methodHelper.invokeMethod(endpoint.getApiProxy(), method, properties);
+
+                    // producer returns a single response, even for methods with List return types
+                    exchange.getOut().setBody(result);
+                    // copy headers
+                    exchange.getOut().setHeaders(exchange.getIn().getHeaders());
+
+                } catch (Throwable t) {
+                    exchange.setException(ObjectHelper.wrapRuntimeCamelException(t));
+                } finally {
+                    callback.done(false);
+                }
+            }
+        };
+
+        getExecutorService(getEndpoint().getCamelContext()).submit(invocation);
+        return false;
+    }
+
+    private Enum<? extends ApiMethod> findMethod(Exchange exchange, Map<String, Object> properties) {
+
+        Enum<? extends ApiMethod> method = null;
+        final List<Enum<? extends ApiMethod>> candidates = endpoint.getCandidates();
+        if (processInBody(exchange, properties)) {
+
+            // filter candidates based on endpoint and exchange properties
+            final Set<String> argNames = properties.keySet();
+            final List<Enum<? extends ApiMethod>> filteredMethods = methodHelper.filterMethods(candidates,
+                    ApiMethodHelper.MatchType.SUPER_SET,
+                    argNames.toArray(new String[argNames.size()]));
+
+            // get the method to call
+            if (filteredMethods.isEmpty()) {
+                final Set<String> missing = methodHelper.getMissingProperties(endpoint.getMethodName(), argNames);
+                throw new RuntimeCamelException(String.format("Missing properties for %s, need one or more from %s",
+                        endpoint.getMethodName(), missing));
+            } else if (filteredMethods.size() == 1) {
+                // found an exact match
+                method = filteredMethods.get(0);
+            } else {
+                method = methodHelper.getHighestPriorityMethod(filteredMethods);
+                LOG.warn("Calling highest priority operation {} from operations {}", method, filteredMethods);
+            }
+        }
+
+        return method;
+    }
+
+    // returns false on exception, which is set in exchange
+    private boolean processInBody(Exchange exchange, Map<String, Object> properties) {
+        final String inBodyProperty = endpoint.getInBody();
+        if (inBodyProperty != null) {
+
+            Object value = exchange.getIn().getBody();
+            try {
+                value = getEndpoint().getCamelContext().getTypeConverter().mandatoryConvertTo(
+                        endpoint.getConfiguration().getClass().getDeclaredField(inBodyProperty).getType(),
+                        exchange, value);
+            } catch (Exception e) {
+                exchange.setException(new RuntimeCamelException(String.format(
+                        "Error converting value %s to property %s: %s", value, inBodyProperty, e.getMessage()), e));
+
+                return false;
+            }
+
+            LOG.debug("Property [{}] has message body value {}", inBodyProperty, value);
+            properties.put(inBodyProperty, value);
+        }
+
+        return true;
+    }
+
+    protected static synchronized ExecutorService getExecutorService(CamelContext context) {
+        // CamelContext will shutdown thread pool when it shutdown so we can
+        // lazy create it on demand
+        // but in case of hot-deploy or the likes we need to be able to
+        // re-create it (its a shared static instance)
+        if (executorService == null || executorService.isTerminated() || executorService.isShutdown()) {
+            final ExecutorServiceManager manager = context.getExecutorServiceManager();
+
+            // try to lookup a pool first based on profile
+            ThreadPoolProfile poolProfile = manager.getThreadPoolProfile(
+                    ${name}Constants.THREAD_PROFILE_NAME);
+            if (poolProfile == null) {
+                poolProfile = manager.getDefaultThreadPoolProfile();
+            }
+
+            // create a new pool using the custom or default profile
+            executorService = manager.newScheduledThreadPool(${name}Producer.class,
+                    ${name}Constants.THREAD_PROFILE_NAME, poolProfile);
+        }
+
+        return executorService;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__Constants.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__Constants.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__Constants.java
new file mode 100644
index 0000000..90e0f1a
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__Constants.java
@@ -0,0 +1,29 @@
+## ------------------------------------------------------------------------
+## 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 ${package}.internal;
+
+/**
+ * Constants for ${name} component.
+ */
+public interface ${name}Constants {
+
+    // suffix for parameters when passed as exchange header properties
+    String PROPERTY_PREFIX = "Camel${name}.";
+
+    // thread profile name for this component
+    String THREAD_PROFILE_NAME = "Camel${name}";
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/911e5413/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__PropertiesHelper.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__PropertiesHelper.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__PropertiesHelper.java
new file mode 100644
index 0000000..fe6910c
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/internal/__name__PropertiesHelper.java
@@ -0,0 +1,40 @@
+## ------------------------------------------------------------------------
+## 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 ${package}.internal;
+
+import org.apache.camel.util.component.ApiMethodPropertiesHelper;
+
+import ${package}.${name}Configuration;
+
+/**
+ * Singleton {@link ApiMethodPropertiesHelper} for ${name} component.
+ */
+public final class ${name}PropertiesHelper extends ApiMethodPropertiesHelper<${name}Configuration> {
+
+    private static ${name}PropertiesHelper helper;
+
+    private ${name}PropertiesHelper() {
+        super(${name}Configuration.class, ${name}Constants.PROPERTY_PREFIX);
+    }
+
+    public static synchronized ${name}PropertiesHelper getHelper() {
+        if (helper == null) {
+            helper = new ${name}PropertiesHelper();
+        }
+        return helper;
+    }
+}


[27/35] git commit: Added missing '/' to test route path

Posted by dh...@apache.org.
Added missing '/' to test route path


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

Branch: refs/heads/master
Commit: e309bf8febdd57c54359b4a3532c35f189ed820e
Parents: bbb4127
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Thu Jun 5 11:40:53 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:34 2014 -0700

----------------------------------------------------------------------
 .../src/main/resources/api-route-test.vm                           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e309bf8f/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
index 78d6301..a3acad1 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
@@ -94,7 +94,7 @@ template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
 #set ( $args = $model.Arguments )
                 // test route for $model.Name
                 from("direct://${model.UniqueName}")
-                  .to("${scheme}://" + PATH_PREFIX + "${model.Name}#if ( $args.size() == 1 )?inBody=${args.get(0).Name}#end");
+                  .to("${scheme}://" + PATH_PREFIX + "/${model.Name}#if ( $args.size() == 1 )?inBody=${args.get(0).Name}#end");
 
 #end
             }


[12/35] git commit: Added substitution for duplicate argument name key

Posted by dh...@apache.org.
Added substitution for duplicate argument name key


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

Branch: refs/heads/master
Commit: 99ccd3775e81573f8de516cd4b8ee42fb7850a43
Parents: ee191eb
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:21:43 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java  | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/99ccd377/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
index 3528eda..dd252f2 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -56,6 +56,8 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
             }
         };
         mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
+        Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey");
+        mojo.substitutions = new Substitution[]{ substitution };
 
         mojo.execute();
 


[09/35] git commit: Added generated source validation, refactored package_path in unit tests

Posted by dh...@apache.org.
Added generated source validation, refactored package_path in unit tests


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

Branch: refs/heads/master
Commit: 03f63df8c6b3994e8a157e9545f56f5baec53607
Parents: ecee7f1
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon May 26 06:04:01 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:30 2014 -0700

----------------------------------------------------------------------
 .../camel-component-util-maven-plugin/pom.xml   | 34 ++++++++++++++++++++
 .../camel/maven/AbstractGeneratorMojoTest.java  |  2 +-
 .../maven/ApiComponentGeneratorMojoTest.java    |  2 +-
 .../maven/FileApiMethodGeneratorMojoTest.java   |  2 +-
 .../JavadocApiMethodGeneratorMojoTest.java      |  3 +-
 5 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/03f63df8/tooling/maven/camel-component-util-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/pom.xml b/tooling/maven/camel-component-util-maven-plugin/pom.xml
index 350cd08..90a9aea 100644
--- a/tooling/maven/camel-component-util-maven-plugin/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/pom.xml
@@ -121,6 +121,40 @@
           </plugin>
       </plugins>
     </pluginManagement>
+    <plugins>
+      <!-- validate generated code after unit tests -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-generated-test-sources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-test-sources/camelComponent</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>validate-generated-test-sources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
   </build>
 
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/03f63df8/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
index eaaf704..07edb41 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue;
  */
 public class AbstractGeneratorMojoTest {
     protected static final String OUT_DIR = "target/generated-test-sources/camelComponent";
-    protected static final String PACKAGE_PATH = AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/");
+    protected static final String PACKAGE_PATH = AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/") + "/";
 
     protected void assertExists(File outFile) {
         assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());

http://git-wip-us.apache.org/repos/asf/camel/blob/03f63df8/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
index 3176755..b0f8168 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
@@ -41,7 +41,7 @@ public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
         final File outDir = new File(OUT_DIR);
         FileUtil.removeDir(outDir);
 
-        final File collectionFile = new File(OUT_DIR, PACKAGE_PATH + "/" + COMPONENT_NAME + "ApiCollection.java");
+        final File collectionFile = new File(OUT_DIR, PACKAGE_PATH + COMPONENT_NAME + "ApiCollection.java");
 
         final ApiComponentGeneratorMojo mojo = new ApiComponentGeneratorMojo();
         mojo.componentName = COMPONENT_NAME;

http://git-wip-us.apache.org/repos/asf/camel/blob/03f63df8/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
index 7f9661e..20c4a5a 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
@@ -38,7 +38,7 @@ public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
     public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
 
         // delete target file to begin
-        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "/TestProxyApiMethod.java");
+        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "TestProxyApiMethod.java");
         if (outFile.exists()) {
             outFile.delete();
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/03f63df8/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
index 8ac2d46..3528eda 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -38,7 +38,7 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
     public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
 
         // delete target file to begin
-        final File outFile = new File(OUT_DIR, AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/") + "/VelocityEngineApiMethod.java");
+        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "VelocityEngineApiMethod.java");
         if (outFile.exists()) {
             outFile.delete();
         }
@@ -62,5 +62,4 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
         // check target file was generated
         assertExists(outFile);
     }
-
 }


[35/35] git commit: Added replaceWithType feature to argument Substitution to allow replacing argument name with substituted type string

Posted by dh...@apache.org.
Added replaceWithType feature to argument Substitution to allow replacing argument name with substituted type string


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

Branch: refs/heads/master
Commit: 420fed02190d00416480e4df809cb3e343e22497
Parents: 4b07979
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon Jun 9 14:25:59 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:35 2014 -0700

----------------------------------------------------------------------
 .../component/ArgumentSubstitutionParser.java   | 76 ++++++++++++++++----
 .../ArgumentSubstitutionParserTest.java         |  8 ++-
 .../__artifactId__-component/pom.xml            |  2 +
 .../src/it/all-it/pom.xml                       |  7 ++
 .../maven/AbstractApiMethodGeneratorMojo.java   |  6 +-
 .../org/apache/camel/maven/Substitution.java    | 12 +++-
 .../maven/FileApiMethodGeneratorMojoTest.java   |  5 +-
 .../JavadocApiMethodGeneratorMojoTest.java      |  2 +-
 8 files changed, 95 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
index 0ebf63c..2544dff 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
@@ -23,24 +23,25 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
         super(proxyType);
         Map<String, Map<String, List<NameReplacement>>> regexMap = new LinkedHashMap<String, Map<String, List<NameReplacement>>>();
 
-        for (Substitution tuple : substitutions) {
-            tuple.validate();
+        for (Substitution substitution : substitutions) {
+            substitution.validate();
 
             final NameReplacement nameReplacement = new NameReplacement();
-            nameReplacement.replacement = tuple.replacement;
-            if (tuple.argType != null) {
-                nameReplacement.type = forName(tuple.argType);
+            nameReplacement.replacement = substitution.replacement;
+            if (substitution.argType != null) {
+                nameReplacement.typePattern = Pattern.compile(substitution.argType);
             }
+            nameReplacement.replaceWithType = substitution.replaceWithType;
 
-            Map<String, List<NameReplacement>> replacementMap = regexMap.get(tuple.method);
+            Map<String, List<NameReplacement>> replacementMap = regexMap.get(substitution.method);
             if (replacementMap == null) {
                 replacementMap = new LinkedHashMap<String, List<NameReplacement>>();
-                regexMap.put(tuple.method, replacementMap);
+                regexMap.put(substitution.method, replacementMap);
             }
-            List<NameReplacement> replacements = replacementMap.get(tuple.argName);
+            List<NameReplacement> replacements = replacementMap.get(substitution.argName);
             if (replacements == null) {
                 replacements = new ArrayList<NameReplacement>();
-                replacementMap.put(tuple.argName, replacements);
+                replacementMap.put(substitution.argName, replacements);
             }
             replacements.add(nameReplacement);
         }
@@ -63,19 +64,40 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
         for (ApiMethodModel model : parseResult) {
             // look for method name matches
             for (Map.Entry<Pattern, Map<Pattern, List<NameReplacement>>> methodEntry : methodMap.entrySet()) {
+                // match the whole method name
                 if (methodEntry.getKey().matcher(model.getName()).matches()) {
 
                     // look for arg name matches
                     final List<Argument> updatedArguments = new ArrayList<Argument>();
                     final Map<Pattern, List<NameReplacement>> argMap = methodEntry.getValue();
                     for (Argument argument : model.getArguments()) {
+                        final Class<?> argType = argument.getType();
+                        final String argTypeName = argType.getCanonicalName();
+
                         for (Map.Entry<Pattern, List<NameReplacement>> argEntry : argMap.entrySet()) {
                             final Matcher matcher = argEntry.getKey().matcher(argument.getName());
+
+                            // match argument name substring
                             if (matcher.find()) {
                                 final List<NameReplacement> adapters = argEntry.getValue();
                                 for (NameReplacement adapter : adapters) {
-                                    if (adapter.type == null || adapter.type == argument.getType()) {
-                                        argument = new Argument(matcher.replaceAll(adapter.replacement), argument.getType());
+                                    if (adapter.typePattern == null) {
+                                        // no type pattern
+                                        final String newName = getJavaArgName(matcher.replaceAll(adapter.replacement));
+                                        argument = new Argument(newName, argType);
+                                    } else {
+                                        final Matcher typeMatcher = adapter.typePattern.matcher(argTypeName);
+                                        if (typeMatcher.find()) {
+                                            if (!adapter.replaceWithType) {
+                                                // replace argument name
+                                                final String newName = getJavaArgName(matcher.replaceAll(adapter.replacement));
+                                                argument = new Argument(newName, argType);
+                                            } else {
+                                                // replace name with argument type name
+                                                final String newName = getJavaArgName(typeMatcher.replaceAll(adapter.replacement));
+                                                argument = new Argument(newName, argType);
+                                            }
+                                        }
                                     }
                                 }
                             }
@@ -95,12 +117,24 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
         return result;
     }
 
+    private String getJavaArgName(String name) {
+        // make sure the first character is lowercase
+        // useful for replacement using type names
+        char firstChar = name.charAt(0);
+        if (Character.isLowerCase(firstChar)) {
+            return name;
+        } else {
+            return Character.toLowerCase(firstChar) + name.substring(1);
+        }
+    }
+
     public static class Substitution {
 
         private String method;
         private String argName;
         private String argType;
         private String replacement;
+        private boolean replaceWithType;
 
         /**
          * Creates a substitution for all argument types.
@@ -122,10 +156,21 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
          * @param replacement replacement text for argument name
          */
         public Substitution(String method, String argName, String argType, String replacement) {
-            this.method = method;
-            this.argName = argName;
+            this(method, argName, replacement);
             this.argType = argType;
-            this.replacement = replacement;
+        }
+
+        /**
+         * Create a substitution for a specific argument type and flag to indicate whether the replacement uses
+         * @param method
+         * @param argName
+         * @param argType
+         * @param replacement
+         * @param replaceWithType
+         */
+        public Substitution(String method, String argName, String argType, String replacement, boolean replaceWithType) {
+            this(method, argName, argType, replacement);
+            this.replaceWithType = replaceWithType;
         }
 
         public void validate() {
@@ -137,6 +182,7 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
 
     private static class NameReplacement {
         private String replacement;
-        private Class<?> type;
+        private Pattern typePattern;
+        private boolean replaceWithType;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java b/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
index ce0153d..a9487c0 100644
--- a/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
@@ -14,10 +14,11 @@ public class ArgumentSubstitutionParserTest {
     @Test
     public void testParse() throws Exception {
 
-        final Substitution[] adapters = new Substitution[3];
+        final Substitution[] adapters = new Substitution[4];
         adapters[0] = new Substitution(".+", "name", PERSON);
         adapters[1] = new Substitution("greet.+", "person([0-9]+)", "astronaut$1");
         adapters[2] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
+        adapters[3] = new Substitution(".+", "(.+)", ".*?(\\w++)\\[\\]", "$1Array", true);
 
         final ApiMethodParser<TestProxy> parser = new ArgumentSubstitutionParser<TestProxy>(TestProxy.class, adapters);
 
@@ -45,8 +46,11 @@ public class ArgumentSubstitutionParserTest {
         assertEquals("astronaut1", greetUs.getArguments().get(0).getName());
         assertEquals("astronaut2", greetUs.getArguments().get(1).getName());
 
-        final ApiMethodParser.ApiMethodModel greetAll = methodModels.get(1);
+        final ApiMethodParser.ApiMethodModel greetAll = methodModels.get(0);
         assertEquals("personsList", greetAll.getArguments().get(0).getName());
+
+        final ApiMethodParser.ApiMethodModel greetAll1 = methodModels.get(1);
+        assertEquals("stringArray", greetAll1.getArguments().get(0).getName());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index 31cf249..8e66c2c 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -157,6 +157,7 @@
                   <argName>^.+$</argName>
                   <argType>java.lang.String</argType>
                   <replacement>$1Param</replacement>
+                  <replaceWithType>false</replaceWithType>
                 </substitution>
               </substitutions>
               -->
@@ -181,6 +182,7 @@
                   <argName>^.+$</argName>
                   <argType>java.lang.String</argType>
                   <replacement>$1Arg</replacement>
+                  <replaceWithType>false</replaceWithType>
                 </substitution>
               </substitutions>
               -->

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
index 9f6f877..d13ef72 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
@@ -89,6 +89,13 @@
                   <argType>java.util.List</argType>
                   <replacement>$1List</replacement>
                 </substitution>
+                <substitution>
+                  <method>.+</method>
+                  <argName>(.+)</argName>
+                  <argType>.*?(\w++)\[\]</argType>
+                  <replacement>$1Array</replacement>
+                  <replaceWithType>true</replaceWithType>
+                </substitution>
               </substitutions>
               <signatureFile>../../../src/test/resources/test-proxy-signatures.txt</signatureFile>
             </configuration>

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
index 445ceda..852b09e 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -174,8 +174,10 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
     public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
         ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
         for (int i = 0; i < substitutions.length; i++) {
-            subs[i] = new ArgumentSubstitutionParser.Substitution(substitutions[i].getMethod(),
-                    substitutions[i].getArgName(), substitutions[i].getArgType(), substitutions[i].getReplacement());
+            final Substitution substitution = substitutions[i];
+            subs[i] = new ArgumentSubstitutionParser.Substitution(substitution.getMethod(),
+                    substitution.getArgName(), substitution.getArgType(),
+                    substitution.getReplacement(), substitution.isReplaceWithType());
         }
         return subs;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
index 0e7b2a8..d16e041 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
@@ -25,15 +25,17 @@ public class Substitution {
     private String argName;
     private String argType;
     private String replacement;
+    private boolean replaceWithType;
 
     public Substitution() {
     }
 
-    public Substitution(String method, String argName, String argType, String replacement) {
+    public Substitution(String method, String argName, String argType, String replacement, boolean replaceWithType) {
         this.method = method;
         this.argName = argName;
         this.argType = argType;
         this.replacement = replacement;
+        this.replaceWithType = replaceWithType;
     }
 
     public String getMethod() {
@@ -67,4 +69,12 @@ public class Substitution {
     public void setReplacement(String replacement) {
         this.replacement = replacement;
     }
+
+    public boolean isReplaceWithType() {
+        return replaceWithType;
+    }
+
+    public void setReplaceWithType(boolean replaceWithType) {
+        this.replaceWithType = replaceWithType;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
index b59aed1..d77bad7 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
@@ -40,8 +40,9 @@ public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
         }
 
         final FileApiMethodGeneratorMojo mojo = new FileApiMethodGeneratorMojo();
-        mojo.substitutions = new Substitution[1];
-        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
+        mojo.substitutions = new Substitution[2];
+        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List", false);
+        mojo.substitutions[1] = new Substitution(".+", "(.+)", ".*?(\\w++)\\[\\]", "$1Array", true);
 
         configureMojo(mojo);
         mojo.proxyClass = TestProxy.class.getCanonicalName();

http://git-wip-us.apache.org/repos/asf/camel/blob/420fed02/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
index 0292111..ded66dd 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -44,7 +44,7 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
 
         // use VelocityEngine javadoc
         mojo.proxyClass = VelocityContext.class.getCanonicalName();
-        Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey");
+        Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey", false);
         mojo.substitutions = new Substitution[]{ substitution };
         mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
         mojo.excludeMethods = "clone|Current|internal|icache";


[03/35] git commit: Made ApiMethodParser.parse() final and added processResults to avoid warnings from ApiMethodParser

Posted by dh...@apache.org.
Made ApiMethodParser.parse() final and added processResults to avoid warnings from ApiMethodParser


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

Branch: refs/heads/master
Commit: 7431e7e9fa9c8ce2d2477fb0a17d16a44e0255d1
Parents: 2ffeacc
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 23 18:33:04 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:29 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodParser.java   |  8 +++-
 .../component/ArgumentSubstitutionParser.java   |  4 +-
 .../apache/camel/maven/TestProxyApiMethod.java  | 48 ++++++++++++++++++++
 3 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7431e7e9/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
index 4c6523a..58ada5a 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -88,7 +88,7 @@ public abstract class ApiMethodParser<T> {
      * Parses the method signatures from {@code getSignatures()}.
      * @return list of Api methods as {@link ApiMethodModel}
      */
-    public List<ApiMethodModel> parse() {
+    public final List<ApiMethodModel> parse() {
         // parse sorted signatures and generate descriptions
         List<ApiMethodModel> result = new ArrayList<ApiMethodModel>();
         for (String signature: signatures) {
@@ -124,6 +124,8 @@ public abstract class ApiMethodParser<T> {
             result.add(new ApiMethodModel(name, resultType, arguments, method));
         }
 
+        result = processResults(result);
+
         Collections.sort(result, new Comparator<ApiMethodModel>() {
             @Override
             public int compare(ApiMethodModel model1, ApiMethodModel model2) {
@@ -171,6 +173,10 @@ public abstract class ApiMethodParser<T> {
         return result;
     }
 
+    protected List<ApiMethodModel> processResults(List<ApiMethodModel> result) {
+        return result;
+    }
+
     protected Class<?> forName(String className) {
         return forName(className, classLoader);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/7431e7e9/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
index 0e15833..43f60e9 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
@@ -57,10 +57,10 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
     }
 
     @Override
-    public List<ApiMethodModel> parse() {
+    public List<ApiMethodModel> processResults(List<ApiMethodModel> parseResult) {
         final List<ApiMethodModel> result = new ArrayList<ApiMethodModel>();
 
-        for (ApiMethodModel model : super.parse()) {
+        for (ApiMethodModel model : parseResult) {
             // look for method name matches
             for (Map.Entry<Pattern, Map<Pattern, List<NameReplacement>>> methodEntry : methodMap.entrySet()) {
                 if (methodEntry.getKey().matcher(model.getName()).matches()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/7431e7e9/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java
new file mode 100644
index 0000000..2a5bee2
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxyApiMethod.java
@@ -0,0 +1,48 @@
+/*
+ * Camel ApiMethod Enumeration generated by camel-component-util-maven-plugin
+ * Generated on: Fri May 23 17:35:21 PDT 2014
+ */
+package org.apache.camel.maven;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.camel.maven.TestProxy;
+
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodImpl;
+
+/**
+ * Camel {@link ApiMethod} Enumeration for org.apache.camel.maven.TestProxy
+ */
+public enum TestProxyApiMethod implements ApiMethod {
+
+    GREETALL(java.lang.String.class, "greetAll", new java.lang.String[0].getClass(), "names"),
+    GREETALL_1(java.lang.String.class, "greetAll", java.util.List.class, "namesList"),
+    GREETME(java.lang.String.class, "greetMe", java.lang.String.class, "name"),
+    GREETTIMES(new java.lang.String[0].getClass(), "greetTimes", java.lang.String.class, "name", int.class, "times"),
+    GREETUS(java.lang.String.class, "greetUs", java.lang.String.class, "name1", java.lang.String.class, "name2"),
+    SAYHI(java.lang.String.class, "sayHi"),
+    SAYHI_1(java.lang.String.class, "sayHi", java.lang.String.class, "name");
+
+    private final ApiMethod apiMethod;
+
+    private TestProxyApiMethod(Class<?> resultType, String name, Object... args) {
+        this.apiMethod = new ApiMethodImpl(TestProxy.class, resultType, name, args);
+    }
+
+    @Override
+    public String getName() { return apiMethod.getName(); }
+
+    @Override
+    public Class<?> getResultType() { return apiMethod.getResultType(); }
+
+    @Override
+    public List<String> getArgNames() { return apiMethod.getArgNames(); }
+
+    @Override
+    public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); }
+
+    @Override
+    public Method getMethod() { return apiMethod.getMethod(); }
+}


[20/35] git commit: Added support for generating endpoint config using component-util plugin, added integration tests, refactored unit tests, cleaned-up generated code

Posted by dh...@apache.org.
Added support for generating endpoint config using component-util plugin, added integration tests, refactored unit tests, cleaned-up generated code


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

Branch: refs/heads/master
Commit: fad48654b42248ddbd1125afc43a6e8b82bd0af9
Parents: 24e196b
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 30 12:48:09 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:32 2014 -0700

----------------------------------------------------------------------
 .../camel-component-util-maven-plugin/pom.xml   |  76 +++++++-
 .../src/it/all-it/pom.xml                       | 178 +++++++++++++++++++
 .../src/it/all-it/verify.groovy                 |  22 +++
 .../src/it/settings.xml                         |  55 ++++++
 .../maven/AbstractApiMethodGeneratorMojo.java   |  64 ++++++-
 .../camel/maven/AbstractGeneratorMojo.java      |  18 +-
 .../java/org/apache/camel/maven/ApiProxy.java   |   8 +
 .../maven/JavadocApiMethodGeneratorMojo.java    |  23 ++-
 .../org/apache/camel/maven/Substitution.java    |   3 +
 .../src/main/resources/api-collection.vm        |   2 +-
 .../src/main/resources/api-endpoint-config.vm   |  47 +++++
 .../src/main/resources/api-method-enum.vm       |   1 +
 .../src/main/resources/api-route-test.vm        |  16 +-
 .../apache/camel/component/test/TestConfig.java |  23 +++
 .../apache/camel/component/test/TestProxy.java  |  68 +++++++
 .../camel/maven/AbstractGeneratorMojoTest.java  |  15 +-
 .../maven/ApiComponentGeneratorMojoTest.java    |  15 +-
 .../maven/FileApiMethodGeneratorMojoTest.java   |   1 +
 .../JavadocApiMethodGeneratorMojoTest.java      |   3 +-
 .../java/org/apache/camel/maven/TestProxy.java  |  64 -------
 .../test/resources/test-proxy-signatures.txt    |   1 +
 21 files changed, 592 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/pom.xml b/tooling/maven/camel-component-util-maven-plugin/pom.xml
index ffda9c4..ed197ac 100644
--- a/tooling/maven/camel-component-util-maven-plugin/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/pom.xml
@@ -60,13 +60,6 @@
       <artifactId>velocity</artifactId>
       <version>${velocity-version}</version>
     </dependency>
-<!--
-    <dependency>
-      <groupId>net.sourceforge.htmlunit</groupId>
-      <artifactId>htmlunit</artifactId>
-      <version>2.14</version>
-    </dependency>
--->
 
     <!-- add some logging to the classpath -->
     <dependency>
@@ -127,6 +120,30 @@
       </plugins>
     </pluginManagement>
     <plugins>
+      <!-- copy test utility classes to integration test project -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-it-resources</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <encoding>UTF-8</encoding>
+              <overwrite>true</overwrite>
+              <outputDirectory>${project.build.directory}/it/all-it/src/main/java/org/apache/camel/component/test</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>src/test/java/org/apache/camel/component/test</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
       <!-- validate generated code after unit tests -->
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
@@ -140,7 +157,7 @@
             </goals>
             <configuration>
               <sources>
-                <source>${project.build.directory}/generated-test-sources/camelComponent</source>
+                <source>${project.build.directory}/generated-test-sources/camel-component</source>
               </sources>
             </configuration>
           </execution>
@@ -156,10 +173,53 @@
             <goals>
               <goal>testCompile</goal>
             </goals>
+            <configuration>
+              <fork>false</fork>
+            </configuration>
           </execution>
         </executions>
       </plugin>
     </plugins>
   </build>
 
+  <!-- Plugin integration test profile -->
+  <profiles>
+    <profile>
+      <id>plugin-itest</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-invoker-plugin</artifactId>
+            <version>1.8</version>
+            <configuration>
+              <debug>true</debug>
+              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+              <pomIncludes>
+                <pomInclude>*/pom.xml</pomInclude>
+              </pomIncludes>
+              <postBuildHookScript>verify</postBuildHookScript>
+              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+              <settingsFile>src/it/settings.xml</settingsFile>
+              <goals>
+                <goal>clean</goal>
+                <goal>verify</goal>
+              </goals>
+            </configuration>
+            <executions>
+              <execution>
+                <id>integration-test</id>
+                <goals>
+                  <goal>install</goal>
+                  <goal>integration-test</goal>
+                  <goal>verify</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+
+      </build>
+    </profile>
+  </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
new file mode 100644
index 0000000..269aefc
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-component-util-maven-plugin-it</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>Integration Test to verify all goals.</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <outPackage>org.apache.camel.component.test.internal</outPackage>
+    <componentPackage>org.apache.camel.component.test</componentPackage>
+    <scheme>testComponent</scheme>
+    <componentName>Test</componentName>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <version>@project.version@</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>@velocity-version@</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <version>@project.version@</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- VelocityEngine javadoc for testing -->
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>@velocity-version@</version>
+      <classifier>javadoc</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- execute component-util plugin -->
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>generate-file-api-method</id>
+            <!-- using generate-test-sources instead of generate-sources to be able to load TestProxy.class -->
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>fromFile</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${scheme}</scheme>
+              <componentName>${componentName}</componentName>
+              <proxyClass>org.apache.camel.component.test.TestProxy</proxyClass>
+              <substitutions>
+                <substitution>
+                  <method>.+</method>
+                  <argName>(.+)</argName>
+                  <argType>java.util.List</argType>
+                  <replacement>$1List</replacement>
+                </substitution>
+              </substitutions>
+              <signatureFile>../../../src/test/resources/test-proxy-signatures.txt</signatureFile>
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-velocity-context-api-method</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>fromJavadoc</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${scheme}</scheme>
+              <componentName>${componentName}</componentName>
+              <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
+              <substitutions>
+                <substitution>
+                  <method>.+</method>
+                  <argName>key</argName>
+                  <argType>java.lang.Object</argType>
+                  <replacement>applicationKey</replacement>
+                </substitution>
+              </substitutions>
+              <excludeClasses>InternalContextBase</excludeClasses>
+              <excludeMethods>clone|Current|internal|icache</excludeMethods>
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-test-component-classes</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>fromApis</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${scheme}</scheme>
+              <componentName>${componentName}</componentName>
+              <apis>
+                <api>
+                  <apiName>test</apiName>
+                  <proxyClass>org.apache.camel.component.test.TestProxy</proxyClass>
+                </api>
+                <api>
+                  <apiName>velocity</apiName>
+                  <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
+                </api>
+              </apis>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- add generated source and test source to build -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>@build-helper-maven-plugin-version@</version>
+        <executions>
+          <execution>
+            <id>add-generated-sources</id>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-sources/camel-component</source>
+              </sources>
+            </configuration>
+          </execution>
+          <execution>
+            <id>add-generated-test-sources</id>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-test-sources/camel-component</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy
new file mode 100644
index 0000000..73edefd
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+// assert that the generated files directory exists
+File sourceDir = new File( basedir, "target/generated-sources/camel-component" );
+File testDir = new File( basedir, "target/generated-test-sources/camel-component" );
+
+assert sourceDir.isDirectory()
+assert testDir.isDirectory()

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml
new file mode 100644
index 0000000..c8f77f0
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+</settings>

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
index 3064824..8b868c4 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -20,6 +20,7 @@ import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.TreeMap;
 
 import org.apache.camel.util.component.ApiMethodParser;
 import org.apache.camel.util.component.ArgumentSubstitutionParser;
@@ -60,6 +61,9 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         // generate enumeration from model
         mergeTemplate(getApiMethodContext(models), getApiMethodFile(), "/api-method-enum.vm");
 
+        // generate EndpointConfiguration for this Api
+        mergeTemplate(getEndpointContext(models), getConfigurationFile(), "/api-endpoint-config.vm");
+
         // generate junit test if it doesn't already exist under test source directory
         // i.e. it may have been generated then moved there and populated with test values
         final String testFilePath = getTestFilePath();
@@ -121,6 +125,42 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         return getProxyType().getSimpleName() + "IntegrationTest";
     }
 
+    private VelocityContext getEndpointContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = getCommonContext(models);
+        context.put("configName", getConfigName());
+        context.put("componentName", componentName);
+        context.put("componentPackage", componentPackage);
+
+        // generate parameter names and types for configuration, sorted by parameter name
+        Map<String, Class<?>> parameters = new TreeMap<String, Class<?>>();
+        for (ApiMethodParser.ApiMethodModel model : models) {
+            for (ApiMethodParser.Argument argument : model.getArguments()) {
+                if (!parameters.containsKey(argument.getName())) {
+                    Class<?> type = argument.getType();
+                    if (type.isPrimitive()) {
+                        // replace primitives with wrapper classes
+                        type = ClassUtils.primitiveToWrapper(type);
+                    }
+                    parameters.put(argument.getName(), type);
+                }
+            }
+        }
+        context.put("parameters", parameters);
+        return context;
+    }
+
+    private File getConfigurationFile() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        // endpoint configuration goes in component package
+        fileName.append(componentPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getConfigName()).append(".java");
+        return new File(generatedSrcDir, fileName.toString());
+    }
+
+    private String getConfigName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "EndpointConfiguration";
+    }
+
     private VelocityContext getCommonContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
         VelocityContext context = new VelocityContext();
         context.put("models", models);
@@ -141,9 +181,9 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
     public static String getType(Class<?> clazz) {
         if (clazz.isArray()) {
             // create a zero length array and get the class from the instance
-            return "new " + clazz.getCanonicalName().replaceAll("\\[\\]", "[0]") + ".getClass()";
+            return "new " + getCanonicalName(clazz).replaceAll("\\[\\]", "[0]") + ".getClass()";
         } else {
-            return clazz.getCanonicalName() + ".class";
+            return getCanonicalName(clazz) + ".class";
         }
     }
 
@@ -172,7 +212,7 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         if (resultType.isPrimitive()) {
             return ClassUtils.primitiveToWrapper(resultType).getSimpleName();
         } else {
-            return resultType.getCanonicalName();
+            return getCanonicalName(resultType);
         }
     }
 
@@ -199,4 +239,22 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
             return "null";
         }
     }
+
+    public static String getPropertySuffix(String parameter) {
+        // capitalize first character
+        StringBuilder builder = new StringBuilder();
+        builder.append(Character.toUpperCase(parameter.charAt(0)));
+        builder.append(parameter.substring(1));
+        return builder.toString();
+    }
+
+    public static String getCanonicalName(Class<?> type) {
+        // remove java.lang prefix for default Java package
+        String canonicalName = type.getCanonicalName();
+        final int pkgEnd = canonicalName.lastIndexOf('.');
+        if (pkgEnd > 0 && canonicalName.substring(0, pkgEnd).equals("java.lang")) {
+            canonicalName = canonicalName.substring(pkgEnd + 1);
+        }
+        return canonicalName;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
index eee09ea..3979745 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
@@ -47,19 +47,16 @@ import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
 public abstract class AbstractGeneratorMojo extends AbstractMojo {
 
     protected static final String PREFIX = "org.apache.camel.";
-    protected static final String OUT_PACKAGE = PREFIX + "component";
-
+    protected static final String OUT_PACKAGE = PREFIX + "component.internal";
+    protected static final String COMPONENT_PACKAGE = PREFIX + "component";
 
     // used for velocity logging, to avoid creating velocity.log
     protected final Logger LOG = Logger.getLogger(this.getClass());
 
-    @Parameter(defaultValue = "${project}", readonly = true)
-    MavenProject project;
-
-    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camel")
+    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camel-component")
     protected File generatedSrcDir;
 
-    @Parameter(defaultValue = "${project.build.directory}/generated-test-sources/camel")
+    @Parameter(defaultValue = "${project.build.directory}/generated-test-sources/camel-component")
     protected File generatedTestDir;
 
     @Parameter(defaultValue = OUT_PACKAGE)
@@ -71,6 +68,12 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
     @Parameter(required = true, property = PREFIX + "componentName")
     protected String componentName;
 
+    @Parameter(defaultValue = COMPONENT_PACKAGE)
+    protected String componentPackage;
+
+    @Parameter(defaultValue = "${project}", readonly = true)
+    MavenProject project;
+
     private VelocityEngine engine;
     private ClassLoader projectClassLoader;
 
@@ -101,6 +104,7 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
             for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
                 try {
                     urls[i] = new File((String) it.next()).toURI().toURL();
+                    LOG.debug("Adding project path " + urls[i]);
                 } catch (MalformedURLException e) {
                     throw new MojoExecutionException(e.getMessage(), e);
                 }

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
index 5751dbd..b708e37 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
@@ -28,6 +28,14 @@ public class ApiProxy {
 
     private Map<String, String> aliases = Collections.EMPTY_MAP;
 
+    public ApiProxy() {
+    }
+
+    public ApiProxy(String apiName, String proxyClass) {
+        this.apiName = apiName;
+        this.proxyClass = proxyClass;
+    }
+
     public String getApiName() {
         return apiName;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
index 677d400..7eea008 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -45,7 +45,7 @@ import org.codehaus.plexus.util.IOUtil;
 /**
  * Parses ApiMethod signatures from Javadoc.
  */
-@Mojo(name = "fromJavaDoc", requiresDependencyResolution = ResolutionScope.TEST, requiresProject = true,
+@Mojo(name = "fromJavadoc", requiresDependencyResolution = ResolutionScope.TEST, requiresProject = true,
         defaultPhase = LifecyclePhase.GENERATE_SOURCES)
 public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
 
@@ -57,6 +57,9 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
     @Parameter(property = "camel.component.util.excludeClasses")
     protected String excludeClasses;
 
+    @Parameter(property = "camel.component.util.excludeMethods")
+    protected String excludeMethods;
+
     @Override
     protected ApiMethodParser createAdapterParser(Class proxyType) {
         return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
@@ -67,18 +70,23 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
         // signatures as map from signature with no arg names to arg names from JavadocParser
         Map<String, String> result = new HashMap<String, String>();
 
-        final Pattern packages = Pattern.compile(excludePackages);
-        Pattern classes = null;
+        final Pattern packagePatterns = Pattern.compile(excludePackages);
+        Pattern classPatterns = null;
         if (excludeClasses != null) {
-            classes = Pattern.compile(excludeClasses);
+            classPatterns = Pattern.compile(excludeClasses);
+        }
+        Pattern methodPatterns = null;
+        if (excludeMethods != null) {
+            methodPatterns = Pattern.compile(excludeMethods);
         }
 
         // for proxy class and super classes not matching excluded packages or classes
         for (Class aClass = getProxyType();
-             aClass != null && !packages.matcher(aClass.getPackage().getName()).matches() &&
-                     (classes == null || !classes.matcher(aClass.getSimpleName()).matches());
+             aClass != null && !packagePatterns.matcher(aClass.getPackage().getName()).matches() &&
+                     (classPatterns == null || !classPatterns.matcher(aClass.getSimpleName()).matches());
              aClass = aClass.getSuperclass()) {
 
+            LOG.debug("Processing " + aClass.getName());
             final String javaDocPath = aClass.getName().replaceAll("\\.", "/") + ".html";
 
             // read javadoc html text for class
@@ -98,7 +106,8 @@ public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMoj
                 // get public method signature
                 final Map<String, String> methodMap = htmlParser.getMethodText();
                 for (String method : htmlParser.getMethods()) {
-                    if (!result.containsKey(method)) {
+                    if (!result.containsKey(method) &&
+                            (methodPatterns == null || !methodPatterns.matcher(method).find())) {
 
                         final int leftBracket = method.indexOf('(');
                         final String name = method.substring(0, leftBracket);

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
index c0772a7..0e7b2a8 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
@@ -26,6 +26,9 @@ public class Substitution {
     private String argType;
     private String replacement;
 
+    public Substitution() {
+    }
+
     public Substitution(String method, String argName, String argType, String replacement) {
         this.method = method;
         this.argName = argName;

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index a82c2c5..7529712 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -46,7 +46,7 @@ public final class $collectionName extends ApiCollection {
 #end
     }
 
-    public static final synchronized $collectionName getCollection() {
+    public static synchronized $collectionName getCollection() {
         if (collection == null) {
             collection = new $collectionName();
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
new file mode 100644
index 0000000..ca44ad9
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
@@ -0,0 +1,47 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-endpoint-config.vm
+/*
+ * Camel EndpointConfiguration generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package ${componentPackage};
+
+/**
+ * Camel EndpointConfiguration for $proxyType.Name
+ */
+@SuppressWarnings("unused")
+public final class $configName extends ${componentName}Config {
+
+#foreach( $parameter in $parameters.entrySet() )
+    private $helper.getCanonicalName($parameter.Value) $parameter.Key;
+#end
+## getters and setters
+#foreach( $parameter in $parameters.entrySet() )
+#set ( $name = $parameter.Key )
+#set ( $type = $helper.getCanonicalName($parameter.Value) )
+#set ( $propertySuffix = $helper.getPropertySuffix($name) )
+
+    public $type get${propertySuffix}() {
+        return $name;
+    }
+
+    public void set${propertySuffix}($type $name) {
+        this.$name = $name;
+    }
+#end
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
index 9dab27c..0bc3056 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-method-enum.vm
@@ -32,6 +32,7 @@ import org.apache.camel.util.component.ApiMethodImpl;
 /**
  * Camel {@link ApiMethod} Enumeration for $proxyType.Name
  */
+@SuppressWarnings("unused")
 public enum $enumName implements ApiMethod {
 
 #foreach ( $model in $models )

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
index 160e920..d12adea 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
@@ -53,13 +53,13 @@ public class ${testName} extends CamelTestSupport {
 ## single argument, use as body
 #if ( $args.size() == 1 )
 #set ( $argType = $args.get(0).Type )
-        // using $argType.CanonicalName message body for single parameter "$args.get(0).Name"
+        // using $helper.getCanonicalName($argType) message body for single parameter "$args.get(0).Name"
 ## multiple arguments, pass them as headers
 #elseif ( $args.size() > 1 )
         final HashMap<String, Object> headers = new HashMap<String, Object>();
 #foreach ( $arg in $args )
 #if ( !$arg.Type.isPrimitive() )
-        // parameter type is $arg.Type.CanonicalName
+        // parameter type is $helper.getCanonicalName($arg.Type)
         headers.put("${helper.getPropertyPrefix()}${arg.Name}", null);
 #else
         headers.put("${helper.getPropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
@@ -70,10 +70,10 @@ public class ${testName} extends CamelTestSupport {
         #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) ) $type result = (${type})#end
 ## actual template call
 #if ( $args.isEmpty() )
-template().requestBody("direct://${model.UniqueName}", (java.lang.Object)null);
+template().requestBody("direct://${model.UniqueName}", (Object)null);
 #elseif ( $args.size() == 1 )
 ## typecast body to avoid requestBody() conflict
-template().requestBody("direct://${model.UniqueName}", (${argType.CanonicalName}) $helper.getDefaultArgValue($argType));
+template().requestBody("direct://${model.UniqueName}", (${helper.getCanonicalName($argType)}) $helper.getDefaultArgValue($argType));
 #else
 template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
 #end
@@ -89,7 +89,7 @@ template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
         return new RouteBuilder() {
             public void configure() {
 #foreach ( $model in $models )
-                // test route for $name
+                // test route for $model.Name
                 from("direct://${model.UniqueName}")
                   .to("${scheme}://${model.Name}");
 
@@ -97,4 +97,10 @@ template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
             }
         };
     }
+
+    @Override
+    public boolean isCreateCamelContextPerClass() {
+        // only create the context once for this class
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java
new file mode 100644
index 0000000..429280e
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java
@@ -0,0 +1,23 @@
+/**
+ * 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.component.test;
+
+/**
+ * Dummy component config.
+ */
+public class TestConfig {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
new file mode 100644
index 0000000..48eb11b
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
@@ -0,0 +1,68 @@
+/**
+ * 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.component.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestProxy {
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String sayHi(boolean hello) {
+        return hello ? "Hello!" : "Hi!";
+    }
+
+    public String sayHi(final String name) {
+        return "Hello " + name;
+    }
+
+    public final String greetMe(final String name) {
+        return "Greetings " + name;
+    }
+
+    public final String greetUs(final String name1, String name2) {
+        return "Greetings " + name1 + ", " + name2;
+    }
+
+    public final String greetAll(final String[] names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String greetAll(List<String> names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String[] greetTimes(String name, int times) {
+        final List<String> result = new ArrayList<String>();
+        for (int i = 0; i < times; i++) {
+            result.add("Greetings " + name);
+        }
+        return result.toArray(new String[result.size()]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
index aa7f7b7..641b34e 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
@@ -30,9 +30,15 @@ import static org.junit.Assert.assertTrue;
  * Base class for Generator MOJO tests.
  */
 public class AbstractGeneratorMojoTest {
-    protected static final String OUT_DIR = "target/generated-test-sources/camelComponent";
-    protected static final String PACKAGE_PATH = AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/") + "/";
-    protected static final String COMPONENT_NAME = "TestComponent";
+    protected static final String OUT_DIR = "target/generated-test-sources/camel-component";
+
+    private static final String COMPONENT_PACKAGE = "org.apache.camel.component.test";
+    private static final String OUT_PACKAGE = COMPONENT_PACKAGE + ".internal";
+
+    protected static final String PACKAGE_PATH = OUT_PACKAGE.replaceAll("\\.", "/") + "/";
+    protected static final String COMPONENT_PACKAGE_PATH = COMPONENT_PACKAGE.replaceAll("\\.", "/") + "/";
+
+    protected static final String COMPONENT_NAME = "Test";
     protected static final String SCHEME = "testComponent";
 
     protected void assertExists(File outFile) {
@@ -44,7 +50,8 @@ public class AbstractGeneratorMojoTest {
         mojo.scheme = SCHEME;
         mojo.generatedSrcDir = new File(OUT_DIR);
         mojo.generatedTestDir = new File(OUT_DIR);
-        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        mojo.outPackage = OUT_PACKAGE;
+        mojo.componentPackage = COMPONENT_PACKAGE;
         mojo.project = new MavenProject((Model) null) {
             @Override
             public List getTestClasspathElements() throws DependencyResolutionRequiredException {

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
index fb738a1..4b4e7ee 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.maven;
 
 import java.io.File;
 
+import org.apache.camel.component.test.TestProxy;
 import org.apache.velocity.VelocityContext;
 import org.junit.Test;
 
@@ -37,17 +38,9 @@ public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
         final ApiComponentGeneratorMojo mojo = new ApiComponentGeneratorMojo();
         configureMojo(mojo);
 
-        final ApiProxy[] proxies = new ApiProxy[2];
-        mojo.apis = proxies;
-        ApiProxy apiProxy = new ApiProxy();
-        proxies[0] = apiProxy;
-        apiProxy.setApiName("test");
-        apiProxy.setProxyClass(TestProxy.class.getName());
-
-        apiProxy = new ApiProxy();
-        proxies[1] = apiProxy;
-        apiProxy.setApiName("velocity");
-        apiProxy.setProxyClass(VelocityContext.class.getName());
+        mojo.apis = new ApiProxy[2];
+        mojo.apis[0] = new ApiProxy("test", TestProxy.class.getName());
+        mojo.apis[1] = new ApiProxy("velocity", VelocityContext.class.getName());
 
         mojo.execute();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
index 7a8af42..b59aed1 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.maven;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.camel.component.test.TestProxy;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
index f90b8ae..0292111 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -44,9 +44,10 @@ public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest
 
         // use VelocityEngine javadoc
         mojo.proxyClass = VelocityContext.class.getCanonicalName();
-        mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
         Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey");
         mojo.substitutions = new Substitution[]{ substitution };
+        mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
+        mojo.excludeMethods = "clone|Current|internal|icache";
 
         mojo.execute();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java
deleted file mode 100644
index ced2058..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/TestProxy.java
+++ /dev/null
@@ -1,64 +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.util.ArrayList;
-import java.util.List;
-
-public class TestProxy {
-    public String sayHi() {
-        return "Hello!";
-    }
-
-    public String sayHi(final String name) {
-        return "Hello " + name;
-    }
-
-    public final String greetMe(final String name) {
-        return "Greetings " + name;
-    }
-
-    public final String greetUs(final String name1, String name2) {
-        return "Greetings " + name1 + ", " + name2;
-    }
-
-    public final String greetAll(final String[] names) {
-        StringBuilder builder = new StringBuilder("Greetings ");
-        for (String name : names) {
-            builder.append(name).append(", ");
-        }
-        builder.delete(builder.length() - 2, builder.length());
-        return builder.toString();
-    }
-
-    public final String greetAll(List<String> names) {
-        StringBuilder builder = new StringBuilder("Greetings ");
-        for (String name : names) {
-            builder.append(name).append(", ");
-        }
-        builder.delete(builder.length() - 2, builder.length());
-        return builder.toString();
-    }
-
-    public final String[] greetTimes(String name, int times) {
-        final List<String> result = new ArrayList<String>();
-        for (int i = 0; i < times; i++) {
-            result.add("Greetings " + name);
-        }
-        return result.toArray(new String[result.size()]);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/fad48654/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
index 1d5ba35..4c47474 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
@@ -1,4 +1,5 @@
 public String sayHi();
+public String sayHi(boolean hello);
 public String sayHi(final String name);
 public final String greetMe(final String name);
 public final String greetUs(final String name1, String name2);


[08/35] git commit: Refactored mojos, added JavadocApiMethodGenerator, ApiComponentGenerator

Posted by dh...@apache.org.
Refactored mojos, added JavadocApiMethodGenerator, ApiComponentGenerator


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

Branch: refs/heads/master
Commit: ecee7f1fcb48b2945aa6ebfd32c84226b86f6dfc
Parents: cd89e14
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon May 26 05:37:45 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:30 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodParser.java   |  16 +-
 .../camel-component-util-maven-plugin/pom.xml   |  15 ++
 .../maven/AbstractApiMethodGeneratorMojo.java   | 117 +++++++++
 .../camel/maven/AbstractGeneratorMojo.java      | 137 ++++++++++
 .../camel/maven/ApiComponentGeneratorMojo.java  | 109 ++++++++
 .../camel/maven/ApiMethodGeneratorMojo.java     | 197 ---------------
 .../java/org/apache/camel/maven/ApiProxy.java   | 100 ++++++++
 .../camel/maven/FileApiMethodGeneratorMojo.java |  34 +--
 .../maven/JavadocApiMethodGeneratorMojo.java    | 252 +++++++++++++++++++
 .../src/main/resources/api-collection.vm        |  46 ++++
 .../camel/maven/AbstractGeneratorMojoTest.java  |  35 +++
 .../maven/ApiComponentGeneratorMojoTest.java    |  78 ++++++
 .../apache/camel/maven/ApiMethodEnumTest.java   |  71 ------
 .../maven/FileApiMethodGeneratorMojoTest.java   |  67 +++++
 .../JavadocApiMethodGeneratorMojoTest.java      |  66 +++++
 .../test/resources/test-proxy-signatures.txt    |   7 +
 16 files changed, 1045 insertions(+), 302 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
index 58ada5a..0e839df 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -178,10 +178,14 @@ public abstract class ApiMethodParser<T> {
     }
 
     protected Class<?> forName(String className) {
-        return forName(className, classLoader);
+        try {
+            return forName(className, classLoader);
+        } catch (ClassNotFoundException e1) {
+            throw new IllegalArgumentException("Error loading class " + className);
+        }
     }
 
-    public static Class<?> forName(String className, ClassLoader classLoader) {
+    public static Class<?> forName(String className, ClassLoader classLoader) throws ClassNotFoundException {
         Class<?> result;
         try {
             // lookup primitive types first
@@ -196,12 +200,8 @@ public abstract class ApiMethodParser<T> {
                 final int nDimensions = (className.length() - firstDim) / 2;
                 return Array.newInstance(forName(className.substring(0, firstDim), classLoader), new int[nDimensions]).getClass();
             }
-            try {
-                // try loading from default Java package java.lang
-                result = Class.forName(JAVA_LANG + className, true, classLoader);
-            } catch (ClassNotFoundException e1) {
-                throw new IllegalArgumentException("Error loading class " + className);
-            }
+            // try loading from default Java package java.lang
+            result = Class.forName(JAVA_LANG + className, true, classLoader);
         }
 
         return result;

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/pom.xml b/tooling/maven/camel-component-util-maven-plugin/pom.xml
index d6159f1..350cd08 100644
--- a/tooling/maven/camel-component-util-maven-plugin/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/pom.xml
@@ -60,6 +60,13 @@
       <artifactId>velocity</artifactId>
       <version>${velocity-version}</version>
     </dependency>
+<!--
+    <dependency>
+      <groupId>net.sourceforge.htmlunit</groupId>
+      <artifactId>htmlunit</artifactId>
+      <version>2.14</version>
+    </dependency>
+-->
 
     <!-- add some logging to the classpath -->
     <dependency>
@@ -76,6 +83,14 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <!-- VelocityEngine javadoc for testing -->
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>${velocity-version}</version>
+      <classifier>javadoc</classifier>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..856a286
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -0,0 +1,117 @@
+/**
+ * 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.util.List;
+
+import org.apache.camel.util.component.ApiMethodParser;
+import org.apache.camel.util.component.ArgumentSubstitutionParser;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * Base Mojo class for ApiMethod generators.
+ */
+public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMojo {
+
+    @Parameter(required = true, property = PREFIX + "proxyClass")
+    protected String proxyClass;
+
+    @Parameter(property = PREFIX + "substitutions")
+    protected Substitution[] substitutions = new Substitution[0];
+
+    // cached fields
+    private Class<?> proxyType;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+
+        // load proxy class and get enumeration file to generate
+        final Class proxyType = getProxyType();
+
+        // create parser
+        ApiMethodParser parser = createAdapterParser(proxyType);
+        parser.setSignatures(getSignatureList());
+        parser.setClassLoader(getProjectClassLoader());
+
+        // parse signatures
+        final List<ApiMethodParser.ApiMethodModel> models = parser.parse();
+
+        // generate enumeration from model
+        mergeTemplate(getApiMethodContext(models), getApiMethodFile(), "/api-method-enum.vm");
+    }
+
+    protected ApiMethodParser createAdapterParser(Class proxyType) {
+        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions()){};
+    }
+
+    private VelocityContext getApiMethodContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = new VelocityContext();
+        context.put("packageName", outPackage);
+        context.put("enumName", getEnumName());
+        context.put("models", models);
+        context.put("proxyType", getProxyType());
+        context.put("helper", getClass());
+        return context;
+    }
+
+    public abstract List<String> getSignatureList() throws MojoExecutionException;
+
+    public Class getProxyType() throws MojoExecutionException {
+        if (proxyType == null) {
+            // load proxy class from Project runtime dependencies
+            try {
+                proxyType = getProjectClassLoader().loadClass(proxyClass);
+            } catch (ClassNotFoundException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+        return proxyType;
+    }
+
+    public File getApiMethodFile() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getEnumName()).append(".java");
+        return new File(outDir, fileName.toString());
+    }
+
+    private String getEnumName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "ApiMethod";
+    }
+
+    public static String getType(Class<?> clazz) {
+        if (clazz.isArray()) {
+            // create a zero length array and get the class from the instance
+            return "new " + clazz.getCanonicalName().replaceAll("\\[\\]", "[0]") + ".getClass()";
+        } else {
+            return clazz.getCanonicalName() + ".class";
+        }
+    }
+
+    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
+        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
+        for (int i = 0; i < substitutions.length; i++) {
+            subs[i] = new ArgumentSubstitutionParser.Substitution(substitutions[i].getMethod(),
+                    substitutions[i].getArgName(), substitutions[i].getArgType(), substitutions[i].getReplacement());
+        }
+        return subs;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
new file mode 100644
index 0000000..0e29a96
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
@@ -0,0 +1,137 @@
+/**
+ * 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.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.Log4JLogChute;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+/**
+ * Base class for Api based code generation MOJOs.
+ */
+public abstract class AbstractGeneratorMojo extends AbstractMojo {
+
+    protected static final String PREFIX = "org.apache.camel.";
+    protected static final String OUT_PACKAGE = PREFIX + "component";
+
+
+    // used for velocity logging, to avoid creating velocity.log
+    protected final Logger LOG = Logger.getLogger(this.getClass());
+
+    @Parameter(defaultValue = "${project}", readonly = true)
+    MavenProject project;
+
+    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camel")
+    protected File outDir;
+
+    @Parameter(defaultValue = OUT_PACKAGE)
+    protected String outPackage;
+
+    private VelocityEngine engine;
+    private ClassLoader projectClassLoader;
+
+    public void setEngine(VelocityEngine engine) {
+        this.engine = engine;
+    }
+
+    public VelocityEngine getEngine() {
+        if (engine == null) {
+            // initialize velocity to load resources from class loader and use Log4J
+            Properties velocityProperties = new Properties();
+            velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
+            velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
+            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
+            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
+            engine = new VelocityEngine(velocityProperties);
+            engine.init();
+        }
+        return engine;
+    }
+
+    protected void setProjectClassLoader(ClassLoader projectClassLoader) {
+        this.projectClassLoader = projectClassLoader;
+    }
+
+    protected ClassLoader getProjectClassLoader() throws MojoExecutionException {
+        if (projectClassLoader == null)  {
+            final List classpathElements;
+            try {
+                classpathElements = project.getRuntimeClasspathElements();
+            } catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+            final URL[] urls = new URL[classpathElements.size()];
+            int i = 0;
+            for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
+                try {
+                    urls[i] = new File((String) it.next()).toURI().toURL();
+                } catch (MalformedURLException e) {
+                    throw new MojoExecutionException(e.getMessage(), e);
+                }
+            }
+            final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+            projectClassLoader = new URLClassLoader(urls, tccl != null ? tccl : getClass().getClassLoader());
+        }
+        return projectClassLoader;
+    }
+
+    protected void mergeTemplate(VelocityContext context, File outFile, String templateName) throws MojoExecutionException {
+        // ensure parent directories exist
+        outFile.getParentFile().mkdirs();
+
+        // add generated date
+        context.put("generatedDate", new Date().toString());
+
+        // load velocity template
+        final Template template = getEngine().getTemplate(templateName, "UTF-8");
+
+        // generate file
+        BufferedWriter writer = null;
+        try {
+            writer = new BufferedWriter(new FileWriter(outFile));
+            template.merge(context, writer);
+        } catch (IOException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.close();
+                } catch (IOException ignore) {}
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
new file mode 100644
index 0000000..7a90b81
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
@@ -0,0 +1,109 @@
+/**
+ * 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 org.apache.maven.plugin.AbstractMojoExecutionException;
+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.apache.velocity.VelocityContext;
+
+/**
+ * Generates Camel Component based on a collection of APIs.
+ */
+@Mojo(name = "fromApis", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
+        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
+
+    @Parameter(required = true)
+    protected String componentName;
+
+    @Parameter(required = true)
+    protected ApiProxy[] apis;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        if (apis == null || apis.length == 0) {
+            throw new MojoExecutionException("One or more API proxies are required");
+        }
+
+        // generate ApiMethods
+        for (int i = 0; i < apis.length; i++) {
+            apis[i].validate();
+
+            AbstractApiMethodGeneratorMojo generator;
+            if (apis[i].getSignatureFile() != null) {
+                generator = new FileApiMethodGeneratorMojo();
+                ((FileApiMethodGeneratorMojo)generator).signatureFile = apis[i].getSignatureFile();
+            } else {
+                generator = new JavadocApiMethodGeneratorMojo();
+                ((JavadocApiMethodGeneratorMojo)generator).excludePackages = apis[i].getExcludePackages();
+                ((JavadocApiMethodGeneratorMojo)generator).excludeClasses = apis[i].getExcludeClasses();
+            }
+            // set API properties
+            generator.proxyClass = apis[i].getProxyClass();
+            generator.substitutions = apis[i].getSubstitutions();
+            // set shared properties
+            generator.outDir = outDir;
+            generator.outPackage = outPackage;
+            // set shared state
+            generator.setEngine(getEngine());
+            generator.setProjectClassLoader(getProjectClassLoader());
+
+            try {
+                generator.execute();
+            } catch (AbstractMojoExecutionException e) {
+                throw new MojoExecutionException("Error generating ApiMethod for " +
+                        apis[i].getProxyClass() + ": " + e.getMessage(), e);
+            }
+        }
+
+        // TODO generate Component classes
+        // generate ApiCollection
+        mergeTemplate(getApiCollectionContext(), getApiCollectionFile(), "/api-collection.vm");
+    }
+
+    private VelocityContext getApiCollectionContext() {
+        final VelocityContext context = new VelocityContext();
+        context.put("componentName", componentName);
+        context.put("collectionName", getApiCollectionName());
+        context.put("packageName", outPackage);
+        context.put("apis", apis);
+        context.put("helper", getClass());
+        return context;
+    }
+
+    private File getApiCollectionFile() {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getApiCollectionName()).append(".java");
+        return new File(outDir, fileName.toString());
+    }
+
+    private String getApiCollectionName() {
+        return componentName + "ApiCollection";
+    }
+
+    public static String getApiMethod(String proxyClass) {
+        return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "ApiMethod";
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java
deleted file mode 100644
index ff0d7f9..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodGeneratorMojo.java
+++ /dev/null
@@ -1,197 +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.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.camel.util.component.ApiMethodParser;
-import org.apache.log4j.Logger;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.Log4JLogChute;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-
-/**
- * Base Mojo class for ApiMethod generators.
- */
-public abstract class ApiMethodGeneratorMojo extends AbstractMojo {
-
-    protected static final String PREFIX = "camel.component.util.";
-
-    // used for velocity logging, to avoid creating velocity.log
-    private final Logger LOG = Logger.getLogger(this.getClass());
-
-    @Parameter(defaultValue = "${project}", readonly = true)
-    MavenProject project;
-
-    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camelComponent")
-    protected File outDir;
-
-    @Parameter(defaultValue = "org.apache.camel.util.component")
-    protected String outPackage;
-
-    @Parameter(required = true, property = PREFIX + "proxyClass")
-    protected String proxyClass;
-
-    // cached fields
-    private Class<?> proxyType;
-    private ClassLoader projectClassLoader;
-    private VelocityEngine engine;
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-
-        // initialize velocity
-        initVelocityEngine();
-
-        // load proxy class and get enumeration file to generate
-        final Class proxyType = getProxyType();
-
-        // create parser
-        ApiMethodParser parser = createAdapterParser(proxyType);
-        parser.setSignatures(getSignatureList());
-        parser.setClassLoader(getProjectClassLoader());
-
-        // parse signatures
-        final List<ApiMethodParser.ApiMethodModel> models = parser.parse();
-
-        // generate enumeration from model
-        generateEnum(models);
-    }
-
-    protected ApiMethodParser createAdapterParser(Class proxyType) {
-        return new ApiMethodParser(proxyType){};
-    }
-
-    private void initVelocityEngine() {
-        // initialize velocity to load resources from class loader and use Log4J
-        Properties velocityProperties = new Properties();
-        velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
-        velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
-        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
-        velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
-        engine = new VelocityEngine(velocityProperties);
-        engine.init();
-    }
-
-    private void generateEnum(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
-        final File apiMethodFile = getApiMethodFile();
-        // ensure parent directories exist
-        apiMethodFile.getParentFile().mkdirs();
-
-        // set template parameters
-        VelocityContext context = new VelocityContext();
-        context.put("generatedDate", new Date().toString());
-        context.put("packageName", outPackage);
-        context.put("enumName", getEnumName());
-        context.put("models", models);
-        context.put("proxyType", getProxyType());
-        context.put("helper", getClass());
-
-        // load velocity template
-        final Template template = engine.getTemplate("/api-method-enum.vm", "UTF-8");
-
-        // generate Enumeration
-        BufferedWriter writer = null;
-        try {
-            writer = new BufferedWriter(new FileWriter(apiMethodFile));
-            template.merge(context, writer);
-        } catch (IOException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        } finally {
-            if (writer != null) {
-                try {
-                    writer.close();
-                } catch (IOException ignore) {}
-            }
-        }
-    }
-
-    public abstract List<String> getSignatureList() throws MojoExecutionException;
-
-    public Class getProxyType() throws MojoExecutionException {
-        if (proxyType == null) {
-            // load proxy class from Project runtime dependencies
-            try {
-                proxyType = getProjectClassLoader().loadClass(proxyClass);
-            } catch (ClassNotFoundException e) {
-                throw new MojoExecutionException(e.getMessage(), e);
-            }
-        }
-        return proxyType;
-    }
-
-    private ClassLoader getProjectClassLoader() throws MojoExecutionException {
-        if (projectClassLoader == null)  {
-            final List classpathElements;
-            try {
-                classpathElements = project.getRuntimeClasspathElements();
-            } catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
-                throw new MojoExecutionException(e.getMessage(), e);
-            }
-            final URL[] urls = new URL[classpathElements.size()];
-            int i = 0;
-            for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
-                try {
-                    urls[i] = new File((String) it.next()).toURI().toURL();
-                } catch (MalformedURLException e) {
-                    throw new MojoExecutionException(e.getMessage(), e);
-                }
-            }
-            projectClassLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
-        }
-        return projectClassLoader;
-    }
-
-    public File getApiMethodFile() throws MojoExecutionException {
-        final StringBuilder fileName = new StringBuilder();
-        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
-        fileName.append(getEnumName()).append(".java");
-        return new File(outDir, fileName.toString());
-    }
-
-    private String getEnumName() throws MojoExecutionException {
-        return getProxyType().getSimpleName() + "ApiMethod";
-    }
-
-    public static String getType(Class<?> clazz) {
-        if (clazz.isArray()) {
-            // create a zero length array and get the class from the instance
-            return "new " + clazz.getCanonicalName().replaceAll("\\[\\]", "[0]") + ".getClass()";
-        } else {
-            return clazz.getCanonicalName() + ".class";
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
new file mode 100644
index 0000000..54e5b80
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
@@ -0,0 +1,100 @@
+/**
+ * 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.util.Collections;
+import java.util.Map;
+
+/**
+ * Represents an API to use for generating Camel Component.
+ */
+public class ApiProxy {
+    private String apiName;
+    private String proxyClass;
+
+    private Substitution[] substitutions = new Substitution[0];
+
+    private String excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
+    private String excludeClasses;
+
+    private File signatureFile;
+
+    private Map<String, String> aliases = Collections.EMPTY_MAP;
+
+    public String getApiName() {
+        return apiName;
+    }
+
+    public void setApiName(String apiName) {
+        this.apiName = apiName;
+    }
+
+    public String getProxyClass() {
+        return proxyClass;
+    }
+
+    public void setProxyClass(String proxyClass) {
+        this.proxyClass = proxyClass;
+    }
+
+    public Substitution[] getSubstitutions() {
+        return substitutions;
+    }
+
+    public void setSubstitutions(Substitution[] substitutions) {
+        this.substitutions = substitutions;
+    }
+
+    public String getExcludePackages() {
+        return excludePackages;
+    }
+
+    public void setExcludePackages(String excludePackages) {
+        this.excludePackages = excludePackages;
+    }
+
+    public String getExcludeClasses() {
+        return excludeClasses;
+    }
+
+    public void setExcludeClasses(String excludeClasses) {
+        this.excludeClasses = excludeClasses;
+    }
+
+    public File getSignatureFile() {
+        return signatureFile;
+    }
+
+    public void setSignatureFile(File signatureFile) {
+        this.signatureFile = signatureFile;
+    }
+
+    public Map<String, String> getAliases() {
+        return aliases;
+    }
+
+    public void setAliases(Map<String, String> aliases) {
+        this.aliases = aliases;
+    }
+
+    public void validate() {
+        if (apiName == null || proxyClass == null) {
+            throw new IllegalArgumentException("Properties apiName and proxyClass are required");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
index 8ce2cf2..566ef0a 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
@@ -24,8 +24,6 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.camel.util.component.ApiMethodParser;
-import org.apache.camel.util.component.ArgumentSubstitutionParser;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -35,30 +33,23 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
 /**
  * Parses ApiMethod signatures from a File.
  */
-@Mojo(name = "fromFile", requiresDependencyResolution = ResolutionScope.RUNTIME, requiresProject = true,
+@Mojo(name = "fromFile", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
         defaultPhase = LifecyclePhase.GENERATE_SOURCES)
-public class FileApiMethodGeneratorMojo extends ApiMethodGeneratorMojo {
+public class FileApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
 
-    @Parameter(required = true, property = "camel.component.util.signatures")
-    protected File signatures;
-
-    @Parameter(property = "camel.component.util.substitutions")
-    protected Substitution[] substitutions;
-
-    @Override
-    protected ApiMethodParser createAdapterParser(Class proxyType) {
-        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
-    }
+    @Parameter(required = true, property = PREFIX + "signatureFile")
+    protected File signatureFile;
 
     @Override
     public List<String> getSignatureList() throws MojoExecutionException {
-        // get signatures as a list of Strings
+        // get signatureFile as a list of Strings
         List<String> result = new ArrayList<String>();
         try {
-            BufferedReader reader = new BufferedReader(new FileReader(this.signatures));
+            BufferedReader reader = new BufferedReader(new FileReader(this.signatureFile));
             String line = reader.readLine();
             while (line != null) {
                 result.add(line);
+                line = reader.readLine();
             }
         } catch (FileNotFoundException e) {
             throw new MojoExecutionException(e.getMessage(), e);
@@ -66,17 +57,8 @@ public class FileApiMethodGeneratorMojo extends ApiMethodGeneratorMojo {
             throw new MojoExecutionException(e.getMessage(), e);
         }
         if (result.isEmpty()) {
-            throw new MojoExecutionException("Signature file " + signatures.getPath() + " is empty");
+            throw new MojoExecutionException("Signature file " + signatureFile.getPath() + " is empty");
         }
         return result;
     }
-
-    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
-        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
-        for (int i = 0; i < substitutions.length; i++) {
-            subs[i] = new ArgumentSubstitutionParser.Substitution(substitutions[i].getMethod(),
-                    substitutions[i].getArgName(), substitutions[i].getArgType(), substitutions[i].getReplacement());
-        }
-        return subs;
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..b94aab7
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -0,0 +1,252 @@
+/**
+ * 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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import javax.swing.text.ChangedCharSetException;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.Parser;
+import javax.swing.text.html.parser.TagElement;
+
+import org.apache.camel.util.component.ApiMethodParser;
+import org.apache.camel.util.component.ArgumentSubstitutionParser;
+import org.apache.maven.plugin.MojoExecutionException;
+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;
+
+/**
+ * Parses ApiMethod signatures from Javadoc.
+ */
+@Mojo(name = "fromJavaDoc", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
+        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
+
+    protected static final String DEFAULT_EXCLUDE_PACKAGES = "javax?\\.lang.*";
+
+    @Parameter(property = "camel.component.util.excludePackages", defaultValue = DEFAULT_EXCLUDE_PACKAGES)
+    protected String excludePackages;
+
+    @Parameter(property = "camel.component.util.excludeClasses")
+    protected String excludeClasses;
+
+    @Override
+    protected ApiMethodParser createAdapterParser(Class proxyType) {
+        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
+    }
+
+    @Override
+    public List<String> getSignatureList() throws MojoExecutionException {
+        // get signatures as a list of Strings
+        List<String> result = new ArrayList<String>();
+
+        final Pattern packages = Pattern.compile(excludePackages);
+        Pattern classes = null;
+        if (excludeClasses != null) {
+            classes = Pattern.compile(excludeClasses);
+        }
+
+        // for proxy class and super classes not matching excluded packages or classes
+        for (Class aClass = getProxyType();
+             !packages.matcher(aClass.getPackage().getName()).matches() && (classes == null ||
+                     !classes.matcher(aClass.getSimpleName()).matches()); aClass = aClass.getSuperclass()) {
+
+            final String javaDocPath = aClass.getName().replaceAll("\\.", "/") + ".html";
+
+            // read javadoc html text for class
+            try {
+                final InputStream inputStream = getProjectClassLoader().getResourceAsStream(javaDocPath);
+                if (inputStream == null) {
+                    throw new MojoExecutionException("JavaDoc not found using classpath for " + aClass.getName());
+                }
+                // transform the HTML to get method summary as text
+                // dummy DTD
+                final DTD dtd = DTD.getDTD("html.dtd");
+                final JavadocParser htmlParser = new JavadocParser(dtd, javaDocPath);
+                htmlParser.parse(new InputStreamReader(inputStream, "UTF-8"));
+
+                // get public method signature
+                final Map<String, String> methodMap = htmlParser.getMethodText();
+                for (String method : htmlParser.getMethods()) {
+                    final int leftBracket = method.indexOf('(');
+                    final String name = method.substring(0, leftBracket);
+                    final String args = method.substring(leftBracket + 1, method.length() - 1);
+                    String[] types;
+                    if (args.isEmpty()) {
+                        types = new String[0];
+                    } else {
+                        types = args.split(",");
+                    }
+                    final String resultType = getResultType(aClass, name, types);
+                    if (resultType != null) {
+                        final StringBuilder signature = new StringBuilder(resultType);
+                        signature.append(" ").append(name).append(methodMap.get(method));
+                        result.add(signature.toString());
+                    }
+                }
+            } catch (IOException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+
+        return result;
+    }
+
+    private String getResultType(Class<?> aClass, String name, String[] types) throws MojoExecutionException {
+        Class<?>[] argTypes = new Class<?>[types.length];
+        final ClassLoader classLoader = getProjectClassLoader();
+        for (int i = 0; i < types.length; i++) {
+            try {
+                try {
+                    argTypes[i] = ApiMethodParser.forName(types[i].trim(), classLoader);
+                } catch (ClassNotFoundException e) {
+                    throw new MojoExecutionException(e.getMessage(), e);
+                }
+            } catch (IllegalArgumentException e) {
+                throw new MojoExecutionException(e.getCause().getMessage(), e.getCause());
+            }
+        }
+        try {
+            final Method method = aClass.getMethod(name, argTypes);
+            if ((method.getModifiers() & Modifier.PUBLIC) != 0) {
+                return method.getReturnType().getCanonicalName();
+            } else {
+                return null;
+            }
+        } catch (NoSuchMethodException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+    }
+
+    private class JavadocParser extends Parser {
+        private String hrefPattern;
+
+        private ParserState parserState;
+        private String methodWithTypes;
+        private StringBuilder methodTextBuilder = new StringBuilder();
+
+        private List<String> methods = new ArrayList<String>();
+        private Map<String, String> methodText = new HashMap<String, String>();
+
+        public JavadocParser(DTD dtd, String docPath) {
+            super(dtd);
+            this.hrefPattern = docPath + "#";
+        }
+
+        @Override
+        protected void startTag(TagElement tag) throws ChangedCharSetException {
+            super.startTag(tag);
+
+            final HTML.Tag htmlTag = tag.getHTMLTag();
+            if (htmlTag != null) {
+                if (HTML.Tag.A.equals(htmlTag)) {
+                    final SimpleAttributeSet attributes = getAttributes();
+                    final Object name = attributes.getAttribute(HTML.Attribute.NAME);
+                    if (name != null) {
+                        final String nameAttr = (String) name;
+                        if (parserState == null && "method_summary".equals(nameAttr)) {
+                            parserState = ParserState.METHOD_SUMMARY;
+                        } else if (parserState == ParserState.METHOD_SUMMARY && nameAttr.startsWith("methods_inherited_from_class_")) {
+                            parserState = null;
+                        } else if (parserState == ParserState.METHOD && methodWithTypes == null) {
+                            final Object href = attributes.getAttribute(HTML.Attribute.HREF);
+                            if (href != null) {
+                                String hrefAttr = (String) href;
+                                if (hrefAttr.contains(hrefPattern)) {
+                                    methodWithTypes = hrefAttr.substring(hrefAttr.indexOf('#') + 1);
+                                }
+                            }
+                        }
+                    }
+                } else if (parserState == ParserState.METHOD_SUMMARY && HTML.Tag.CODE.equals(htmlTag)) {
+                    parserState = ParserState.METHOD;
+                }
+            }
+        }
+
+        @Override
+        protected void endTag(boolean omitted) {
+            super.endTag(omitted);    //To change body of overridden methods use File | Settings | File Templates.
+        }
+
+        @Override
+        protected void handleEmptyTag(TagElement tag) {
+            if (parserState == ParserState.METHOD && HTML.Tag.CODE.equals(tag.getHTMLTag())) {
+                if (methodWithTypes != null) {
+                    // process collected method data
+                    methods.add(methodWithTypes);
+                    this.methodText.put(methodWithTypes, getArgSignature());
+
+                    // clear the text builder for next method
+                    methodTextBuilder.delete(0, methodTextBuilder.length());
+                    methodWithTypes = null;
+                }
+
+                parserState = ParserState.METHOD_SUMMARY;
+            }
+        }
+
+        private String getArgSignature() {
+            final String typeString = methodWithTypes.substring(methodWithTypes.indexOf('(') + 1, methodWithTypes.indexOf(')'));
+            if (typeString.isEmpty()) {
+                return "()";
+            }
+            final String[] types = typeString.split(",");
+            String argText = methodTextBuilder.toString().replaceAll("&nbsp;", " ").replaceAll("&nbsp", " ");
+            final String[] args = argText.substring(argText.indexOf('(') + 1, argText.indexOf(')')).split(",");
+            StringBuilder builder = new StringBuilder("(");
+            for (int i = 0; i < types.length; i++) {
+                final String[] arg = args[i].trim().split(" ");
+                builder.append(types[i]).append(" ").append(arg[1].trim()).append(",");
+            }
+            builder.deleteCharAt(builder.length() - 1);
+            builder.append(")");
+            return builder.toString();
+        }
+
+        @Override
+        protected void handleText(char[] text) {
+            if (parserState == ParserState.METHOD && methodWithTypes != null) {
+                methodTextBuilder.append(text);
+            }
+        }
+
+        private List<String> getMethods() {
+            return methods;
+        }
+
+        private Map<String, String> getMethodText() {
+            return methodText;
+        }
+    }
+
+    private static enum ParserState {
+        METHOD_SUMMARY, METHOD;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
new file mode 100644
index 0000000..26382db
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -0,0 +1,46 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-collection.vm
+/*
+ * Camel ApiCollection generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.camel.util.component.ApiCollection;
+import org.apache.camel.util.component.ApiMethodHelper;
+
+/**
+ * Camel {@link ApiCollection} for $componentName
+ */
+public class $collectionName extends ApiCollection {
+
+    public ${collectionName}() {
+        final Map<String, String> aliases = new HashMap<String, String>();
+#foreach( $api in $apis )
+        aliases.clear();
+#foreach( $alias in $api.Aliases.entrySet() )
+        aliases.put("$alias.Key", "$alias.Value");
+#end
+#set( $apiMethod = $helper.getApiMethod($api.ProxyClass) )
+        apis.put("$api.ApiName", new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
+#end
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
new file mode 100644
index 0000000..eaaf704
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
@@ -0,0 +1,35 @@
+/**
+ * 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 static org.junit.Assert.assertTrue;
+
+/**
+ * User: dbokde
+ * Date: 5/26/14
+ * Time: 4:49 AM
+ */
+public class AbstractGeneratorMojoTest {
+    protected static final String OUT_DIR = "target/generated-test-sources/camelComponent";
+    protected static final String PACKAGE_PATH = AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/");
+
+    protected void assertExists(File outFile) {
+        assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
new file mode 100644
index 0000000..3176755
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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.util.Collections;
+import java.util.List;
+
+import org.apache.camel.util.FileUtil;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.app.VelocityEngine;
+import org.junit.Test;
+
+/**
+ * Tests {@link ApiComponentGeneratorMojo}
+ */
+public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
+
+    private static final String COMPONENT_NAME = "TestComponent";
+
+    @Test
+    public void testExecute() throws Exception {
+
+        // delete target files to begin
+        final File outDir = new File(OUT_DIR);
+        FileUtil.removeDir(outDir);
+
+        final File collectionFile = new File(OUT_DIR, PACKAGE_PATH + "/" + COMPONENT_NAME + "ApiCollection.java");
+
+        final ApiComponentGeneratorMojo mojo = new ApiComponentGeneratorMojo();
+        mojo.componentName = COMPONENT_NAME;
+        mojo.outDir = new File(OUT_DIR);
+        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        mojo.project = new MavenProject((Model) null) {
+            @Override
+            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
+                return Collections.EMPTY_LIST;
+            }
+        };
+
+        final ApiProxy[] proxies = new ApiProxy[2];
+        mojo.apis = proxies;
+        ApiProxy apiProxy = new ApiProxy();
+        proxies[0] = apiProxy;
+        apiProxy.setApiName("test");
+        apiProxy.setProxyClass(TestProxy.class.getName());
+        apiProxy.setSignatureFile(new File("src/test/resources/test-proxy-signatures.txt"));
+        Substitution[] substitutions = new Substitution[1];
+        substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
+        apiProxy.setSubstitutions(substitutions);
+
+        apiProxy = new ApiProxy();
+        proxies[1] = apiProxy;
+        apiProxy.setApiName("velocity");
+        apiProxy.setProxyClass(VelocityEngine.class.getName());
+
+        mojo.execute();
+
+        // check target file was generated
+        assertExists(collectionFile);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java
deleted file mode 100644
index b224a6e..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiMethodEnumTest.java
+++ /dev/null
@@ -1,71 +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.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.model.Model;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.junit.Test;
-
-/**
- * Tests api-method-enum.vm
- */
-public class ApiMethodEnumTest {
-
-    @Test
-    public void testTemplate() throws IOException, MojoFailureException, MojoExecutionException {
-
-        final FileApiMethodGeneratorMojo mojo = new FileApiMethodGeneratorMojo() {
-
-            @Override
-            public List<String> getSignatureList() throws MojoExecutionException {
-                final ArrayList<String> signatures = new ArrayList<String>();
-                signatures.add("public String sayHi();");
-                signatures.add("public String sayHi(final String name);");
-                signatures.add("public final String greetMe(final String name);");
-                signatures.add("public final String greetUs(final String name1, String name2);");
-                signatures.add("public final String greetAll(String[] names);");
-                signatures.add("public final String greetAll(java.util.List<String> names);");
-                signatures.add("public final String[] greetTimes(String name, int times);");
-                return signatures;
-            }
-        };
-        mojo.substitutions = new Substitution[1];
-        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
-
-        mojo.outDir = new File("target/generated-test-sources/camelComponent");
-        mojo.outPackage = "org.apache.camel.component.util";
-        mojo.proxyClass = TestProxy.class.getCanonicalName();
-        mojo.project = new MavenProject((Model) null) {
-            @Override
-            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
-                return Collections.EMPTY_LIST;
-            }
-        };
-
-        mojo.execute();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
new file mode 100644
index 0000000..7f9661e
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link FileApiMethodGeneratorMojo}
+ */
+public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
+
+    @Test
+    public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
+
+        // delete target file to begin
+        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "/TestProxyApiMethod.java");
+        if (outFile.exists()) {
+            outFile.delete();
+        }
+
+        final FileApiMethodGeneratorMojo mojo = new FileApiMethodGeneratorMojo();
+        mojo.substitutions = new Substitution[1];
+        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
+
+        mojo.outDir = new File(OUT_DIR);
+        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        mojo.proxyClass = TestProxy.class.getCanonicalName();
+        mojo.project = new MavenProject((Model) null) {
+            @Override
+            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
+                return Collections.EMPTY_LIST;
+            }
+        };
+        mojo.signatureFile = new File("src/test/resources/test-proxy-signatures.txt");
+
+        mojo.execute();
+
+        // check target file was generated
+        assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
new file mode 100644
index 0000000..8ac2d46
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Model;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.app.VelocityEngine;
+import org.junit.Test;
+
+/**
+ * Tests {@link JavadocApiMethodGeneratorMojo}
+ */
+public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
+
+    @Test
+    public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
+
+        // delete target file to begin
+        final File outFile = new File(OUT_DIR, AbstractGeneratorMojo.OUT_PACKAGE.replaceAll("\\.", "/") + "/VelocityEngineApiMethod.java");
+        if (outFile.exists()) {
+            outFile.delete();
+        }
+
+        final JavadocApiMethodGeneratorMojo mojo = new JavadocApiMethodGeneratorMojo();
+
+        mojo.outDir = new File(OUT_DIR);
+        mojo.outPackage = AbstractGeneratorMojo.OUT_PACKAGE;
+        // use VelocityEngine javadoc
+        mojo.proxyClass = VelocityEngine.class.getCanonicalName();
+        mojo.project = new MavenProject((Model) null) {
+            @Override
+            public List getRuntimeClasspathElements() throws DependencyResolutionRequiredException {
+                return Collections.EMPTY_LIST;
+            }
+        };
+        mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
+
+        mojo.execute();
+
+        // check target file was generated
+        assertExists(outFile);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ecee7f1f/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
new file mode 100644
index 0000000..1d5ba35
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/test-proxy-signatures.txt
@@ -0,0 +1,7 @@
+public String sayHi();
+public String sayHi(final String name);
+public final String greetMe(final String name);
+public final String greetUs(final String name1, String name2);
+public final String greetAll(String[] names);
+public final String greetAll(java.util.List<String> names);
+public final String[] greetTimes(String name, int times);


[24/35] git commit: Added support for creating endpoint configuration from ApiCollection, added method aliases to tests, minor refactoring

Posted by dh...@apache.org.
Added support for creating endpoint configuration from ApiCollection, added method aliases to tests, minor refactoring


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

Branch: refs/heads/master
Commit: 5bf87ed423ec661b190792e721453248fe48984f
Parents: a056dfa
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Tue Jun 3 21:39:35 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:33 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiCollection.java     | 18 ++++++-
 .../src/it/all-it/pom.xml                       | 10 ++++
 .../maven/AbstractApiMethodGeneratorMojo.java   |  7 +--
 .../camel/maven/AbstractGeneratorMojo.java      | 22 ++++++++-
 .../camel/maven/ApiComponentGeneratorMojo.java  |  6 ++-
 .../org/apache/camel/maven/ApiMethodAlias.java  | 50 ++++++++++++++++++++
 .../java/org/apache/camel/maven/ApiProxy.java   | 13 +++--
 .../src/main/resources/api-collection.vm        | 24 ++++++++--
 .../src/main/resources/api-endpoint-config.vm   |  6 +--
 .../src/main/resources/api-route-test.vm        |  4 +-
 .../src/main/resources/log4j.properties         | 36 ++++++++++++++
 .../maven/ApiComponentGeneratorMojoTest.java    |  7 ++-
 .../src/test/resources/log4j.properties         | 36 --------------
 13 files changed, 184 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
index 1183591..a1fd2b7 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
@@ -26,14 +26,23 @@ import java.util.Set;
  * Base class for a collection of ApiMethods. Meant to be extended by Components to create the api name map.
  */
 @SuppressWarnings("unused")
-public abstract class ApiCollection<T extends Enum & ApiName> {
+public abstract class ApiCollection<T extends Enum & ApiName, C> {
 
     protected final Map<T, ApiMethodHelper> apis = new HashMap<T, ApiMethodHelper>();
 
+    /**
+     * Returns a {@link ApiMethodHelper} for a particular API.
+     * @param apiName name of the API
+     * @return helper class to work with {@link ApiMethod}
+     */
     public final ApiMethodHelper getHelper(T apiName) {
         return apis.get(apiName);
     }
 
+    /**
+     * Returns a list of API name strings.
+     * @return list of API names.
+     */
     public final Set<String> getApiNames() {
         final Set<String> result = new HashSet<String>();
         for (T api : apis.keySet()) {
@@ -41,4 +50,11 @@ public abstract class ApiCollection<T extends Enum & ApiName> {
         }
         return Collections.unmodifiableSet(result);
     }
+
+    /**
+     * Creates an endpoint configuration for a particular API
+     * @param apiName name of the API.
+     * @return Endpoint configuration object for the API.
+     */
+    public abstract C getEndpointConfiguration(T apiName);
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
index 269aefc..5ebd269 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
@@ -136,6 +136,16 @@
                 <api>
                   <apiName>velocity</apiName>
                   <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
+                  <aliases>
+                    <alias>
+                      <methodPattern>get(.+)</methodPattern>
+                      <methodAlias>$1</methodAlias>
+                    </alias>
+                    <alias>
+                      <methodPattern>set(.+)</methodPattern>
+                      <methodAlias>$1</methodAlias>
+                    </alias>
+                  </aliases>
                 </api>
               </apis>
             </configuration>

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
index 8b868c4..de70464 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -204,8 +204,9 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         return resultType == Void.TYPE;
     }
 
-    public String getPropertyPrefix() {
-        return componentName + ".";
+    public String getExchangePropertyPrefix() {
+        // exchange property prefix
+        return "Camel" + componentName + ".";
     }
 
     public static String getResultDeclaration(Class<?> resultType) {
@@ -240,7 +241,7 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         }
     }
 
-    public static String getPropertySuffix(String parameter) {
+    public static String getBeanPropertySuffix(String parameter) {
         // capitalize first character
         StringBuilder builder = new StringBuilder();
         builder.append(Character.toUpperCase(parameter.charAt(0)));

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
index 3979745..faf0964 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -49,6 +50,7 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
     protected static final String PREFIX = "org.apache.camel.";
     protected static final String OUT_PACKAGE = PREFIX + "component.internal";
     protected static final String COMPONENT_PACKAGE = PREFIX + "component";
+    private static final String LOGGER_PREFIX = "log4j.logger";
 
     // used for velocity logging, to avoid creating velocity.log
     protected final Logger LOG = Logger.getLogger(this.getClass());
@@ -77,6 +79,24 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
     private VelocityEngine engine;
     private ClassLoader projectClassLoader;
 
+    protected AbstractGeneratorMojo() {
+        // configure Log4J from system properties
+        for (String propertyName : System.getProperties().stringPropertyNames())
+        {
+            if (propertyName.startsWith(LOGGER_PREFIX)) {
+                String loggerName = propertyName.substring(LOGGER_PREFIX.length());
+                String levelName = System.getProperty(propertyName, "");
+                Level level = Level.toLevel(levelName); // defaults to DEBUG
+                if (!"".equals(levelName) && !levelName.toUpperCase().equals(level.toString())) {
+                    LOG.warn("Skipping unrecognized log4j log level " + levelName + ": -D" + propertyName + "=" + levelName);
+                    continue;
+                }
+                LOG.debug("Setting " + loggerName + " => " + level.toString());
+                Logger.getLogger(loggerName).setLevel(level);
+            }
+        }
+    }
+
     public VelocityEngine getEngine() {
         if (engine == null) {
             // initialize velocity to load resources from class loader and use Log4J
@@ -84,7 +104,7 @@ public abstract class AbstractGeneratorMojo extends AbstractMojo {
             velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
             velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
             velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
-            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM + ".log4j.logger", LOG.getName());
+            velocityProperties.setProperty(Log4JLogChute.RUNTIME_LOG_LOG4J_LOGGER, LOG.getName());
             engine = new VelocityEngine(velocityProperties);
             engine.init();
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
index d0d4b97..28d5e3b 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
@@ -52,7 +52,7 @@ public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
     private VelocityContext getApiContext() {
         final VelocityContext context = new VelocityContext();
         context.put("componentName", componentName);
-        context.put("packageName", outPackage);
+        context.put("componentPackage", componentPackage);
         context.put("apis", apis);
         context.put("helper", getClass());
         context.put("collectionName", getApiCollectionName());
@@ -90,6 +90,10 @@ public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
         return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "ApiMethod";
     }
 
+    public static String getEndpointConfig(String proxyClass) {
+        return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "EndpointConfiguration";
+    }
+
     public static String getEnumConstant(String enumValue) {
         if (enumValue == null || enumValue.isEmpty()) {
             return "DEFAULT";

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
new file mode 100644
index 0000000..71bb89e
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
@@ -0,0 +1,50 @@
+/**
+ * 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;
+
+/**
+ * Represents method alias
+ */
+public class ApiMethodAlias {
+
+    private String methodPattern;
+    private String methodAlias;
+
+    public ApiMethodAlias() {
+    }
+
+    public ApiMethodAlias(String methodPattern, String methodAlias) {
+        this.methodPattern = methodPattern;
+        this.methodAlias = methodAlias;
+    }
+
+    public String getMethodPattern() {
+        return methodPattern;
+    }
+
+    public void setMethodPattern(String methodPattern) {
+        this.methodPattern = methodPattern;
+    }
+
+    public String getMethodAlias() {
+        return methodAlias;
+    }
+
+    public void setMethodAlias(String methodAlias) {
+        this.methodAlias = methodAlias;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
index b708e37..69a759b 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
@@ -17,7 +17,7 @@
 package org.apache.camel.maven;
 
 import java.util.Collections;
-import java.util.Map;
+import java.util.List;
 
 /**
  * Represents an API to use for generating Camel Component.
@@ -26,7 +26,7 @@ public class ApiProxy {
     private String apiName;
     private String proxyClass;
 
-    private Map<String, String> aliases = Collections.EMPTY_MAP;
+    private List<ApiMethodAlias> aliases = Collections.EMPTY_LIST;
 
     public ApiProxy() {
     }
@@ -36,6 +36,11 @@ public class ApiProxy {
         this.proxyClass = proxyClass;
     }
 
+    public ApiProxy(String apiName, String proxyClass, List<ApiMethodAlias> aliases) {
+        this(apiName, proxyClass);
+        this.aliases = aliases;
+    }
+
     public String getApiName() {
         return apiName;
     }
@@ -52,11 +57,11 @@ public class ApiProxy {
         this.proxyClass = proxyClass;
     }
 
-    public Map<String, String> getAliases() {
+    public List<ApiMethodAlias> getAliases() {
         return aliases;
     }
 
-    public void setAliases(Map<String, String> aliases) {
+    public void setAliases(List<ApiMethodAlias> aliases) {
         this.aliases = aliases;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index b7213c6..6596d16 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -24,13 +24,19 @@ package $packageName;
 import java.util.Map;
 import java.util.HashMap;
 
+#set( $componentConfig = "${componentName}Config" )
+import ${componentPackage}.${componentConfig};
+#foreach ( $api in $apis )
+import ${componentPackage}.${helper.getEndpointConfig($api.ProxyClass)};
+#end
+
 import org.apache.camel.util.component.ApiCollection;
 import org.apache.camel.util.component.ApiMethodHelper;
 
 /**
  * Camel {@link ApiCollection} for $componentName
  */
-public final class $collectionName extends ApiCollection<${apiNameEnum}> {
+public final class $collectionName extends ApiCollection<${apiNameEnum}, ${componentConfig}> {
 
     private static $collectionName collection;
 
@@ -38,14 +44,26 @@ public final class $collectionName extends ApiCollection<${apiNameEnum}> {
         final Map<String, String> aliases = new HashMap<String, String>();
 #foreach( $api in $apis )
         aliases.clear();
-#foreach( $alias in $api.Aliases.entrySet() )
-        aliases.put("$alias.Key", "$alias.Value");
+#foreach( $alias in $api.Aliases )
+        aliases.put("$alias.MethodPattern", "$alias.MethodAlias");
 #end
 #set( $apiMethod = $helper.getApiMethod($api.ProxyClass) )
         apis.put(${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}, new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
 #end
     }
 
+    public $componentConfig getEndpointConfiguration(${apiNameEnum} apiName) {
+        $componentConfig result = null;
+        switch (apiName) {
+#foreach( $api in $apis )
+        case ${helper.getEnumConstant($api.ApiName)}:
+            result = new ${helper.getEndpointConfig($api.ProxyClass)}();
+            break;
+#end
+        }
+        return result;
+    }
+
     public static synchronized $collectionName getCollection() {
         if (collection == null) {
             collection = new $collectionName();

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
index ca44ad9..03ddd4b 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
@@ -34,13 +34,13 @@ public final class $configName extends ${componentName}Config {
 #foreach( $parameter in $parameters.entrySet() )
 #set ( $name = $parameter.Key )
 #set ( $type = $helper.getCanonicalName($parameter.Value) )
-#set ( $propertySuffix = $helper.getPropertySuffix($name) )
+#set ( $suffix = $helper.getBeanPropertySuffix($name) )
 
-    public $type get${propertySuffix}() {
+    public $type get${suffix}() {
         return $name;
     }
 
-    public void set${propertySuffix}($type $name) {
+    public void set${suffix}($type $name) {
         this.$name = $name;
     }
 #end

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
index d12adea..f61ecc5 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
@@ -60,9 +60,9 @@ public class ${testName} extends CamelTestSupport {
 #foreach ( $arg in $args )
 #if ( !$arg.Type.isPrimitive() )
         // parameter type is $helper.getCanonicalName($arg.Type)
-        headers.put("${helper.getPropertyPrefix()}${arg.Name}", null);
+        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", null);
 #else
-        headers.put("${helper.getPropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
+        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
 #end
 #end
 #end

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties
new file mode 100644
index 0000000..3d544fc
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/log4j.properties
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
+
+#log4j.logger.org.apache.camel.maven=DEBUG
+#log4j.logger.org.apache.http=DEBUG
+#log4j.logger.org.apache.camel.util.component=TRACE

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
index 4b4e7ee..3e9400c 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
@@ -17,6 +17,8 @@
 package org.apache.camel.maven;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.camel.component.test.TestProxy;
 import org.apache.velocity.VelocityContext;
@@ -40,7 +42,10 @@ public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
 
         mojo.apis = new ApiProxy[2];
         mojo.apis[0] = new ApiProxy("test", TestProxy.class.getName());
-        mojo.apis[1] = new ApiProxy("velocity", VelocityContext.class.getName());
+        List<ApiMethodAlias> aliases = new ArrayList<ApiMethodAlias>();
+        aliases.add(new ApiMethodAlias("get(.+)", "$1"));
+        aliases.add(new ApiMethodAlias("set(.+)", "$1"));
+        mojo.apis[1] = new ApiProxy("velocity", VelocityContext.class.getName(), aliases);
 
         mojo.execute();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/5bf87ed4/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties b/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties
deleted file mode 100644
index 3d544fc..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,36 +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.
-#
-
-#
-# The logging properties used
-#
-log4j.rootLogger=INFO, out
-
-# uncomment the following line to turn on Camel debugging
-#log4j.logger.org.apache.camel=DEBUG
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-
-log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
-
-#log4j.logger.org.apache.camel.maven=DEBUG
-#log4j.logger.org.apache.http=DEBUG
-#log4j.logger.org.apache.camel.util.component=TRACE


[21/35] git commit: Fixed method alias handling, changed component config file name pattern

Posted by dh...@apache.org.
Fixed method alias handling, changed component config file name pattern


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

Branch: refs/heads/master
Commit: 96c8ec0f4da3df0f6bbe0374a625dddaa2d7524d
Parents: 5bf87ed
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 13:47:58 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:33 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodHelper.java   | 21 +++++++++++++-----
 .../component/ApiMethodPropertiesHelper.java    | 14 ++++++------
 .../ApiMethodPropertiesHelperTest.java          |  4 ++--
 .../src/main/resources/api-collection.vm        |  2 +-
 .../src/main/resources/api-endpoint-config.vm   |  2 +-
 .../src/main/resources/api-name-enum.vm         |  2 +-
 .../apache/camel/component/test/TestConfig.java | 23 --------------------
 .../camel/component/test/TestConfiguration.java | 23 ++++++++++++++++++++
 8 files changed, 51 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
index dbbc332..a698c1e 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
@@ -50,7 +50,7 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
     private final Map<String, Class<?>> VALID_ARGUMENTS = new HashMap<String, Class<?>>();
 
     // maps aliases to actual method names
-    private final HashMap<String, String> ALIASES = new HashMap<String, String>();
+    private final HashMap<String, Set<String>> ALIASES = new HashMap<String, Set<String>>();
 
     /**
      * Create a helper to work with a {@link ApiMethod}, using optional method aliases.
@@ -94,7 +94,12 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
                         builder.append(Character.toLowerCase(firstChar)).append(alias.substring(1));
                         alias = builder.toString();
                     }
-                    ALIASES.put(alias, name);
+                    Set<String> names = ALIASES.get(alias);
+                    if (names == null) {
+                        names = new HashSet<String>();
+                        ALIASES.put(alias, names);
+                    }
+                    names.add(name);
                 }
             }
 
@@ -144,7 +149,7 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
     /**
      * Gets methods that match the given name and arguments.<p/>
      * Note that the args list is a required subset of arguments for returned methods.
-     * @param name case sensitive full method name to lookup
+     * @param name case sensitive method name or alias to lookup
      * @param argNames unordered required argument names
      * @return non-null unmodifiable list of methods that take all of the given arguments, empty if there is no match
      */
@@ -152,7 +157,10 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
         List<T> methods = METHOD_MAP.get(name);
         if (methods == null) {
             if (ALIASES.containsKey(name)) {
-                methods = METHOD_MAP.get(ALIASES.get(name));
+                methods = new ArrayList<T>();
+                for (String method : ALIASES.get(name)) {
+                    methods.addAll(METHOD_MAP.get(method));
+                }
             }
         }
         if (methods == null) {
@@ -232,7 +240,10 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
         List<Object> arguments = ARGUMENTS_MAP.get(name);
         if (arguments == null) {
             if (ALIASES.containsKey(name)) {
-                arguments = ARGUMENTS_MAP.get(ALIASES.get(name));
+                arguments = new ArrayList<Object>();
+                for (String method : ALIASES.get(name)) {
+                    arguments.addAll(ARGUMENTS_MAP.get(method));
+                }
             }
         }
         if (arguments == null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
index ea0f442..4cd692c 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
@@ -29,19 +29,19 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Helper class to work with ApiMethod arguments.
+ * Helper class to work with ApiMethod arguments to be extended by components.
  */
-public final class ApiMethodPropertiesHelper<C> {
+public abstract class ApiMethodPropertiesHelper<C> {
 
-    private final Logger LOG = LoggerFactory.getLogger(ApiMethodPropertiesHelper.class);
+    protected Logger LOG = LoggerFactory.getLogger(ApiMethodPropertiesHelper.class);
 
     // set of field names which are specific to the api, to be excluded from method argument considerations
-    private final Set<String> COMPONENT_CONFIG_FIELDS = new HashSet<String>();
+    protected final Set<String> COMPONENT_CONFIG_FIELDS = new HashSet<String>();
 
-    private final Class<?> componentConfigClass;
-    private final String propertyPrefix;
+    protected final Class<?> componentConfigClass;
+    protected final String propertyPrefix;
 
-    public ApiMethodPropertiesHelper(Class<C> componentConfiguration, String propertyPrefix) {
+    protected ApiMethodPropertiesHelper(Class<C> componentConfiguration, String propertyPrefix) {
 
         this.componentConfigClass = componentConfiguration;
         this.propertyPrefix = propertyPrefix;

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
index c711c5f..cfc29d1 100644
--- a/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertEquals;
 
 public class ApiMethodPropertiesHelperTest {
 
-    private static final String TEST_PREFIX = "TestComponent.";
+    private static final String TEST_PREFIX = "CamelTest.";
 
     private static final String PROPERTY_1 = TEST_PREFIX + "property1";
     private static final String PROPERTY_2 = TEST_PREFIX + "property2";
@@ -38,7 +38,7 @@ public class ApiMethodPropertiesHelperTest {
     private static final String VALUE_4 = "true";
 
     private static ApiMethodPropertiesHelper propertiesHelper =
-            new ApiMethodPropertiesHelper(TestComponentConfiguration.class, TEST_PREFIX);
+            new ApiMethodPropertiesHelper(TestComponentConfiguration.class, TEST_PREFIX){};
 
     @Test
     public void testGetExchangeProperties() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index 6596d16..e2c7eb4 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -24,7 +24,7 @@ package $packageName;
 import java.util.Map;
 import java.util.HashMap;
 
-#set( $componentConfig = "${componentName}Config" )
+#set( $componentConfig = "${componentName}Configuration" )
 import ${componentPackage}.${componentConfig};
 #foreach ( $api in $apis )
 import ${componentPackage}.${helper.getEndpointConfig($api.ProxyClass)};

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
index 03ddd4b..f01d29e 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-endpoint-config.vm
@@ -25,7 +25,7 @@ package ${componentPackage};
  * Camel EndpointConfiguration for $proxyType.Name
  */
 @SuppressWarnings("unused")
-public final class $configName extends ${componentName}Config {
+public final class $configName extends ${componentName}Configuration {
 
 #foreach( $parameter in $parameters.entrySet() )
     private $helper.getCanonicalName($parameter.Value) $parameter.Key;

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
index f4fa253..e0d558d 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
@@ -45,7 +45,7 @@ public enum $apiNameEnum implements ApiName {
         return name;
     }
 
-    public static $apiNameEnum fromValue(String value) {
+    public static $apiNameEnum fromValue(String value) throws IllegalArgumentException {
         for ($apiNameEnum api : ${apiNameEnum}.values()) {
             if (api.name.equals(value)) {
                 return api;

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java
deleted file mode 100644
index 429280e..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfig.java
+++ /dev/null
@@ -1,23 +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.component.test;
-
-/**
- * Dummy component config.
- */
-public class TestConfig {
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/96c8ec0f/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
new file mode 100644
index 0000000..de22f82
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
@@ -0,0 +1,23 @@
+/**
+ * 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.component.test;
+
+/**
+ * Dummy component configuration.
+ */
+public class TestConfiguration {
+}


[16/35] git commit: Updated ApiCollection to use type ApiName, fixed method name constant to be locale independent

Posted by dh...@apache.org.
Updated ApiCollection to use type ApiName, fixed method name constant to be locale independent


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

Branch: refs/heads/master
Commit: a38476c24af048437a8fb4ddb35b73ad5dbeb4ea
Parents: fad4865
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon Jun 2 15:45:47 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:32 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiCollection.java     | 14 +++++++---
 .../camel/util/component/ApiMethodParser.java   | 11 ++++++--
 .../apache/camel/util/component/ApiName.java    | 29 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a38476c2/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
index 6520d1c..1183591 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
@@ -18,21 +18,27 @@ package org.apache.camel.util.component;
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
 /**
  * Base class for a collection of ApiMethods. Meant to be extended by Components to create the api name map.
  */
-public abstract class ApiCollection {
+@SuppressWarnings("unused")
+public abstract class ApiCollection<T extends Enum & ApiName> {
 
-    protected final Map<String, ApiMethodHelper> apis = new HashMap<String, ApiMethodHelper>();
+    protected final Map<T, ApiMethodHelper> apis = new HashMap<T, ApiMethodHelper>();
 
-    public final ApiMethodHelper getHelper(String apiName) {
+    public final ApiMethodHelper getHelper(T apiName) {
         return apis.get(apiName);
     }
 
     public final Set<String> getApiNames() {
-        return Collections.unmodifiableSet(apis.keySet());
+        final Set<String> result = new HashSet<String>();
+        for (T api : apis.keySet()) {
+            result.add(api.getName());
+        }
+        return Collections.unmodifiableSet(result);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a38476c2/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
index b7e6ef7..1003df4 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -178,8 +178,15 @@ public abstract class ApiMethodParser<T> {
         // assign unique names to every method model
         final Map<String, Integer> dups = new HashMap<String, Integer>();
         for (ApiMethodModel model : result) {
-            // TODO watch out, this uses default locale to convert to upper case
-            String uniqueName = model.name.toUpperCase();
+            // locale independent upper case conversion
+            final String name = model.getName();
+            final char[] upperCase = new char[name.length()];
+            final char[] lowerCase = name.toCharArray();
+            for (int i = 0; i < upperCase.length; i++) {
+                upperCase[i] = Character.toUpperCase(lowerCase[i]);
+            }
+            String uniqueName = new String(upperCase);
+
             Integer suffix = dups.get(uniqueName);
             if (suffix == null) {
                 dups.put(uniqueName, 1);

http://git-wip-us.apache.org/repos/asf/camel/blob/a38476c2/camel-core/src/main/java/org/apache/camel/util/component/ApiName.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiName.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiName.java
new file mode 100644
index 0000000..9c863fd
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiName.java
@@ -0,0 +1,29 @@
+/**
+ * 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.util.component;
+
+/**
+ * Marker interface for ApiName enumerations.
+ */
+public interface ApiName {
+
+    /**
+     * Returns API name prefix path element for endpoint uri.
+     * @return unique API name prefix
+     */
+    String getName();
+}


[34/35] git commit: Renamed component-util plugin to api-component

Posted by dh...@apache.org.
Renamed component-util plugin to api-component


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

Branch: refs/heads/master
Commit: 0c9fbb62b426c4374b94b35b229b179295ae587b
Parents: 420fed0
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Tue Jun 10 12:19:21 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:35 2014 -0700

----------------------------------------------------------------------
 .../META-INF/maven/archetype-metadata.xml       |   2 +-
 .../__artifactId__-component/pom.xml            |   2 +-
 .../camel-api-component-maven-plugin/pom.xml    | 225 +++++++++++++++
 .../src/it/all-it/pom.xml                       | 185 +++++++++++++
 .../src/it/all-it/verify.groovy                 |  22 ++
 .../src/it/settings.xml                         |  55 ++++
 .../maven/AbstractApiMethodGeneratorMojo.java   | 265 ++++++++++++++++++
 .../camel/maven/AbstractGeneratorMojo.java      | 167 +++++++++++
 .../camel/maven/ApiComponentGeneratorMojo.java  | 115 ++++++++
 .../org/apache/camel/maven/ApiMethodAlias.java  |  50 ++++
 .../java/org/apache/camel/maven/ApiProxy.java   |  73 +++++
 .../camel/maven/FileApiMethodGeneratorMojo.java |  64 +++++
 .../maven/JavadocApiMethodGeneratorMojo.java    | 276 +++++++++++++++++++
 .../org/apache/camel/maven/Substitution.java    |  80 ++++++
 .../src/main/resources/api-collection.vm        |  76 +++++
 .../src/main/resources/api-endpoint-config.vm   |  47 ++++
 .../src/main/resources/api-method-enum.vm       |  63 +++++
 .../src/main/resources/api-name-enum.vm         |  56 ++++
 .../src/main/resources/api-route-test.vm        | 109 ++++++++
 .../src/main/resources/log4j.properties         |  36 +++
 .../camel/component/test/TestConfiguration.java |  23 ++
 .../apache/camel/component/test/TestProxy.java  |  68 +++++
 .../camel/maven/AbstractGeneratorMojoTest.java  |  72 +++++
 .../maven/ApiComponentGeneratorMojoTest.java    |  55 ++++
 .../maven/FileApiMethodGeneratorMojoTest.java   |  57 ++++
 .../JavadocApiMethodGeneratorMojoTest.java      |  58 ++++
 .../test/resources/test-proxy-signatures.txt    |   8 +
 .../camel-component-util-maven-plugin/pom.xml   | 225 ---------------
 .../src/it/all-it/pom.xml                       | 185 -------------
 .../src/it/all-it/verify.groovy                 |  22 --
 .../src/it/settings.xml                         |  55 ----
 .../maven/AbstractApiMethodGeneratorMojo.java   | 265 ------------------
 .../camel/maven/AbstractGeneratorMojo.java      | 167 -----------
 .../camel/maven/ApiComponentGeneratorMojo.java  | 115 --------
 .../org/apache/camel/maven/ApiMethodAlias.java  |  50 ----
 .../java/org/apache/camel/maven/ApiProxy.java   |  73 -----
 .../camel/maven/FileApiMethodGeneratorMojo.java |  64 -----
 .../maven/JavadocApiMethodGeneratorMojo.java    | 276 -------------------
 .../org/apache/camel/maven/Substitution.java    |  80 ------
 .../src/main/resources/api-collection.vm        |  76 -----
 .../src/main/resources/api-endpoint-config.vm   |  47 ----
 .../src/main/resources/api-method-enum.vm       |  63 -----
 .../src/main/resources/api-name-enum.vm         |  56 ----
 .../src/main/resources/api-route-test.vm        | 109 --------
 .../src/main/resources/log4j.properties         |  36 ---
 .../camel/component/test/TestConfiguration.java |  23 --
 .../apache/camel/component/test/TestProxy.java  |  68 -----
 .../camel/maven/AbstractGeneratorMojoTest.java  |  72 -----
 .../maven/ApiComponentGeneratorMojoTest.java    |  55 ----
 .../maven/FileApiMethodGeneratorMojoTest.java   |  57 ----
 .../JavadocApiMethodGeneratorMojoTest.java      |  58 ----
 .../test/resources/test-proxy-signatures.txt    |   8 -
 tooling/maven/pom.xml                           |   2 +-
 53 files changed, 2308 insertions(+), 2308 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
index f597ef5..935370b 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -15,7 +15,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
-<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="camel-archetype-from-apis"
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="camel-archetype-api-component"
     xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index 8e66c2c..05992cb 100644
--- a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -136,7 +136,7 @@
       <!-- generate Component source and test source -->
       <plugin>
         <groupId>org.apache.camel</groupId>
-        <artifactId>camel-component-util-maven-plugin</artifactId>
+        <artifactId>camel-api-component-maven-plugin</artifactId>
         <version>${camel-version}</version>
         <executions>
           <execution>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/pom.xml b/tooling/maven/camel-api-component-maven-plugin/pom.xml
new file mode 100644
index 0000000..7ed800d
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/pom.xml
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>maven-plugins</artifactId>
+    <version>2.14-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-api-component-maven-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Camel :: Maven Plugins :: Camel API Component Plugin</name>
+  <description>Maven plugin to generate code for Camel Components based on third party APIs</description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-descriptor</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>${velocity-version}</version>
+    </dependency>
+
+    <!-- add some logging to the classpath -->
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- VelocityEngine javadoc for testing -->
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>${velocity-version}</version>
+      <classifier>javadoc</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-plugin-plugin</artifactId>
+          <version>3.3</version>
+          <configuration>
+            <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
+            <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+          </configuration>
+          <executions>
+            <execution>
+              <id>mojo-descriptor</id>
+              <goals>
+                  <goal>descriptor</goal>
+              </goals>
+            </execution>
+            <execution>
+              <id>help-goal</id>
+              <goals>
+                  <goal>helpmojo</goal>
+              </goals>
+            </execution>
+          </executions>
+          </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <!-- copy test utility classes to integration test project -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-it-resources</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <encoding>UTF-8</encoding>
+              <overwrite>true</overwrite>
+              <outputDirectory>${project.build.directory}/it/all-it/src/main/java/org/apache/camel/component/test</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>src/test/java/org/apache/camel/component/test</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- validate generated code after unit tests -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>add-generated-test-sources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-test-sources/camel-component</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>validate-generated-test-sources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+            <configuration>
+              <fork>false</fork>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <!-- Plugin integration test profile -->
+  <profiles>
+    <profile>
+      <id>plugin-itest</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-invoker-plugin</artifactId>
+            <version>1.8</version>
+            <configuration>
+              <debug>true</debug>
+              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+              <pomIncludes>
+                <pomInclude>*/pom.xml</pomInclude>
+              </pomIncludes>
+              <postBuildHookScript>verify</postBuildHookScript>
+              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+              <settingsFile>src/it/settings.xml</settingsFile>
+              <goals>
+                <goal>clean</goal>
+                <goal>verify</goal>
+              </goals>
+            </configuration>
+            <executions>
+              <execution>
+                <id>integration-test</id>
+                <goals>
+                  <goal>install</goal>
+                  <goal>integration-test</goal>
+                  <goal>verify</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+
+      </build>
+    </profile>
+  </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/pom.xml b/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/pom.xml
new file mode 100644
index 0000000..ba2bf7c
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/pom.xml
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-api-component-maven-plugin-it</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <description>Integration Test to verify all goals.</description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <outPackage>org.apache.camel.component.test.internal</outPackage>
+    <componentPackage>org.apache.camel.component.test</componentPackage>
+    <scheme>testComponent</scheme>
+    <componentName>Test</componentName>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <version>@project.version@</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>@velocity-version@</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <version>@project.version@</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- VelocityEngine javadoc for testing -->
+    <dependency>
+      <groupId>org.apache.velocity</groupId>
+      <artifactId>velocity</artifactId>
+      <version>@velocity-version@</version>
+      <classifier>javadoc</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- execute api-component plugin -->
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>generate-file-api-method</id>
+            <!-- using generate-test-sources instead of generate-sources to be able to load TestProxy.class -->
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>fromFile</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${scheme}</scheme>
+              <componentName>${componentName}</componentName>
+              <proxyClass>org.apache.camel.component.test.TestProxy</proxyClass>
+              <substitutions>
+                <substitution>
+                  <method>.+</method>
+                  <argName>(.+)</argName>
+                  <argType>java.util.List</argType>
+                  <replacement>$1List</replacement>
+                </substitution>
+                <substitution>
+                  <method>.+</method>
+                  <argName>(.+)</argName>
+                  <argType>.*?(\w++)\[\]</argType>
+                  <replacement>$1Array</replacement>
+                  <replaceWithType>true</replaceWithType>
+                </substitution>
+              </substitutions>
+              <signatureFile>../../../src/test/resources/test-proxy-signatures.txt</signatureFile>
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-velocity-context-api-method</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>fromJavadoc</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${scheme}</scheme>
+              <componentName>${componentName}</componentName>
+              <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
+              <substitutions>
+                <substitution>
+                  <method>.+</method>
+                  <argName>key</argName>
+                  <argType>java.lang.Object</argType>
+                  <replacement>applicationKey</replacement>
+                </substitution>
+              </substitutions>
+              <excludeClasses>InternalContextBase</excludeClasses>
+              <excludeMethods>clone|Current|internal|icache</excludeMethods>
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-test-component-classes</id>
+            <phase>generate-test-sources</phase>
+            <goals>
+              <goal>fromApis</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${scheme}</scheme>
+              <componentName>${componentName}</componentName>
+              <apis>
+                <api>
+                  <apiName>test</apiName>
+                  <proxyClass>org.apache.camel.component.test.TestProxy</proxyClass>
+                </api>
+                <api>
+                  <apiName>velocity</apiName>
+                  <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
+                  <aliases>
+                    <alias>
+                      <methodPattern>get(.+)</methodPattern>
+                      <methodAlias>$1</methodAlias>
+                    </alias>
+                    <alias>
+                      <methodPattern>set(.+)</methodPattern>
+                      <methodAlias>$1</methodAlias>
+                    </alias>
+                  </aliases>
+                </api>
+              </apis>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- add generated source and test source to build for test-compile -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>@build-helper-maven-plugin-version@</version>
+        <executions>
+          <execution>
+            <id>add-generated-test-sources</id>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-sources/camel-component</source>
+                <source>${project.build.directory}/generated-test-sources/camel-component</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/verify.groovy
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/verify.groovy b/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/verify.groovy
new file mode 100644
index 0000000..73edefd
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/it/all-it/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+// assert that the generated files directory exists
+File sourceDir = new File( basedir, "target/generated-sources/camel-component" );
+File testDir = new File( basedir, "target/generated-test-sources/camel-component" );
+
+assert sourceDir.isDirectory()
+assert testDir.isDirectory()

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/it/settings.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/it/settings.xml b/tooling/maven/camel-api-component-maven-plugin/src/it/settings.xml
new file mode 100644
index 0000000..c8f77f0
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/it/settings.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<settings>
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+</settings>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..852b09e
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -0,0 +1,265 @@
+/**
+ * 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.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.camel.util.component.ApiMethodParser;
+import org.apache.camel.util.component.ArgumentSubstitutionParser;
+import org.apache.commons.lang.ClassUtils;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * Base Mojo class for ApiMethod generators.
+ */
+public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMojo {
+
+    @Parameter(required = true, property = PREFIX + "proxyClass")
+    protected String proxyClass;
+
+    @Parameter(property = PREFIX + "substitutions")
+    protected Substitution[] substitutions = new Substitution[0];
+
+    // cached fields
+    private Class<?> proxyType;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+
+        // load proxy class and get enumeration file to generate
+        final Class proxyType = getProxyType();
+
+        // create parser
+        ApiMethodParser parser = createAdapterParser(proxyType);
+        parser.setSignatures(getSignatureList());
+        parser.setClassLoader(getProjectClassLoader());
+
+        // parse signatures
+        final List<ApiMethodParser.ApiMethodModel> models = parser.parse();
+
+        // generate enumeration from model
+        mergeTemplate(getApiMethodContext(models), getApiMethodFile(), "/api-method-enum.vm");
+
+        // generate EndpointConfiguration for this Api
+        mergeTemplate(getEndpointContext(models), getConfigurationFile(), "/api-endpoint-config.vm");
+
+        // generate junit test if it doesn't already exist under test source directory
+        // i.e. it may have been generated then moved there and populated with test values
+        final String testFilePath = getTestFilePath();
+        if (!new File(project.getBuild().getTestSourceDirectory(), testFilePath).exists()) {
+            mergeTemplate(getApiTestContext(models), new File(generatedTestDir, testFilePath), "/api-route-test.vm");
+        }
+    }
+
+    protected ApiMethodParser createAdapterParser(Class proxyType) {
+        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions()){};
+    }
+
+    public abstract List<String> getSignatureList() throws MojoExecutionException;
+
+    public Class getProxyType() throws MojoExecutionException {
+        if (proxyType == null) {
+            // load proxy class from Project runtime dependencies
+            try {
+                proxyType = getProjectClassLoader().loadClass(proxyClass);
+            } catch (ClassNotFoundException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+        return proxyType;
+    }
+
+    private VelocityContext getApiMethodContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = getCommonContext(models);
+        context.put("enumName", getEnumName());
+        return context;
+    }
+
+    public File getApiMethodFile() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getEnumName()).append(".java");
+        return new File(generatedSrcDir, fileName.toString());
+    }
+
+    private String getEnumName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "ApiMethod";
+    }
+
+    private VelocityContext getApiTestContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = getCommonContext(models);
+        context.put("testName", getUnitTestName());
+        context.put("scheme", scheme);
+        context.put("componentName", componentName);
+        context.put("enumName", getEnumName());
+        return context;
+    }
+
+    private String getTestFilePath() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getUnitTestName()).append(".java");
+        return fileName.toString();
+    }
+
+    private String getUnitTestName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "IntegrationTest";
+    }
+
+    private VelocityContext getEndpointContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = getCommonContext(models);
+        context.put("configName", getConfigName());
+        context.put("componentName", componentName);
+        context.put("componentPackage", componentPackage);
+
+        // generate parameter names and types for configuration, sorted by parameter name
+        Map<String, Class<?>> parameters = new TreeMap<String, Class<?>>();
+        for (ApiMethodParser.ApiMethodModel model : models) {
+            for (ApiMethodParser.Argument argument : model.getArguments()) {
+                if (!parameters.containsKey(argument.getName())) {
+                    Class<?> type = argument.getType();
+                    if (type.isPrimitive()) {
+                        // replace primitives with wrapper classes
+                        type = ClassUtils.primitiveToWrapper(type);
+                    }
+                    parameters.put(argument.getName(), type);
+                }
+            }
+        }
+        context.put("parameters", parameters);
+        return context;
+    }
+
+    private File getConfigurationFile() throws MojoExecutionException {
+        final StringBuilder fileName = new StringBuilder();
+        // endpoint configuration goes in component package
+        fileName.append(componentPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        fileName.append(getConfigName()).append(".java");
+        return new File(generatedSrcDir, fileName.toString());
+    }
+
+    private String getConfigName() throws MojoExecutionException {
+        return getProxyType().getSimpleName() + "EndpointConfiguration";
+    }
+
+    private VelocityContext getCommonContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
+        VelocityContext context = new VelocityContext();
+        context.put("models", models);
+        context.put("proxyType", getProxyType());
+        context.put("helper", this);
+        return context;
+    }
+
+    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
+        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
+        for (int i = 0; i < substitutions.length; i++) {
+            final Substitution substitution = substitutions[i];
+            subs[i] = new ArgumentSubstitutionParser.Substitution(substitution.getMethod(),
+                    substitution.getArgName(), substitution.getArgType(),
+                    substitution.getReplacement(), substitution.isReplaceWithType());
+        }
+        return subs;
+    }
+
+    public static String getType(Class<?> clazz) {
+        if (clazz.isArray()) {
+            // create a zero length array and get the class from the instance
+            return "new " + getCanonicalName(clazz).replaceAll("\\[\\]", "[0]") + ".getClass()";
+        } else {
+            return getCanonicalName(clazz) + ".class";
+        }
+    }
+
+    public static String getTestName(ApiMethodParser.ApiMethodModel model) {
+        final StringBuilder builder = new StringBuilder();
+        final String name = model.getMethod().getName();
+        builder.append(Character.toUpperCase(name.charAt(0)));
+        builder.append(name.substring(1));
+        // find overloaded method suffix from unique name
+        final String uniqueName = model.getUniqueName();
+        if (uniqueName.length() > name.length()) {
+            builder.append(uniqueName.substring(name.length()));
+        }
+        return builder.toString();
+    }
+
+    public static boolean isVoidType(Class<?> resultType) {
+        return resultType == Void.TYPE;
+    }
+
+    public String getExchangePropertyPrefix() {
+        // exchange property prefix
+        return "Camel" + componentName + ".";
+    }
+
+    public static String getResultDeclaration(Class<?> resultType) {
+        if (resultType.isPrimitive()) {
+            return ClassUtils.primitiveToWrapper(resultType).getSimpleName();
+        } else {
+            return getCanonicalName(resultType);
+        }
+    }
+
+    private static final Map<Class<?>, String> PRIMITIVE_VALUES;
+
+    static {
+        PRIMITIVE_VALUES = new HashMap<Class<?>, String>();
+        PRIMITIVE_VALUES.put(Boolean.TYPE, "Boolean.FALSE");
+        PRIMITIVE_VALUES.put(Byte.TYPE, "(byte) 0");
+        PRIMITIVE_VALUES.put(Character.TYPE, "(char) 0");
+        PRIMITIVE_VALUES.put(Short.TYPE, "(short) 0");
+        PRIMITIVE_VALUES.put(Integer.TYPE, "0");
+        PRIMITIVE_VALUES.put(Long.TYPE, "0L");
+        PRIMITIVE_VALUES.put(Float.TYPE, "0.0f");
+        PRIMITIVE_VALUES.put(Double.TYPE, "0.0d");
+    }
+
+    public static String getDefaultArgValue(Class<?> aClass) {
+        if (aClass.isPrimitive()) {
+            // lookup default primitive value string
+            return PRIMITIVE_VALUES.get(aClass);
+        } else {
+            // return type cast null string
+            return "null";
+        }
+    }
+
+    public static String getBeanPropertySuffix(String parameter) {
+        // capitalize first character
+        StringBuilder builder = new StringBuilder();
+        builder.append(Character.toUpperCase(parameter.charAt(0)));
+        builder.append(parameter.substring(1));
+        return builder.toString();
+    }
+
+    public static String getCanonicalName(Class<?> type) {
+        // remove java.lang prefix for default Java package
+        String canonicalName = type.getCanonicalName();
+        final int pkgEnd = canonicalName.lastIndexOf('.');
+        if (pkgEnd > 0 && canonicalName.substring(0, pkgEnd).equals("java.lang")) {
+            canonicalName = canonicalName.substring(pkgEnd + 1);
+        }
+        return canonicalName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
new file mode 100644
index 0000000..faf0964
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
@@ -0,0 +1,167 @@
+/**
+ * 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.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.VelocityException;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.Log4JLogChute;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+/**
+ * Base class for Api based code generation MOJOs.
+ */
+public abstract class AbstractGeneratorMojo extends AbstractMojo {
+
+    protected static final String PREFIX = "org.apache.camel.";
+    protected static final String OUT_PACKAGE = PREFIX + "component.internal";
+    protected static final String COMPONENT_PACKAGE = PREFIX + "component";
+    private static final String LOGGER_PREFIX = "log4j.logger";
+
+    // used for velocity logging, to avoid creating velocity.log
+    protected final Logger LOG = Logger.getLogger(this.getClass());
+
+    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camel-component")
+    protected File generatedSrcDir;
+
+    @Parameter(defaultValue = "${project.build.directory}/generated-test-sources/camel-component")
+    protected File generatedTestDir;
+
+    @Parameter(defaultValue = OUT_PACKAGE)
+    protected String outPackage;
+
+    @Parameter(required = true, property = PREFIX + "scheme")
+    protected String scheme;
+
+    @Parameter(required = true, property = PREFIX + "componentName")
+    protected String componentName;
+
+    @Parameter(defaultValue = COMPONENT_PACKAGE)
+    protected String componentPackage;
+
+    @Parameter(defaultValue = "${project}", readonly = true)
+    MavenProject project;
+
+    private VelocityEngine engine;
+    private ClassLoader projectClassLoader;
+
+    protected AbstractGeneratorMojo() {
+        // configure Log4J from system properties
+        for (String propertyName : System.getProperties().stringPropertyNames())
+        {
+            if (propertyName.startsWith(LOGGER_PREFIX)) {
+                String loggerName = propertyName.substring(LOGGER_PREFIX.length());
+                String levelName = System.getProperty(propertyName, "");
+                Level level = Level.toLevel(levelName); // defaults to DEBUG
+                if (!"".equals(levelName) && !levelName.toUpperCase().equals(level.toString())) {
+                    LOG.warn("Skipping unrecognized log4j log level " + levelName + ": -D" + propertyName + "=" + levelName);
+                    continue;
+                }
+                LOG.debug("Setting " + loggerName + " => " + level.toString());
+                Logger.getLogger(loggerName).setLevel(level);
+            }
+        }
+    }
+
+    public VelocityEngine getEngine() {
+        if (engine == null) {
+            // initialize velocity to load resources from class loader and use Log4J
+            Properties velocityProperties = new Properties();
+            velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
+            velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
+            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
+            velocityProperties.setProperty(Log4JLogChute.RUNTIME_LOG_LOG4J_LOGGER, LOG.getName());
+            engine = new VelocityEngine(velocityProperties);
+            engine.init();
+        }
+        return engine;
+    }
+
+    protected ClassLoader getProjectClassLoader() throws MojoExecutionException {
+        if (projectClassLoader == null)  {
+            final List classpathElements;
+            try {
+                classpathElements = project.getTestClasspathElements();
+            } catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+            final URL[] urls = new URL[classpathElements.size()];
+            int i = 0;
+            for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
+                try {
+                    urls[i] = new File((String) it.next()).toURI().toURL();
+                    LOG.debug("Adding project path " + urls[i]);
+                } catch (MalformedURLException e) {
+                    throw new MojoExecutionException(e.getMessage(), e);
+                }
+            }
+            final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+            projectClassLoader = new URLClassLoader(urls, tccl != null ? tccl : getClass().getClassLoader());
+        }
+        return projectClassLoader;
+    }
+
+    protected void mergeTemplate(VelocityContext context, File outFile, String templateName) throws MojoExecutionException {
+        // ensure parent directories exist
+        outFile.getParentFile().mkdirs();
+
+        // add generated date
+        context.put("generatedDate", new Date().toString());
+        // add output package
+        context.put("packageName", outPackage);
+
+        // load velocity template
+        final Template template = getEngine().getTemplate(templateName, "UTF-8");
+
+        // generate file
+        BufferedWriter writer = null;
+        try {
+            writer = new BufferedWriter(new FileWriter(outFile));
+            template.merge(context, writer);
+        } catch (IOException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        } catch (VelocityException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        } finally {
+            if (writer != null) {
+                try {
+                    writer.close();
+                } catch (IOException ignore) {}
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
new file mode 100644
index 0000000..28d5e3b
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
@@ -0,0 +1,115 @@
+/**
+ * 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 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.apache.velocity.VelocityContext;
+
+/**
+ * Generates Camel Component based on a collection of APIs.
+ */
+@Mojo(name = "fromApis", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
+        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
+
+    @Parameter(required = true)
+    protected ApiProxy[] apis;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        if (apis == null || apis.length == 0) {
+            throw new MojoExecutionException("One or more API proxies are required");
+        }
+
+        // generate ApiCollection
+        mergeTemplate(getApiContext(), getApiCollectionFile(), "/api-collection.vm");
+
+        // generate ApiName
+        mergeTemplate(getApiContext(), getApiNameFile(), "/api-name-enum.vm");
+    }
+
+    private VelocityContext getApiContext() {
+        final VelocityContext context = new VelocityContext();
+        context.put("componentName", componentName);
+        context.put("componentPackage", componentPackage);
+        context.put("apis", apis);
+        context.put("helper", getClass());
+        context.put("collectionName", getApiCollectionName());
+        context.put("apiNameEnum", getApiNameEnum());
+        return context;
+    }
+
+    private String getApiCollectionName() {
+        return componentName + "ApiCollection";
+    }
+
+    private String getApiNameEnum() {
+        return componentName + "ApiName";
+    }
+
+    private File getApiCollectionFile() {
+        final StringBuilder fileName = getFileBuilder();
+        fileName.append(getApiCollectionName()).append(".java");
+        return new File(generatedSrcDir, fileName.toString());
+    }
+
+    private File getApiNameFile() {
+        final StringBuilder fileName = getFileBuilder();
+        fileName.append(getApiNameEnum()).append(".java");
+        return new File(generatedSrcDir, fileName.toString());
+    }
+
+    private StringBuilder getFileBuilder() {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        return fileName;
+    }
+
+    public static String getApiMethod(String proxyClass) {
+        return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "ApiMethod";
+    }
+
+    public static String getEndpointConfig(String proxyClass) {
+        return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "EndpointConfiguration";
+    }
+
+    public static String getEnumConstant(String enumValue) {
+        if (enumValue == null || enumValue.isEmpty()) {
+            return "DEFAULT";
+        }
+        StringBuilder builder = new StringBuilder();
+        if (!Character.isJavaIdentifierStart(enumValue.charAt(0))) {
+            builder.append('_');
+        }
+        for (char c : enumValue.toCharArray()) {
+            char upperCase = Character.toUpperCase(c);
+            if (!Character.isJavaIdentifierPart(upperCase)) {
+                builder.append('_');
+            } else {
+                builder.append(upperCase);
+            }
+        }
+        return builder.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
new file mode 100644
index 0000000..71bb89e
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
@@ -0,0 +1,50 @@
+/**
+ * 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;
+
+/**
+ * Represents method alias
+ */
+public class ApiMethodAlias {
+
+    private String methodPattern;
+    private String methodAlias;
+
+    public ApiMethodAlias() {
+    }
+
+    public ApiMethodAlias(String methodPattern, String methodAlias) {
+        this.methodPattern = methodPattern;
+        this.methodAlias = methodAlias;
+    }
+
+    public String getMethodPattern() {
+        return methodPattern;
+    }
+
+    public void setMethodPattern(String methodPattern) {
+        this.methodPattern = methodPattern;
+    }
+
+    public String getMethodAlias() {
+        return methodAlias;
+    }
+
+    public void setMethodAlias(String methodAlias) {
+        this.methodAlias = methodAlias;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
new file mode 100644
index 0000000..69a759b
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
@@ -0,0 +1,73 @@
+/**
+ * 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.util.Collections;
+import java.util.List;
+
+/**
+ * Represents an API to use for generating Camel Component.
+ */
+public class ApiProxy {
+    private String apiName;
+    private String proxyClass;
+
+    private List<ApiMethodAlias> aliases = Collections.EMPTY_LIST;
+
+    public ApiProxy() {
+    }
+
+    public ApiProxy(String apiName, String proxyClass) {
+        this.apiName = apiName;
+        this.proxyClass = proxyClass;
+    }
+
+    public ApiProxy(String apiName, String proxyClass, List<ApiMethodAlias> aliases) {
+        this(apiName, proxyClass);
+        this.aliases = aliases;
+    }
+
+    public String getApiName() {
+        return apiName;
+    }
+
+    public void setApiName(String apiName) {
+        this.apiName = apiName;
+    }
+
+    public String getProxyClass() {
+        return proxyClass;
+    }
+
+    public void setProxyClass(String proxyClass) {
+        this.proxyClass = proxyClass;
+    }
+
+    public List<ApiMethodAlias> getAliases() {
+        return aliases;
+    }
+
+    public void setAliases(List<ApiMethodAlias> aliases) {
+        this.aliases = aliases;
+    }
+
+    public void validate() {
+        if (apiName == null || proxyClass == null) {
+            throw new IllegalArgumentException("Properties apiName and proxyClass are required");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..566ef0a
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.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;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+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;
+
+/**
+ * Parses ApiMethod signatures from a File.
+ */
+@Mojo(name = "fromFile", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
+        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class FileApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
+
+    @Parameter(required = true, property = PREFIX + "signatureFile")
+    protected File signatureFile;
+
+    @Override
+    public List<String> getSignatureList() throws MojoExecutionException {
+        // get signatureFile as a list of Strings
+        List<String> result = new ArrayList<String>();
+        try {
+            BufferedReader reader = new BufferedReader(new FileReader(this.signatureFile));
+            String line = reader.readLine();
+            while (line != null) {
+                result.add(line);
+                line = reader.readLine();
+            }
+        } catch (FileNotFoundException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        } catch (IOException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+        if (result.isEmpty()) {
+            throw new MojoExecutionException("Signature file " + signatureFile.getPath() + " is empty");
+        }
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
new file mode 100644
index 0000000..28bd958
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -0,0 +1,276 @@
+/**
+ * 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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import javax.swing.text.ChangedCharSetException;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.parser.DTD;
+import javax.swing.text.html.parser.Parser;
+import javax.swing.text.html.parser.TagElement;
+
+import org.apache.camel.util.component.ApiMethodParser;
+import org.apache.camel.util.component.ArgumentSubstitutionParser;
+import org.apache.maven.plugin.MojoExecutionException;
+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.codehaus.plexus.util.IOUtil;
+
+/**
+ * Parses ApiMethod signatures from Javadoc.
+ */
+@Mojo(name = "fromJavadoc", requiresDependencyResolution = ResolutionScope.TEST, requiresProject = true,
+        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
+
+    static {
+        // set Java AWT to headless before using Swing HTML parser
+        System.setProperty("java.awt.headless", "true");
+    }
+
+    protected static final String DEFAULT_EXCLUDE_PACKAGES = "javax?\\.lang.*";
+
+    @Parameter(property = "camel.component.util.excludePackages", defaultValue = DEFAULT_EXCLUDE_PACKAGES)
+    protected String excludePackages;
+
+    @Parameter(property = "camel.component.util.excludeClasses")
+    protected String excludeClasses;
+
+    @Parameter(property = "camel.component.util.excludeMethods")
+    protected String excludeMethods;
+
+    @Override
+    protected ApiMethodParser createAdapterParser(Class proxyType) {
+        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions());
+    }
+
+    @Override
+    public List<String> getSignatureList() throws MojoExecutionException {
+        // signatures as map from signature with no arg names to arg names from JavadocParser
+        Map<String, String> result = new HashMap<String, String>();
+
+        final Pattern packagePatterns = Pattern.compile(excludePackages);
+        Pattern classPatterns = null;
+        if (excludeClasses != null) {
+            classPatterns = Pattern.compile(excludeClasses);
+        }
+        Pattern methodPatterns = null;
+        if (excludeMethods != null) {
+            methodPatterns = Pattern.compile(excludeMethods);
+        }
+
+        // for proxy class and super classes not matching excluded packages or classes
+        for (Class aClass = getProxyType();
+             aClass != null && !packagePatterns.matcher(aClass.getPackage().getName()).matches() &&
+                     (classPatterns == null || !classPatterns.matcher(aClass.getSimpleName()).matches());
+             aClass = aClass.getSuperclass()) {
+
+            LOG.debug("Processing " + aClass.getName());
+            final String javaDocPath = aClass.getName().replaceAll("\\.", "/") + ".html";
+
+            // read javadoc html text for class
+            InputStream inputStream = null;
+            try {
+                inputStream = getProjectClassLoader().getResourceAsStream(javaDocPath);
+                if (inputStream == null) {
+                    LOG.debug("JavaDoc not found on classpath for " + aClass.getName());
+                    break;
+                }
+                // transform the HTML to get method summary as text
+                // dummy DTD
+                final DTD dtd = DTD.getDTD("html.dtd");
+                final JavadocParser htmlParser = new JavadocParser(dtd, javaDocPath);
+                htmlParser.parse(new InputStreamReader(inputStream, "UTF-8"));
+
+                // get public method signature
+                final Map<String, String> methodMap = htmlParser.getMethodText();
+                for (String method : htmlParser.getMethods()) {
+                    if (!result.containsKey(method) &&
+                            (methodPatterns == null || !methodPatterns.matcher(method).find())) {
+
+                        final int leftBracket = method.indexOf('(');
+                        final String name = method.substring(0, leftBracket);
+                        final String args = method.substring(leftBracket + 1, method.length() - 1);
+                        String[] types;
+                        if (args.isEmpty()) {
+                            types = new String[0];
+                        } else {
+                            types = args.split(",");
+                        }
+                        final String resultType = getResultType(aClass, name, types);
+                        if (resultType != null) {
+                            final StringBuilder signature = new StringBuilder(resultType);
+                            signature.append(" ").append(name).append(methodMap.get(method));
+                            result.put(method, signature.toString());
+                        }
+                    }
+                }
+            } catch (IOException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            } finally {
+                IOUtil.close(inputStream);
+            }
+        }
+
+        if (result.isEmpty()) {
+            throw new MojoExecutionException("No public non-static methods found, " +
+                    "make sure Javadoc is available as project test dependency");
+        }
+        return new ArrayList<String>(result.values());
+    }
+
+    private String getResultType(Class<?> aClass, String name, String[] types) throws MojoExecutionException {
+        Class<?>[] argTypes = new Class<?>[types.length];
+        final ClassLoader classLoader = getProjectClassLoader();
+        for (int i = 0; i < types.length; i++) {
+            try {
+                try {
+                    argTypes[i] = ApiMethodParser.forName(types[i].trim(), classLoader);
+                } catch (ClassNotFoundException e) {
+                    throw new MojoExecutionException(e.getMessage(), e);
+                }
+            } catch (IllegalArgumentException e) {
+                throw new MojoExecutionException(e.getCause().getMessage(), e.getCause());
+            }
+        }
+        try {
+            final Method method = aClass.getMethod(name, argTypes);
+            // only include non-static public methods
+            int modifiers = method.getModifiers();
+            if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
+                return method.getReturnType().getCanonicalName();
+            } else {
+                return null;
+            }
+        } catch (NoSuchMethodException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+    }
+
+    private class JavadocParser extends Parser {
+        private String hrefPattern;
+
+        private ParserState parserState;
+        private String methodWithTypes;
+        private StringBuilder methodTextBuilder = new StringBuilder();
+
+        private List<String> methods = new ArrayList<String>();
+        private Map<String, String> methodText = new HashMap<String, String>();
+
+        public JavadocParser(DTD dtd, String docPath) {
+            super(dtd);
+            this.hrefPattern = docPath + "#";
+        }
+
+        @Override
+        protected void startTag(TagElement tag) throws ChangedCharSetException {
+            super.startTag(tag);
+
+            final HTML.Tag htmlTag = tag.getHTMLTag();
+            if (htmlTag != null) {
+                if (HTML.Tag.A.equals(htmlTag)) {
+                    final SimpleAttributeSet attributes = getAttributes();
+                    final Object name = attributes.getAttribute(HTML.Attribute.NAME);
+                    if (name != null) {
+                        final String nameAttr = (String) name;
+                        if (parserState == null && "method_summary".equals(nameAttr)) {
+                            parserState = ParserState.METHOD_SUMMARY;
+                        } else if (parserState == ParserState.METHOD_SUMMARY && nameAttr.startsWith("methods_inherited_from_class_")) {
+                            parserState = null;
+                        } else if (parserState == ParserState.METHOD && methodWithTypes == null) {
+                            final Object href = attributes.getAttribute(HTML.Attribute.HREF);
+                            if (href != null) {
+                                String hrefAttr = (String) href;
+                                if (hrefAttr.contains(hrefPattern)) {
+                                    methodWithTypes = hrefAttr.substring(hrefAttr.indexOf('#') + 1);
+                                }
+                            }
+                        }
+                    }
+                } else if (parserState == ParserState.METHOD_SUMMARY && HTML.Tag.CODE.equals(htmlTag)) {
+                    parserState = ParserState.METHOD;
+                }
+            }
+        }
+
+        @Override
+        protected void handleEmptyTag(TagElement tag) {
+            if (parserState == ParserState.METHOD && HTML.Tag.CODE.equals(tag.getHTMLTag())) {
+                if (methodWithTypes != null) {
+                    // process collected method data
+                    methods.add(methodWithTypes);
+                    this.methodText.put(methodWithTypes, getArgSignature());
+
+                    // clear the text builder for next method
+                    methodTextBuilder.delete(0, methodTextBuilder.length());
+                    methodWithTypes = null;
+                }
+
+                parserState = ParserState.METHOD_SUMMARY;
+            }
+        }
+
+        private String getArgSignature() {
+            final String typeString = methodWithTypes.substring(methodWithTypes.indexOf('(') + 1, methodWithTypes.indexOf(')'));
+            if (typeString.isEmpty()) {
+                return "()";
+            }
+            final String[] types = typeString.split(",");
+            String argText = methodTextBuilder.toString().replaceAll("&nbsp;", " ").replaceAll("&nbsp", " ");
+            final String[] args = argText.substring(argText.indexOf('(') + 1, argText.indexOf(')')).split(",");
+            StringBuilder builder = new StringBuilder("(");
+            for (int i = 0; i < types.length; i++) {
+                final String[] arg = args[i].trim().split(" ");
+                builder.append(types[i]).append(" ").append(arg[1].trim()).append(",");
+            }
+            builder.deleteCharAt(builder.length() - 1);
+            builder.append(")");
+            return builder.toString();
+        }
+
+        @Override
+        protected void handleText(char[] text) {
+            if (parserState == ParserState.METHOD && methodWithTypes != null) {
+                methodTextBuilder.append(text);
+            }
+        }
+
+        private List<String> getMethods() {
+            return methods;
+        }
+
+        private Map<String, String> getMethodText() {
+            return methodText;
+        }
+    }
+
+    private static enum ParserState {
+        METHOD_SUMMARY, METHOD;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
new file mode 100644
index 0000000..d16e041
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/Substitution.java
@@ -0,0 +1,80 @@
+/**
+ * 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;
+
+/**
+ * Argument name substitution for {@link FileApiMethodGeneratorMojo}.
+ */
+public class Substitution {
+
+    public String method;
+    private String argName;
+    private String argType;
+    private String replacement;
+    private boolean replaceWithType;
+
+    public Substitution() {
+    }
+
+    public Substitution(String method, String argName, String argType, String replacement, boolean replaceWithType) {
+        this.method = method;
+        this.argName = argName;
+        this.argType = argType;
+        this.replacement = replacement;
+        this.replaceWithType = replaceWithType;
+    }
+
+    public String getMethod() {
+        return method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public String getArgName() {
+        return argName;
+    }
+
+    public void setArgName(String argName) {
+        this.argName = argName;
+    }
+
+    public String getArgType() {
+        return argType;
+    }
+
+    public void setArgType(String argType) {
+        this.argType = argType;
+    }
+
+    public String getReplacement() {
+        return replacement;
+    }
+
+    public void setReplacement(String replacement) {
+        this.replacement = replacement;
+    }
+
+    public boolean isReplaceWithType() {
+        return replaceWithType;
+    }
+
+    public void setReplaceWithType(boolean replaceWithType) {
+        this.replaceWithType = replaceWithType;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-collection.vm
new file mode 100644
index 0000000..0774366
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-collection.vm
@@ -0,0 +1,76 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-collection.vm
+/*
+ * Camel ApiCollection generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import java.util.Map;
+import java.util.HashMap;
+
+#set( $componentConfig = "${componentName}Configuration" )
+import ${componentPackage}.${componentConfig};
+#foreach ( $api in $apis )
+import ${componentPackage}.${helper.getEndpointConfig($api.ProxyClass)};
+#end
+
+import org.apache.camel.util.component.ApiCollection;
+import org.apache.camel.util.component.ApiMethodHelper;
+
+/**
+ * Camel {@link ApiCollection} for $componentName
+ */
+public final class $collectionName extends ApiCollection<${apiNameEnum}, ${componentConfig}> {
+
+    private static $collectionName collection;
+
+    private ${collectionName}() {
+        final Map<String, String> aliases = new HashMap<String, String>();
+#foreach( $api in $apis )
+
+        aliases.clear();
+#foreach( $alias in $api.Aliases )
+        aliases.put("$alias.MethodPattern", "$alias.MethodAlias");
+#end
+#set( $apiMethod = ${helper.getApiMethod($api.ProxyClass)} )
+#set( $apiName = "${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}" )
+        apis.put($apiName, new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
+        apiMethods.put(${apiMethod}.class, ${apiName});
+#end
+    }
+
+    public $componentConfig getEndpointConfiguration(${apiNameEnum} apiName) {
+        $componentConfig result = null;
+        switch (apiName) {
+#foreach( $api in $apis )
+        case ${helper.getEnumConstant($api.ApiName)}:
+            result = new ${helper.getEndpointConfig($api.ProxyClass)}();
+            break;
+#end
+        }
+        return result;
+    }
+
+    public static synchronized $collectionName getCollection() {
+        if (collection == null) {
+            collection = new $collectionName();
+        }
+        return collection;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-endpoint-config.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-endpoint-config.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-endpoint-config.vm
new file mode 100644
index 0000000..f01d29e
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-endpoint-config.vm
@@ -0,0 +1,47 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-endpoint-config.vm
+/*
+ * Camel EndpointConfiguration generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package ${componentPackage};
+
+/**
+ * Camel EndpointConfiguration for $proxyType.Name
+ */
+@SuppressWarnings("unused")
+public final class $configName extends ${componentName}Configuration {
+
+#foreach( $parameter in $parameters.entrySet() )
+    private $helper.getCanonicalName($parameter.Value) $parameter.Key;
+#end
+## getters and setters
+#foreach( $parameter in $parameters.entrySet() )
+#set ( $name = $parameter.Key )
+#set ( $type = $helper.getCanonicalName($parameter.Value) )
+#set ( $suffix = $helper.getBeanPropertySuffix($name) )
+
+    public $type get${suffix}() {
+        return $name;
+    }
+
+    public void set${suffix}($type $name) {
+        this.$name = $name;
+    }
+#end
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm
new file mode 100644
index 0000000..0bc3056
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-method-enum.vm
@@ -0,0 +1,63 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-method-enum.vm
+/*
+ * Camel ApiMethod Enumeration generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import $proxyType.Name;
+
+import org.apache.camel.util.component.ApiMethod;
+import org.apache.camel.util.component.ApiMethodImpl;
+
+/**
+ * Camel {@link ApiMethod} Enumeration for $proxyType.Name
+ */
+@SuppressWarnings("unused")
+public enum $enumName implements ApiMethod {
+
+#foreach ( $model in $models )
+    ${model.UniqueName}($helper.getType($model.ResultType), "$model.Name"#foreach ( $arg in $model.Arguments ), $helper.getType($arg.Type), "$arg.Name"#end)#if ( $foreach.hasNext ),#else;#end
+
+#end
+
+    private final ApiMethod apiMethod;
+
+    private ${enumName}(Class<?> resultType, String name, Object... args) {
+        this.apiMethod = new ApiMethodImpl(${proxyType.SimpleName}.class, resultType, name, args);
+    }
+
+    @Override
+    public String getName() { return apiMethod.getName(); }
+
+    @Override
+    public Class<?> getResultType() { return apiMethod.getResultType(); }
+
+    @Override
+    public List<String> getArgNames() { return apiMethod.getArgNames(); }
+
+    @Override
+    public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); }
+
+    @Override
+    public Method getMethod() { return apiMethod.getMethod(); }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm
new file mode 100644
index 0000000..e0d558d
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-name-enum.vm
@@ -0,0 +1,56 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-name-enum.vm
+/*
+ * Camel ApiName Enumeration generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import org.apache.camel.util.component.ApiName;
+
+/**
+ * Camel {@link ApiName} Enumeration for Component $componentName
+ */
+public enum $apiNameEnum implements ApiName {
+
+#foreach ( $api in $apis )
+#set ( $apiName = $api.ApiName )
+    ${helper.getEnumConstant($apiName)}("$apiName")#if ( $foreach.hasNext ),#else;#end
+
+#end
+
+    private final String name;
+
+    private ${apiNameEnum}(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public static $apiNameEnum fromValue(String value) throws IllegalArgumentException {
+        for ($apiNameEnum api : ${apiNameEnum}.values()) {
+            if (api.name.equals(value)) {
+                return api;
+            }
+        }
+        throw new IllegalArgumentException("Invalid value " + value);
+    }
+}


[18/35] git commit: Added getApiNames() to ApiCollection, added more method modifiers to signature parsing

Posted by dh...@apache.org.
Added getApiNames() to ApiCollection, added more method modifiers to signature parsing


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

Branch: refs/heads/master
Commit: 24e196bc6f3af120e4495ce8f3d2c7bee391bb6c
Parents: 3d46cbf
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 30 11:14:46 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:32 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/camel/util/component/ApiCollection.java     | 5 +++++
 .../java/org/apache/camel/util/component/ApiMethodParser.java   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/24e196bc/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
index 585fbb2..6520d1c 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
@@ -16,8 +16,10 @@
  */
 package org.apache.camel.util.component;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Base class for a collection of ApiMethods. Meant to be extended by Components to create the api name map.
@@ -30,4 +32,7 @@ public abstract class ApiCollection {
         return apis.get(apiName);
     }
 
+    public final Set<String> getApiNames() {
+        return Collections.unmodifiableSet(apis.keySet());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/24e196bc/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
index 933a0b9..b7e6ef7 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -93,7 +93,7 @@ public abstract class ApiMethodParser<T> {
         List<ApiMethodModel> result = new ArrayList<ApiMethodModel>();
         for (String signature: signatures) {
             // remove all type parameters and modifiers
-            signature = signature.replaceAll("<[^>]*>|public|final", "");
+            signature = signature.replaceAll("<[^>]*>|\\s*(public|final|synchronized|native)\\s*", "");
             log.debug("Processing " + signature);
 
             final Matcher methodMatcher = METHOD_PATTERN.matcher(signature);


[30/35] git commit: Updated generated tests to get api name for test routes from ApiCollection, added java.awt.headless=true to Javadoc mojo

Posted by dh...@apache.org.
Updated generated tests to get api name for test routes from ApiCollection, added java.awt.headless=true to Javadoc mojo


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

Branch: refs/heads/master
Commit: 4e1254a7e2df28b2c659fc9028ee8d15cdbe5c30
Parents: 911e541
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 18:41:37 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:34 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/camel/util/component/ApiCollection.java   | 5 +++++
 .../apache/camel/maven/AbstractApiMethodGeneratorMojo.java    | 2 ++
 .../org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java | 5 +++++
 .../src/main/resources/api-collection.vm                      | 7 +++++--
 .../src/main/resources/api-route-test.vm                      | 7 +++++--
 5 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4e1254a7/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
index a1fd2b7..3d0fce8 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
@@ -29,6 +29,7 @@ import java.util.Set;
 public abstract class ApiCollection<T extends Enum & ApiName, C> {
 
     protected final Map<T, ApiMethodHelper> apis = new HashMap<T, ApiMethodHelper>();
+    protected final Map<Class<? extends ApiMethod>, T> apiMethods = new HashMap<Class<? extends ApiMethod>, T>();
 
     /**
      * Returns a {@link ApiMethodHelper} for a particular API.
@@ -51,6 +52,10 @@ public abstract class ApiCollection<T extends Enum & ApiName, C> {
         return Collections.unmodifiableSet(result);
     }
 
+    public final T getApiName(Class<? extends ApiMethod> apiMethod) {
+        return apiMethods.get(apiMethod);
+    }
+
     /**
      * Creates an endpoint configuration for a particular API
      * @param apiName name of the API.

http://git-wip-us.apache.org/repos/asf/camel/blob/4e1254a7/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
index de70464..445ceda 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
@@ -111,6 +111,8 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMo
         VelocityContext context = getCommonContext(models);
         context.put("testName", getUnitTestName());
         context.put("scheme", scheme);
+        context.put("componentName", componentName);
+        context.put("enumName", getEnumName());
         return context;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4e1254a7/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
index 7eea008..28bd958 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojo.java
@@ -49,6 +49,11 @@ import org.codehaus.plexus.util.IOUtil;
         defaultPhase = LifecyclePhase.GENERATE_SOURCES)
 public class JavadocApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
 
+    static {
+        // set Java AWT to headless before using Swing HTML parser
+        System.setProperty("java.awt.headless", "true");
+    }
+
     protected static final String DEFAULT_EXCLUDE_PACKAGES = "javax?\\.lang.*";
 
     @Parameter(property = "camel.component.util.excludePackages", defaultValue = DEFAULT_EXCLUDE_PACKAGES)

http://git-wip-us.apache.org/repos/asf/camel/blob/4e1254a7/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index e2c7eb4..868b958 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -43,12 +43,15 @@ public final class $collectionName extends ApiCollection<${apiNameEnum}, ${compo
     private ${collectionName}() {
         final Map<String, String> aliases = new HashMap<String, String>();
 #foreach( $api in $apis )
+
         aliases.clear();
 #foreach( $alias in $api.Aliases )
         aliases.put("$alias.MethodPattern", "$alias.MethodAlias");
 #end
-#set( $apiMethod = $helper.getApiMethod($api.ProxyClass) )
-        apis.put(${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}, new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
+#set( $apiMethod = "${helper.getApiMethod($api.ProxyClass)}.class" )
+#set( $apiName = "${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}" )
+        apis.put($apiName, new ApiMethodHelper<$apiMethod>(${apiMethod}, aliases));
+        apiMethods.put(${apiMethod}, ${apiName});
 #end
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/4e1254a7/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
index f61ecc5..e53331f 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
@@ -32,11 +32,13 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Test class for $proxyType.Name APIs.
- * TODO Copy the file to src/test/java, populate parameter values, and remove @Ignore annotations.
+ * TODO Move the file to src/test/java, populate parameter values, and remove @Ignore annotations.
+ * The class source won't be generated again if the generator MOJO finds it under src/test/java.
  */
 public class ${testName} extends CamelTestSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(${testName}.class);
+    private static final String PATH_PREFIX = ${componentName}ApiCollection.getCollection().getApiName(${enumName}.class).getName();
 
 #foreach ( $model in $models )
 #set ( $testName = $helper.getTestName($model) )
@@ -89,9 +91,10 @@ template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
         return new RouteBuilder() {
             public void configure() {
 #foreach ( $model in $models )
+#set ( $args = $model.Arguments )
                 // test route for $model.Name
                 from("direct://${model.UniqueName}")
-                  .to("${scheme}://${model.Name}");
+                  .to("${scheme}://" + PATH_PREFIX + "${model.Name}#if ( $args.size() == 1 )?inBody=${args.get(0).Name}#end");
 
 #end
             }


[13/35] git commit: Converted generated ApiCollection class to singleton

Posted by dh...@apache.org.
Converted generated ApiCollection class to singleton


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

Branch: refs/heads/master
Commit: ee191eb061dddb6504889d42a1f14a7e5e2d2ad3
Parents: 32677ff
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:21:05 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../src/main/resources/api-collection.vm               | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ee191eb0/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index 26382db..a82c2c5 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -30,9 +30,11 @@ import org.apache.camel.util.component.ApiMethodHelper;
 /**
  * Camel {@link ApiCollection} for $componentName
  */
-public class $collectionName extends ApiCollection {
+public final class $collectionName extends ApiCollection {
 
-    public ${collectionName}() {
+    private static $collectionName collection;
+
+    private ${collectionName}() {
         final Map<String, String> aliases = new HashMap<String, String>();
 #foreach( $api in $apis )
         aliases.clear();
@@ -43,4 +45,11 @@ public class $collectionName extends ApiCollection {
         apis.put("$api.ApiName", new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
 #end
     }
+
+    public static final synchronized $collectionName getCollection() {
+        if (collection == null) {
+            collection = new $collectionName();
+        }
+        return collection;
+    }
 }


[10/35] git commit: Removed author name

Posted by dh...@apache.org.
Removed author name


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

Branch: refs/heads/master
Commit: 0f67b18d89a5566f6ca7cd3cc4752d5007a27ceb
Parents: e47e53c
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:24:51 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/camel/maven/AbstractGeneratorMojoTest.java   | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0f67b18d/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
index 07edb41..0e781d8 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
@@ -21,9 +21,7 @@ import java.io.File;
 import static org.junit.Assert.assertTrue;
 
 /**
- * User: dbokde
- * Date: 5/26/14
- * Time: 4:49 AM
+ * Base class for Generator MOJO tests.
  */
 public class AbstractGeneratorMojoTest {
     protected static final String OUT_DIR = "target/generated-test-sources/camelComponent";


[33/35] Renamed component-util plugin to api-component

Posted by dh...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
new file mode 100644
index 0000000..a3acad1
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-route-test.vm
@@ -0,0 +1,109 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-route-test.vm
+/*
+ * Camel Api Route test generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import java.util.HashMap;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test class for $proxyType.Name APIs.
+ * TODO Move the file to src/test/java, populate parameter values, and remove @Ignore annotations.
+ * The class source won't be generated again if the generator MOJO finds it under src/test/java.
+ */
+public class ${testName} extends CamelTestSupport {
+
+    private static final Logger LOG = LoggerFactory.getLogger(${testName}.class);
+    private static final String PATH_PREFIX = ${componentName}ApiCollection.getCollection().getApiName(${enumName}.class).getName();
+
+#foreach ( $model in $models )
+#set ( $testName = $helper.getTestName($model) )
+#set ( $args = $model.Arguments )
+#set ( $resultType = $model.ResultType )
+#set ( $voidResult = $helper.isVoidType($resultType) )
+## are parameter values needed
+#if ( !$args.isEmpty() )
+    // TODO provide parameter values for $model.Name
+#end
+    @Ignore
+    @Test
+    public void test${testName}() throws Exception {
+## single argument, use as body
+#if ( $args.size() == 1 )
+#set ( $argType = $args.get(0).Type )
+        // using $helper.getCanonicalName($argType) message body for single parameter "$args.get(0).Name"
+## multiple arguments, pass them as headers
+#elseif ( $args.size() > 1 )
+        final HashMap<String, Object> headers = new HashMap<String, Object>();
+#foreach ( $arg in $args )
+#if ( !$arg.Type.isPrimitive() )
+        // parameter type is $helper.getCanonicalName($arg.Type)
+        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", null);
+#else
+        headers.put("${helper.getExchangePropertyPrefix()}${arg.Name}", $helper.getDefaultArgValue($arg.Type));
+#end
+#end
+#end
+## method invocation result
+        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) )$type result = (${type})#end
+## actual template call
+#if ( $args.isEmpty() )
+template().requestBody("direct://${model.UniqueName}", (Object)null);
+#elseif ( $args.size() == 1 )
+## typecast body to avoid requestBody() conflict
+template().requestBody("direct://${model.UniqueName}", (${helper.getCanonicalName($argType)}) $helper.getDefaultArgValue($argType));
+#else
+template().requestBodyAndHeader("direct://${model.UniqueName}", null, headers);
+#end
+#if ( !$voidResult )
+
+        LOG.debug("${model.Name} :" + result);
+#end
+    }
+
+#end
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+#foreach ( $model in $models )
+#set ( $args = $model.Arguments )
+                // test route for $model.Name
+                from("direct://${model.UniqueName}")
+                  .to("${scheme}://" + PATH_PREFIX + "/${model.Name}#if ( $args.size() == 1 )?inBody=${args.get(0).Name}#end");
+
+#end
+            }
+        };
+    }
+
+    @Override
+    public boolean isCreateCamelContextPerClass() {
+        // only create the context once for this class
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/log4j.properties b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/log4j.properties
new file mode 100644
index 0000000..3d544fc
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/log4j.properties
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
+
+#log4j.logger.org.apache.camel.maven=DEBUG
+#log4j.logger.org.apache.http=DEBUG
+#log4j.logger.org.apache.camel.util.component=TRACE

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
new file mode 100644
index 0000000..de22f82
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestConfiguration.java
@@ -0,0 +1,23 @@
+/**
+ * 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.component.test;
+
+/**
+ * Dummy component configuration.
+ */
+public class TestConfiguration {
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
new file mode 100644
index 0000000..48eb11b
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/component/test/TestProxy.java
@@ -0,0 +1,68 @@
+/**
+ * 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.component.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestProxy {
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String sayHi(boolean hello) {
+        return hello ? "Hello!" : "Hi!";
+    }
+
+    public String sayHi(final String name) {
+        return "Hello " + name;
+    }
+
+    public final String greetMe(final String name) {
+        return "Greetings " + name;
+    }
+
+    public final String greetUs(final String name1, String name2) {
+        return "Greetings " + name1 + ", " + name2;
+    }
+
+    public final String greetAll(final String[] names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String greetAll(List<String> names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String[] greetTimes(String name, int times) {
+        final List<String> result = new ArrayList<String>();
+        for (int i = 0; i < times; i++) {
+            result.add("Greetings " + name);
+        }
+        return result.toArray(new String[result.size()]);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
new file mode 100644
index 0000000..641b34e
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/AbstractGeneratorMojoTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.util.Collections;
+import java.util.List;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.MavenProject;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Base class for Generator MOJO tests.
+ */
+public class AbstractGeneratorMojoTest {
+    protected static final String OUT_DIR = "target/generated-test-sources/camel-component";
+
+    private static final String COMPONENT_PACKAGE = "org.apache.camel.component.test";
+    private static final String OUT_PACKAGE = COMPONENT_PACKAGE + ".internal";
+
+    protected static final String PACKAGE_PATH = OUT_PACKAGE.replaceAll("\\.", "/") + "/";
+    protected static final String COMPONENT_PACKAGE_PATH = COMPONENT_PACKAGE.replaceAll("\\.", "/") + "/";
+
+    protected static final String COMPONENT_NAME = "Test";
+    protected static final String SCHEME = "testComponent";
+
+    protected void assertExists(File outFile) {
+        assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
+    }
+
+    protected void configureMojo(AbstractGeneratorMojo mojo) {
+        mojo.componentName = COMPONENT_NAME;
+        mojo.scheme = SCHEME;
+        mojo.generatedSrcDir = new File(OUT_DIR);
+        mojo.generatedTestDir = new File(OUT_DIR);
+        mojo.outPackage = OUT_PACKAGE;
+        mojo.componentPackage = COMPONENT_PACKAGE;
+        mojo.project = new MavenProject((Model) null) {
+            @Override
+            public List getTestClasspathElements() throws DependencyResolutionRequiredException {
+                return Collections.EMPTY_LIST;
+            }
+
+            @Override
+            public Build getBuild() {
+                return new Build() {
+                    @Override
+                    public String getTestSourceDirectory() {
+                        return OUT_DIR;
+                    }
+                };
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
new file mode 100644
index 0000000..3e9400c
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/ApiComponentGeneratorMojoTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.component.test.TestProxy;
+import org.apache.velocity.VelocityContext;
+import org.junit.Test;
+
+/**
+ * Tests {@link ApiComponentGeneratorMojo}
+ */
+public class ApiComponentGeneratorMojoTest extends AbstractGeneratorMojoTest {
+
+    @Test
+    public void testExecute() throws Exception {
+
+        final File collectionFile = new File(OUT_DIR, PACKAGE_PATH + COMPONENT_NAME + "ApiCollection.java");
+
+        // delete target files to begin
+        collectionFile.delete();
+
+        final ApiComponentGeneratorMojo mojo = new ApiComponentGeneratorMojo();
+        configureMojo(mojo);
+
+        mojo.apis = new ApiProxy[2];
+        mojo.apis[0] = new ApiProxy("test", TestProxy.class.getName());
+        List<ApiMethodAlias> aliases = new ArrayList<ApiMethodAlias>();
+        aliases.add(new ApiMethodAlias("get(.+)", "$1"));
+        aliases.add(new ApiMethodAlias("set(.+)", "$1"));
+        mojo.apis[1] = new ApiProxy("velocity", VelocityContext.class.getName(), aliases);
+
+        mojo.execute();
+
+        // check target file was generated
+        assertExists(collectionFile);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
new file mode 100644
index 0000000..d77bad7
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/FileApiMethodGeneratorMojoTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.IOException;
+
+import org.apache.camel.component.test.TestProxy;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests {@link FileApiMethodGeneratorMojo}
+ */
+public class FileApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
+
+    @Test
+    public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
+
+        // delete target file to begin
+        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "TestProxyApiMethod.java");
+        if (outFile.exists()) {
+            outFile.delete();
+        }
+
+        final FileApiMethodGeneratorMojo mojo = new FileApiMethodGeneratorMojo();
+        mojo.substitutions = new Substitution[2];
+        mojo.substitutions[0] = new Substitution(".+", "(.+)", "java.util.List", "$1List", false);
+        mojo.substitutions[1] = new Substitution(".+", "(.+)", ".*?(\\w++)\\[\\]", "$1Array", true);
+
+        configureMojo(mojo);
+        mojo.proxyClass = TestProxy.class.getCanonicalName();
+        mojo.signatureFile = new File("src/test/resources/test-proxy-signatures.txt");
+
+        mojo.execute();
+
+        // check target file was generated
+        assertTrue("Generated file not found " + outFile.getPath(), outFile.exists());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
new file mode 100644
index 0000000..ded66dd
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/JavadocApiMethodGeneratorMojoTest.java
@@ -0,0 +1,58 @@
+/**
+ * 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.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.velocity.VelocityContext;
+import org.junit.Test;
+
+/**
+ * Tests {@link JavadocApiMethodGeneratorMojo}
+ */
+public class JavadocApiMethodGeneratorMojoTest extends AbstractGeneratorMojoTest {
+
+    @Test
+    public void testExecute() throws IOException, MojoFailureException, MojoExecutionException {
+
+        // delete target file to begin
+        final File outFile = new File(OUT_DIR, PACKAGE_PATH + "VelocityContextApiMethod.java");
+        if (outFile.exists()) {
+            outFile.delete();
+        }
+
+        final JavadocApiMethodGeneratorMojo mojo = new JavadocApiMethodGeneratorMojo();
+
+        configureMojo(mojo);
+
+        // use VelocityEngine javadoc
+        mojo.proxyClass = VelocityContext.class.getCanonicalName();
+        Substitution substitution = new Substitution(".*", "key", "java.lang.Object", "applicationKey", false);
+        mojo.substitutions = new Substitution[]{ substitution };
+        mojo.excludePackages = JavadocApiMethodGeneratorMojo.DEFAULT_EXCLUDE_PACKAGES;
+        mojo.excludeMethods = "clone|Current|internal|icache";
+
+        mojo.execute();
+
+        // check target file was generated
+        assertExists(outFile);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-api-component-maven-plugin/src/test/resources/test-proxy-signatures.txt
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/resources/test-proxy-signatures.txt b/tooling/maven/camel-api-component-maven-plugin/src/test/resources/test-proxy-signatures.txt
new file mode 100644
index 0000000..4c47474
--- /dev/null
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/resources/test-proxy-signatures.txt
@@ -0,0 +1,8 @@
+public String sayHi();
+public String sayHi(boolean hello);
+public String sayHi(final String name);
+public final String greetMe(final String name);
+public final String greetUs(final String name1, String name2);
+public final String greetAll(String[] names);
+public final String greetAll(java.util.List<String> names);
+public final String[] greetTimes(String name, int times);

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/pom.xml b/tooling/maven/camel-component-util-maven-plugin/pom.xml
deleted file mode 100644
index ed197ac..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/pom.xml
+++ /dev/null
@@ -1,225 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.camel</groupId>
-    <artifactId>maven-plugins</artifactId>
-    <version>2.14-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>camel-component-util-maven-plugin</artifactId>
-  <packaging>maven-plugin</packaging>
-  <name>Camel :: Maven Plugins :: Camel Component Utilities</name>
-  <description>Maven plugin to generate Camel Components for APIs</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.plugin-tools</groupId>
-      <artifactId>maven-plugin-annotations</artifactId>
-      <version>3.3</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-descriptor</artifactId>
-      <version>2.2.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
-      <version>2.2.1</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>${velocity-version}</version>
-    </dependency>
-
-    <!-- add some logging to the classpath -->
-    <dependency>
-      <groupId>log4j</groupId>
-      <artifactId>log4j</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <!-- VelocityEngine javadoc for testing -->
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>${velocity-version}</version>
-      <classifier>javadoc</classifier>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <pluginManagement>
-      <plugins>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-plugin-plugin</artifactId>
-          <version>3.3</version>
-          <configuration>
-            <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
-            <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
-          </configuration>
-          <executions>
-            <execution>
-              <id>mojo-descriptor</id>
-              <goals>
-                  <goal>descriptor</goal>
-              </goals>
-            </execution>
-            <execution>
-              <id>help-goal</id>
-              <goals>
-                  <goal>helpmojo</goal>
-              </goals>
-            </execution>
-          </executions>
-          </plugin>
-      </plugins>
-    </pluginManagement>
-    <plugins>
-      <!-- copy test utility classes to integration test project -->
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-resources-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>copy-it-resources</id>
-            <phase>generate-test-sources</phase>
-            <goals>
-              <goal>copy-resources</goal>
-            </goals>
-            <configuration>
-              <encoding>UTF-8</encoding>
-              <overwrite>true</overwrite>
-              <outputDirectory>${project.build.directory}/it/all-it/src/main/java/org/apache/camel/component/test</outputDirectory>
-              <resources>
-                <resource>
-                  <directory>src/test/java/org/apache/camel/component/test</directory>
-                </resource>
-              </resources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <!-- validate generated code after unit tests -->
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>add-generated-test-sources</id>
-            <phase>verify</phase>
-            <goals>
-              <goal>add-test-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-test-sources/camel-component</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>validate-generated-test-sources</id>
-            <phase>verify</phase>
-            <goals>
-              <goal>testCompile</goal>
-            </goals>
-            <configuration>
-              <fork>false</fork>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-  <!-- Plugin integration test profile -->
-  <profiles>
-    <profile>
-      <id>plugin-itest</id>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-invoker-plugin</artifactId>
-            <version>1.8</version>
-            <configuration>
-              <debug>true</debug>
-              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
-              <pomIncludes>
-                <pomInclude>*/pom.xml</pomInclude>
-              </pomIncludes>
-              <postBuildHookScript>verify</postBuildHookScript>
-              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
-              <settingsFile>src/it/settings.xml</settingsFile>
-              <goals>
-                <goal>clean</goal>
-                <goal>verify</goal>
-              </goals>
-            </configuration>
-            <executions>
-              <execution>
-                <id>integration-test</id>
-                <goals>
-                  <goal>install</goal>
-                  <goal>integration-test</goal>
-                  <goal>verify</goal>
-                </goals>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-
-      </build>
-    </profile>
-  </profiles>
-</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
deleted file mode 100644
index d13ef72..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
+++ /dev/null
@@ -1,185 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ 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.
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <groupId>org.apache.camel</groupId>
-  <artifactId>camel-component-util-maven-plugin-it</artifactId>
-  <version>1.0-SNAPSHOT</version>
-
-  <description>Integration Test to verify all goals.</description>
-
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <outPackage>org.apache.camel.component.test.internal</outPackage>
-    <componentPackage>org.apache.camel.component.test</componentPackage>
-    <scheme>testComponent</scheme>
-    <componentName>Test</componentName>
-  </properties>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-      <version>@project.version@</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity-version@</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-test</artifactId>
-      <version>@project.version@</version>
-      <scope>test</scope>
-    </dependency>
-    <!-- VelocityEngine javadoc for testing -->
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity</artifactId>
-      <version>@velocity-version@</version>
-      <classifier>javadoc</classifier>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <!-- execute component-util plugin -->
-      <plugin>
-        <groupId>@project.groupId@</groupId>
-        <artifactId>@project.artifactId@</artifactId>
-        <version>@project.version@</version>
-        <executions>
-          <execution>
-            <id>generate-file-api-method</id>
-            <!-- using generate-test-sources instead of generate-sources to be able to load TestProxy.class -->
-            <phase>generate-test-sources</phase>
-            <goals>
-              <goal>fromFile</goal>
-            </goals>
-            <configuration>
-              <outPackage>${outPackage}</outPackage>
-              <componentPackage>${componentPackage}</componentPackage>
-              <scheme>${scheme}</scheme>
-              <componentName>${componentName}</componentName>
-              <proxyClass>org.apache.camel.component.test.TestProxy</proxyClass>
-              <substitutions>
-                <substitution>
-                  <method>.+</method>
-                  <argName>(.+)</argName>
-                  <argType>java.util.List</argType>
-                  <replacement>$1List</replacement>
-                </substitution>
-                <substitution>
-                  <method>.+</method>
-                  <argName>(.+)</argName>
-                  <argType>.*?(\w++)\[\]</argType>
-                  <replacement>$1Array</replacement>
-                  <replaceWithType>true</replaceWithType>
-                </substitution>
-              </substitutions>
-              <signatureFile>../../../src/test/resources/test-proxy-signatures.txt</signatureFile>
-            </configuration>
-          </execution>
-          <execution>
-            <id>generate-velocity-context-api-method</id>
-            <phase>generate-test-sources</phase>
-            <goals>
-              <goal>fromJavadoc</goal>
-            </goals>
-            <configuration>
-              <outPackage>${outPackage}</outPackage>
-              <componentPackage>${componentPackage}</componentPackage>
-              <scheme>${scheme}</scheme>
-              <componentName>${componentName}</componentName>
-              <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
-              <substitutions>
-                <substitution>
-                  <method>.+</method>
-                  <argName>key</argName>
-                  <argType>java.lang.Object</argType>
-                  <replacement>applicationKey</replacement>
-                </substitution>
-              </substitutions>
-              <excludeClasses>InternalContextBase</excludeClasses>
-              <excludeMethods>clone|Current|internal|icache</excludeMethods>
-            </configuration>
-          </execution>
-          <execution>
-            <id>generate-test-component-classes</id>
-            <phase>generate-test-sources</phase>
-            <goals>
-              <goal>fromApis</goal>
-            </goals>
-            <configuration>
-              <outPackage>${outPackage}</outPackage>
-              <componentPackage>${componentPackage}</componentPackage>
-              <scheme>${scheme}</scheme>
-              <componentName>${componentName}</componentName>
-              <apis>
-                <api>
-                  <apiName>test</apiName>
-                  <proxyClass>org.apache.camel.component.test.TestProxy</proxyClass>
-                </api>
-                <api>
-                  <apiName>velocity</apiName>
-                  <proxyClass>org.apache.velocity.VelocityContext</proxyClass>
-                  <aliases>
-                    <alias>
-                      <methodPattern>get(.+)</methodPattern>
-                      <methodAlias>$1</methodAlias>
-                    </alias>
-                    <alias>
-                      <methodPattern>set(.+)</methodPattern>
-                      <methodAlias>$1</methodAlias>
-                    </alias>
-                  </aliases>
-                </api>
-              </apis>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <!-- add generated source and test source to build for test-compile -->
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>build-helper-maven-plugin</artifactId>
-        <version>@build-helper-maven-plugin-version@</version>
-        <executions>
-          <execution>
-            <id>add-generated-test-sources</id>
-            <goals>
-              <goal>add-test-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources/camel-component</source>
-                <source>${project.build.directory}/generated-test-sources/camel-component</source>
-              </sources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-
-</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy
deleted file mode 100644
index 73edefd..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/verify.groovy
+++ /dev/null
@@ -1,22 +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.
- */
-// assert that the generated files directory exists
-File sourceDir = new File( basedir, "target/generated-sources/camel-component" );
-File testDir = new File( basedir, "target/generated-test-sources/camel-component" );
-
-assert sourceDir.isDirectory()
-assert testDir.isDirectory()

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml
deleted file mode 100644
index c8f77f0..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/it/settings.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-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.
--->
-
-<settings>
-  <profiles>
-    <profile>
-      <id>it-repo</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-      </activation>
-      <repositories>
-        <repository>
-          <id>local.central</id>
-          <url>@localRepositoryUrl@</url>
-          <releases>
-            <enabled>true</enabled>
-          </releases>
-          <snapshots>
-            <enabled>true</enabled>
-          </snapshots>
-        </repository>
-      </repositories>
-      <pluginRepositories>
-        <pluginRepository>
-          <id>local.central</id>
-          <url>@localRepositoryUrl@</url>
-          <releases>
-            <enabled>true</enabled>
-          </releases>
-          <snapshots>
-            <enabled>true</enabled>
-          </snapshots>
-        </pluginRepository>
-      </pluginRepositories>
-    </profile>
-  </profiles>
-</settings>

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
deleted file mode 100644
index 852b09e..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java
+++ /dev/null
@@ -1,265 +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.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.camel.util.component.ApiMethodParser;
-import org.apache.camel.util.component.ArgumentSubstitutionParser;
-import org.apache.commons.lang.ClassUtils;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.velocity.VelocityContext;
-
-/**
- * Base Mojo class for ApiMethod generators.
- */
-public abstract class AbstractApiMethodGeneratorMojo extends AbstractGeneratorMojo {
-
-    @Parameter(required = true, property = PREFIX + "proxyClass")
-    protected String proxyClass;
-
-    @Parameter(property = PREFIX + "substitutions")
-    protected Substitution[] substitutions = new Substitution[0];
-
-    // cached fields
-    private Class<?> proxyType;
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-
-        // load proxy class and get enumeration file to generate
-        final Class proxyType = getProxyType();
-
-        // create parser
-        ApiMethodParser parser = createAdapterParser(proxyType);
-        parser.setSignatures(getSignatureList());
-        parser.setClassLoader(getProjectClassLoader());
-
-        // parse signatures
-        final List<ApiMethodParser.ApiMethodModel> models = parser.parse();
-
-        // generate enumeration from model
-        mergeTemplate(getApiMethodContext(models), getApiMethodFile(), "/api-method-enum.vm");
-
-        // generate EndpointConfiguration for this Api
-        mergeTemplate(getEndpointContext(models), getConfigurationFile(), "/api-endpoint-config.vm");
-
-        // generate junit test if it doesn't already exist under test source directory
-        // i.e. it may have been generated then moved there and populated with test values
-        final String testFilePath = getTestFilePath();
-        if (!new File(project.getBuild().getTestSourceDirectory(), testFilePath).exists()) {
-            mergeTemplate(getApiTestContext(models), new File(generatedTestDir, testFilePath), "/api-route-test.vm");
-        }
-    }
-
-    protected ApiMethodParser createAdapterParser(Class proxyType) {
-        return new ArgumentSubstitutionParser(proxyType, getArgumentSubstitutions()){};
-    }
-
-    public abstract List<String> getSignatureList() throws MojoExecutionException;
-
-    public Class getProxyType() throws MojoExecutionException {
-        if (proxyType == null) {
-            // load proxy class from Project runtime dependencies
-            try {
-                proxyType = getProjectClassLoader().loadClass(proxyClass);
-            } catch (ClassNotFoundException e) {
-                throw new MojoExecutionException(e.getMessage(), e);
-            }
-        }
-        return proxyType;
-    }
-
-    private VelocityContext getApiMethodContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
-        VelocityContext context = getCommonContext(models);
-        context.put("enumName", getEnumName());
-        return context;
-    }
-
-    public File getApiMethodFile() throws MojoExecutionException {
-        final StringBuilder fileName = new StringBuilder();
-        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
-        fileName.append(getEnumName()).append(".java");
-        return new File(generatedSrcDir, fileName.toString());
-    }
-
-    private String getEnumName() throws MojoExecutionException {
-        return getProxyType().getSimpleName() + "ApiMethod";
-    }
-
-    private VelocityContext getApiTestContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
-        VelocityContext context = getCommonContext(models);
-        context.put("testName", getUnitTestName());
-        context.put("scheme", scheme);
-        context.put("componentName", componentName);
-        context.put("enumName", getEnumName());
-        return context;
-    }
-
-    private String getTestFilePath() throws MojoExecutionException {
-        final StringBuilder fileName = new StringBuilder();
-        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
-        fileName.append(getUnitTestName()).append(".java");
-        return fileName.toString();
-    }
-
-    private String getUnitTestName() throws MojoExecutionException {
-        return getProxyType().getSimpleName() + "IntegrationTest";
-    }
-
-    private VelocityContext getEndpointContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
-        VelocityContext context = getCommonContext(models);
-        context.put("configName", getConfigName());
-        context.put("componentName", componentName);
-        context.put("componentPackage", componentPackage);
-
-        // generate parameter names and types for configuration, sorted by parameter name
-        Map<String, Class<?>> parameters = new TreeMap<String, Class<?>>();
-        for (ApiMethodParser.ApiMethodModel model : models) {
-            for (ApiMethodParser.Argument argument : model.getArguments()) {
-                if (!parameters.containsKey(argument.getName())) {
-                    Class<?> type = argument.getType();
-                    if (type.isPrimitive()) {
-                        // replace primitives with wrapper classes
-                        type = ClassUtils.primitiveToWrapper(type);
-                    }
-                    parameters.put(argument.getName(), type);
-                }
-            }
-        }
-        context.put("parameters", parameters);
-        return context;
-    }
-
-    private File getConfigurationFile() throws MojoExecutionException {
-        final StringBuilder fileName = new StringBuilder();
-        // endpoint configuration goes in component package
-        fileName.append(componentPackage.replaceAll("\\.", File.separator)).append(File.separator);
-        fileName.append(getConfigName()).append(".java");
-        return new File(generatedSrcDir, fileName.toString());
-    }
-
-    private String getConfigName() throws MojoExecutionException {
-        return getProxyType().getSimpleName() + "EndpointConfiguration";
-    }
-
-    private VelocityContext getCommonContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
-        VelocityContext context = new VelocityContext();
-        context.put("models", models);
-        context.put("proxyType", getProxyType());
-        context.put("helper", this);
-        return context;
-    }
-
-    public ArgumentSubstitutionParser.Substitution[] getArgumentSubstitutions() {
-        ArgumentSubstitutionParser.Substitution[] subs = new ArgumentSubstitutionParser.Substitution[substitutions.length];
-        for (int i = 0; i < substitutions.length; i++) {
-            final Substitution substitution = substitutions[i];
-            subs[i] = new ArgumentSubstitutionParser.Substitution(substitution.getMethod(),
-                    substitution.getArgName(), substitution.getArgType(),
-                    substitution.getReplacement(), substitution.isReplaceWithType());
-        }
-        return subs;
-    }
-
-    public static String getType(Class<?> clazz) {
-        if (clazz.isArray()) {
-            // create a zero length array and get the class from the instance
-            return "new " + getCanonicalName(clazz).replaceAll("\\[\\]", "[0]") + ".getClass()";
-        } else {
-            return getCanonicalName(clazz) + ".class";
-        }
-    }
-
-    public static String getTestName(ApiMethodParser.ApiMethodModel model) {
-        final StringBuilder builder = new StringBuilder();
-        final String name = model.getMethod().getName();
-        builder.append(Character.toUpperCase(name.charAt(0)));
-        builder.append(name.substring(1));
-        // find overloaded method suffix from unique name
-        final String uniqueName = model.getUniqueName();
-        if (uniqueName.length() > name.length()) {
-            builder.append(uniqueName.substring(name.length()));
-        }
-        return builder.toString();
-    }
-
-    public static boolean isVoidType(Class<?> resultType) {
-        return resultType == Void.TYPE;
-    }
-
-    public String getExchangePropertyPrefix() {
-        // exchange property prefix
-        return "Camel" + componentName + ".";
-    }
-
-    public static String getResultDeclaration(Class<?> resultType) {
-        if (resultType.isPrimitive()) {
-            return ClassUtils.primitiveToWrapper(resultType).getSimpleName();
-        } else {
-            return getCanonicalName(resultType);
-        }
-    }
-
-    private static final Map<Class<?>, String> PRIMITIVE_VALUES;
-
-    static {
-        PRIMITIVE_VALUES = new HashMap<Class<?>, String>();
-        PRIMITIVE_VALUES.put(Boolean.TYPE, "Boolean.FALSE");
-        PRIMITIVE_VALUES.put(Byte.TYPE, "(byte) 0");
-        PRIMITIVE_VALUES.put(Character.TYPE, "(char) 0");
-        PRIMITIVE_VALUES.put(Short.TYPE, "(short) 0");
-        PRIMITIVE_VALUES.put(Integer.TYPE, "0");
-        PRIMITIVE_VALUES.put(Long.TYPE, "0L");
-        PRIMITIVE_VALUES.put(Float.TYPE, "0.0f");
-        PRIMITIVE_VALUES.put(Double.TYPE, "0.0d");
-    }
-
-    public static String getDefaultArgValue(Class<?> aClass) {
-        if (aClass.isPrimitive()) {
-            // lookup default primitive value string
-            return PRIMITIVE_VALUES.get(aClass);
-        } else {
-            // return type cast null string
-            return "null";
-        }
-    }
-
-    public static String getBeanPropertySuffix(String parameter) {
-        // capitalize first character
-        StringBuilder builder = new StringBuilder();
-        builder.append(Character.toUpperCase(parameter.charAt(0)));
-        builder.append(parameter.substring(1));
-        return builder.toString();
-    }
-
-    public static String getCanonicalName(Class<?> type) {
-        // remove java.lang prefix for default Java package
-        String canonicalName = type.getCanonicalName();
-        final int pkgEnd = canonicalName.lastIndexOf('.');
-        if (pkgEnd > 0 && canonicalName.substring(0, pkgEnd).equals("java.lang")) {
-            canonicalName = canonicalName.substring(pkgEnd + 1);
-        }
-        return canonicalName;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
deleted file mode 100644
index faf0964..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/AbstractGeneratorMojo.java
+++ /dev/null
@@ -1,167 +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.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.VelocityException;
-import org.apache.velocity.runtime.RuntimeConstants;
-import org.apache.velocity.runtime.log.Log4JLogChute;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-
-/**
- * Base class for Api based code generation MOJOs.
- */
-public abstract class AbstractGeneratorMojo extends AbstractMojo {
-
-    protected static final String PREFIX = "org.apache.camel.";
-    protected static final String OUT_PACKAGE = PREFIX + "component.internal";
-    protected static final String COMPONENT_PACKAGE = PREFIX + "component";
-    private static final String LOGGER_PREFIX = "log4j.logger";
-
-    // used for velocity logging, to avoid creating velocity.log
-    protected final Logger LOG = Logger.getLogger(this.getClass());
-
-    @Parameter(defaultValue = "${project.build.directory}/generated-sources/camel-component")
-    protected File generatedSrcDir;
-
-    @Parameter(defaultValue = "${project.build.directory}/generated-test-sources/camel-component")
-    protected File generatedTestDir;
-
-    @Parameter(defaultValue = OUT_PACKAGE)
-    protected String outPackage;
-
-    @Parameter(required = true, property = PREFIX + "scheme")
-    protected String scheme;
-
-    @Parameter(required = true, property = PREFIX + "componentName")
-    protected String componentName;
-
-    @Parameter(defaultValue = COMPONENT_PACKAGE)
-    protected String componentPackage;
-
-    @Parameter(defaultValue = "${project}", readonly = true)
-    MavenProject project;
-
-    private VelocityEngine engine;
-    private ClassLoader projectClassLoader;
-
-    protected AbstractGeneratorMojo() {
-        // configure Log4J from system properties
-        for (String propertyName : System.getProperties().stringPropertyNames())
-        {
-            if (propertyName.startsWith(LOGGER_PREFIX)) {
-                String loggerName = propertyName.substring(LOGGER_PREFIX.length());
-                String levelName = System.getProperty(propertyName, "");
-                Level level = Level.toLevel(levelName); // defaults to DEBUG
-                if (!"".equals(levelName) && !levelName.toUpperCase().equals(level.toString())) {
-                    LOG.warn("Skipping unrecognized log4j log level " + levelName + ": -D" + propertyName + "=" + levelName);
-                    continue;
-                }
-                LOG.debug("Setting " + loggerName + " => " + level.toString());
-                Logger.getLogger(loggerName).setLevel(level);
-            }
-        }
-    }
-
-    public VelocityEngine getEngine() {
-        if (engine == null) {
-            // initialize velocity to load resources from class loader and use Log4J
-            Properties velocityProperties = new Properties();
-            velocityProperties.setProperty(RuntimeConstants.RESOURCE_LOADER, "cloader");
-            velocityProperties.setProperty("cloader.resource.loader.class", ClasspathResourceLoader.class.getName());
-            velocityProperties.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
-            velocityProperties.setProperty(Log4JLogChute.RUNTIME_LOG_LOG4J_LOGGER, LOG.getName());
-            engine = new VelocityEngine(velocityProperties);
-            engine.init();
-        }
-        return engine;
-    }
-
-    protected ClassLoader getProjectClassLoader() throws MojoExecutionException {
-        if (projectClassLoader == null)  {
-            final List classpathElements;
-            try {
-                classpathElements = project.getTestClasspathElements();
-            } catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
-                throw new MojoExecutionException(e.getMessage(), e);
-            }
-            final URL[] urls = new URL[classpathElements.size()];
-            int i = 0;
-            for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
-                try {
-                    urls[i] = new File((String) it.next()).toURI().toURL();
-                    LOG.debug("Adding project path " + urls[i]);
-                } catch (MalformedURLException e) {
-                    throw new MojoExecutionException(e.getMessage(), e);
-                }
-            }
-            final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
-            projectClassLoader = new URLClassLoader(urls, tccl != null ? tccl : getClass().getClassLoader());
-        }
-        return projectClassLoader;
-    }
-
-    protected void mergeTemplate(VelocityContext context, File outFile, String templateName) throws MojoExecutionException {
-        // ensure parent directories exist
-        outFile.getParentFile().mkdirs();
-
-        // add generated date
-        context.put("generatedDate", new Date().toString());
-        // add output package
-        context.put("packageName", outPackage);
-
-        // load velocity template
-        final Template template = getEngine().getTemplate(templateName, "UTF-8");
-
-        // generate file
-        BufferedWriter writer = null;
-        try {
-            writer = new BufferedWriter(new FileWriter(outFile));
-            template.merge(context, writer);
-        } catch (IOException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        } catch (VelocityException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        } finally {
-            if (writer != null) {
-                try {
-                    writer.close();
-                } catch (IOException ignore) {}
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
deleted file mode 100644
index 28d5e3b..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
+++ /dev/null
@@ -1,115 +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 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.apache.velocity.VelocityContext;
-
-/**
- * Generates Camel Component based on a collection of APIs.
- */
-@Mojo(name = "fromApis", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
-        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
-public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
-
-    @Parameter(required = true)
-    protected ApiProxy[] apis;
-
-    @Override
-    public void execute() throws MojoExecutionException, MojoFailureException {
-        if (apis == null || apis.length == 0) {
-            throw new MojoExecutionException("One or more API proxies are required");
-        }
-
-        // generate ApiCollection
-        mergeTemplate(getApiContext(), getApiCollectionFile(), "/api-collection.vm");
-
-        // generate ApiName
-        mergeTemplate(getApiContext(), getApiNameFile(), "/api-name-enum.vm");
-    }
-
-    private VelocityContext getApiContext() {
-        final VelocityContext context = new VelocityContext();
-        context.put("componentName", componentName);
-        context.put("componentPackage", componentPackage);
-        context.put("apis", apis);
-        context.put("helper", getClass());
-        context.put("collectionName", getApiCollectionName());
-        context.put("apiNameEnum", getApiNameEnum());
-        return context;
-    }
-
-    private String getApiCollectionName() {
-        return componentName + "ApiCollection";
-    }
-
-    private String getApiNameEnum() {
-        return componentName + "ApiName";
-    }
-
-    private File getApiCollectionFile() {
-        final StringBuilder fileName = getFileBuilder();
-        fileName.append(getApiCollectionName()).append(".java");
-        return new File(generatedSrcDir, fileName.toString());
-    }
-
-    private File getApiNameFile() {
-        final StringBuilder fileName = getFileBuilder();
-        fileName.append(getApiNameEnum()).append(".java");
-        return new File(generatedSrcDir, fileName.toString());
-    }
-
-    private StringBuilder getFileBuilder() {
-        final StringBuilder fileName = new StringBuilder();
-        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
-        return fileName;
-    }
-
-    public static String getApiMethod(String proxyClass) {
-        return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "ApiMethod";
-    }
-
-    public static String getEndpointConfig(String proxyClass) {
-        return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "EndpointConfiguration";
-    }
-
-    public static String getEnumConstant(String enumValue) {
-        if (enumValue == null || enumValue.isEmpty()) {
-            return "DEFAULT";
-        }
-        StringBuilder builder = new StringBuilder();
-        if (!Character.isJavaIdentifierStart(enumValue.charAt(0))) {
-            builder.append('_');
-        }
-        for (char c : enumValue.toCharArray()) {
-            char upperCase = Character.toUpperCase(c);
-            if (!Character.isJavaIdentifierPart(upperCase)) {
-                builder.append('_');
-            } else {
-                builder.append(upperCase);
-            }
-        }
-        return builder.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
deleted file mode 100644
index 71bb89e..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiMethodAlias.java
+++ /dev/null
@@ -1,50 +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;
-
-/**
- * Represents method alias
- */
-public class ApiMethodAlias {
-
-    private String methodPattern;
-    private String methodAlias;
-
-    public ApiMethodAlias() {
-    }
-
-    public ApiMethodAlias(String methodPattern, String methodAlias) {
-        this.methodPattern = methodPattern;
-        this.methodAlias = methodAlias;
-    }
-
-    public String getMethodPattern() {
-        return methodPattern;
-    }
-
-    public void setMethodPattern(String methodPattern) {
-        this.methodPattern = methodPattern;
-    }
-
-    public String getMethodAlias() {
-        return methodAlias;
-    }
-
-    public void setMethodAlias(String methodAlias) {
-        this.methodAlias = methodAlias;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
deleted file mode 100644
index 69a759b..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiProxy.java
+++ /dev/null
@@ -1,73 +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.util.Collections;
-import java.util.List;
-
-/**
- * Represents an API to use for generating Camel Component.
- */
-public class ApiProxy {
-    private String apiName;
-    private String proxyClass;
-
-    private List<ApiMethodAlias> aliases = Collections.EMPTY_LIST;
-
-    public ApiProxy() {
-    }
-
-    public ApiProxy(String apiName, String proxyClass) {
-        this.apiName = apiName;
-        this.proxyClass = proxyClass;
-    }
-
-    public ApiProxy(String apiName, String proxyClass, List<ApiMethodAlias> aliases) {
-        this(apiName, proxyClass);
-        this.aliases = aliases;
-    }
-
-    public String getApiName() {
-        return apiName;
-    }
-
-    public void setApiName(String apiName) {
-        this.apiName = apiName;
-    }
-
-    public String getProxyClass() {
-        return proxyClass;
-    }
-
-    public void setProxyClass(String proxyClass) {
-        this.proxyClass = proxyClass;
-    }
-
-    public List<ApiMethodAlias> getAliases() {
-        return aliases;
-    }
-
-    public void setAliases(List<ApiMethodAlias> aliases) {
-        this.aliases = aliases;
-    }
-
-    public void validate() {
-        if (apiName == null || proxyClass == null) {
-            throw new IllegalArgumentException("Properties apiName and proxyClass are required");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/0c9fbb62/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
deleted file mode 100644
index 566ef0a..0000000
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/FileApiMethodGeneratorMojo.java
+++ /dev/null
@@ -1,64 +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.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.plugin.MojoExecutionException;
-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;
-
-/**
- * Parses ApiMethod signatures from a File.
- */
-@Mojo(name = "fromFile", requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, requiresProject = true,
-        defaultPhase = LifecyclePhase.GENERATE_SOURCES)
-public class FileApiMethodGeneratorMojo extends AbstractApiMethodGeneratorMojo {
-
-    @Parameter(required = true, property = PREFIX + "signatureFile")
-    protected File signatureFile;
-
-    @Override
-    public List<String> getSignatureList() throws MojoExecutionException {
-        // get signatureFile as a list of Strings
-        List<String> result = new ArrayList<String>();
-        try {
-            BufferedReader reader = new BufferedReader(new FileReader(this.signatureFile));
-            String line = reader.readLine();
-            while (line != null) {
-                result.add(line);
-                line = reader.readLine();
-            }
-        } catch (FileNotFoundException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        } catch (IOException e) {
-            throw new MojoExecutionException(e.getMessage(), e);
-        }
-        if (result.isEmpty()) {
-            throw new MojoExecutionException("Signature file " + signatureFile.getPath() + " is empty");
-        }
-        return result;
-    }
-}


[11/35] git commit: Added test for invoking a derived proxy class

Posted by dh...@apache.org.
Added test for invoking a derived proxy class


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

Branch: refs/heads/master
Commit: ec5a57ee16cceb34d54febccb162efd32d8bd2dc
Parents: ace29c8
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:19:35 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodHelperTest.java    | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ec5a57ee/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
index f41bc76..12bc877 100644
--- a/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
@@ -132,6 +132,21 @@ public class ApiMethodHelperTest {
         properties.put("name1", "Dave");
         properties.put("name2", "Frank");
         assertEquals("greetUs(name1, name2)", "Greetings Dave, Frank", apiMethodHelper.invokeMethod(proxy, TestMethod.GREETUS, properties));
+
+        properties.clear();
+        properties.put("names", new String[] { "Dave", "Frank" });
+        assertEquals("greetAll(names)", "Greetings Dave, Frank", apiMethodHelper.invokeMethod(proxy, TestMethod.GREETALL, properties));
+
+        // test with a derived proxy
+        proxy = new TestProxy() {
+            @Override
+            public String sayHi(String name) {
+                return "Howdy " + name;
+            }
+        };
+        properties.clear();
+        properties.put("name", "Dave");
+        assertEquals("Derived sayHi(name)", "Howdy Dave", apiMethodHelper.invokeMethod(proxy, TestMethod.SAYHI_1, properties));
     }
 
     static enum TestMethod implements ApiMethod {


[25/35] git commit: Fixed formatting

Posted by dh...@apache.org.
Fixed formatting


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

Branch: refs/heads/master
Commit: bbb4127a977ac0f8eb537368bd134401a1d9009c
Parents: 161b216
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 19:39:18 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:34 2014 -0700

----------------------------------------------------------------------
 .../src/main/resources/api-route-test.vm                           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bbb4127a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
index e53331f..78d6301 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-route-test.vm
@@ -69,7 +69,7 @@ public class ${testName} extends CamelTestSupport {
 #end
 #end
 ## method invocation result
-        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) ) $type result = (${type})#end
+        #if ( !$voidResult )#set ( $type = $helper.getResultDeclaration($resultType) )$type result = (${type})#end
 ## actual template call
 #if ( $args.isEmpty() )
 template().requestBody("direct://${model.UniqueName}", (Object)null);


[07/35] git commit: Fixed array argument handling

Posted by dh...@apache.org.
Fixed array argument handling


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

Branch: refs/heads/master
Commit: 0932ed48a947ae607b1d7572888531702dc8fb4e
Parents: 03f63df
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:18:17 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:30 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodHelper.java     | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0932ed48/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
index 9f250f0..dbbc332 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
@@ -128,7 +128,7 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
                 // also collect argument names for all methods, and detect clashes here
                 final Class<?> previousType = VALID_ARGUMENTS.get(argName);
                 if (previousType != null && previousType != argType) {
-                    throw new ExceptionInInitializerError(String.format(
+                    throw new IllegalArgumentException(String.format(
                         "Argument %s has ambiguous types (%s, %s) across methods!",
                         name, previousType, argType));
                 } else if (previousType == null) {
@@ -334,14 +334,16 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
                     }
                     value = array;
                 } else if (value.getClass().isArray()
-                    && type.getComponentType().isAssignableFrom(value.getClass().getComponentType())) {
-                    // convert derived array to super array
-                    final int size = Array.getLength(value);
-                    Object array = Array.newInstance(type.getComponentType(), size);
-                    for (int i = 0; i < size; i++) {
-                        Array.set(array, i, Array.get(value, i));
+                        && type.getComponentType().isAssignableFrom(value.getClass().getComponentType())) {
+                    // convert derived array to super array if needed
+                    if (type.getComponentType() != value.getClass().getComponentType()) {
+                        final int size = Array.getLength(value);
+                        Object array = Array.newInstance(type.getComponentType(), size);
+                        for (int i = 0; i < size; i++) {
+                            Array.set(array, i, Array.get(value, i));
+                        }
+                        value = array;
                     }
-                    value = array;
                 } else {
                     throw new IllegalArgumentException(
                         String.format("Cannot convert %s to %s", value.getClass(), type));


[29/35] git commit: Fixed generated ApiCollection, fixed integration test

Posted by dh...@apache.org.
Fixed generated ApiCollection, fixed integration test


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

Branch: refs/heads/master
Commit: b79eb69c2dc611f52af96303f1e53255145bc7cd
Parents: 4e1254a
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed Jun 4 19:03:50 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:34 2014 -0700

----------------------------------------------------------------------
 .../src/it/all-it/pom.xml                             | 14 ++------------
 .../src/main/resources/api-collection.vm              |  6 +++---
 2 files changed, 5 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b79eb69c/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
index 5ebd269..9f6f877 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
+++ b/tooling/maven/camel-component-util-maven-plugin/src/it/all-it/pom.xml
@@ -152,30 +152,20 @@
           </execution>
         </executions>
       </plugin>
-      <!-- add generated source and test source to build -->
+      <!-- add generated source and test source to build for test-compile -->
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <version>@build-helper-maven-plugin-version@</version>
         <executions>
           <execution>
-            <id>add-generated-sources</id>
-            <goals>
-              <goal>add-source</goal>
-            </goals>
-            <configuration>
-              <sources>
-                <source>${project.build.directory}/generated-sources/camel-component</source>
-              </sources>
-            </configuration>
-          </execution>
-          <execution>
             <id>add-generated-test-sources</id>
             <goals>
               <goal>add-test-source</goal>
             </goals>
             <configuration>
               <sources>
+                <source>${project.build.directory}/generated-sources/camel-component</source>
                 <source>${project.build.directory}/generated-test-sources/camel-component</source>
               </sources>
             </configuration>

http://git-wip-us.apache.org/repos/asf/camel/blob/b79eb69c/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index 868b958..0774366 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -48,10 +48,10 @@ public final class $collectionName extends ApiCollection<${apiNameEnum}, ${compo
 #foreach( $alias in $api.Aliases )
         aliases.put("$alias.MethodPattern", "$alias.MethodAlias");
 #end
-#set( $apiMethod = "${helper.getApiMethod($api.ProxyClass)}.class" )
+#set( $apiMethod = ${helper.getApiMethod($api.ProxyClass)} )
 #set( $apiName = "${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}" )
-        apis.put($apiName, new ApiMethodHelper<$apiMethod>(${apiMethod}, aliases));
-        apiMethods.put(${apiMethod}, ${apiName});
+        apis.put($apiName, new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
+        apiMethods.put(${apiMethod}.class, ${apiName});
 #end
     }
 


[23/35] git commit: Initial version of camel-archetype-api-component

Posted by dh...@apache.org.
Initial version of camel-archetype-api-component


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

Branch: refs/heads/master
Commit: a056dfad9fdd53e217b7b98047f4033aeaad7b56
Parents: dd70b99
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Tue Jun 3 12:44:16 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:33 2014 -0700

----------------------------------------------------------------------
 .../camel-archetype-api-component/pom.xml       |  59 +++++
 .../META-INF/maven/archetype-metadata.xml       | 110 +++++++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../resources/archetype-resources/ReadMe.txt    |  13 +
 .../__artifactId__-api/pom.xml                  |  60 +++++
 .../src/main/java/__name__FileSigApi.java       |  31 +++
 .../src/main/java/__name__JavadocSigApi.java    |  31 +++
 .../__artifactId__-component/pom.xml            | 245 +++++++++++++++++++
 .../signatures/file-sig-api.txt                 |   2 +
 .../src/main/java/__name__Component.java        |  34 +++
 .../src/main/java/__name__Consumer.java         |  56 +++++
 .../src/main/java/__name__Endpoint.java         |  51 ++++
 .../src/main/java/__name__Producer.java         |  40 +++
 .../org/apache/camel/component/__scheme__       |  17 ++
 .../src/test/resources/log4j.properties         |  30 +++
 .../main/resources/archetype-resources/pom.xml  |  49 ++++
 tooling/archetypes/pom.xml                      |   1 +
 18 files changed, 1043 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/pom.xml
new file mode 100644
index 0000000..b86cf45
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>archetypes</artifactId>
+    <version>2.14-SNAPSHOT</version>
+  </parent>
+
+  <groupId>org.apache.camel.archetypes</groupId>
+  <artifactId>camel-archetype-api-component</artifactId>
+  <name>Camel :: Archetypes :: Component</name>
+  <description>Creates a new Camel component that wraps one or more API proxies.</description>
+  <packaging>maven-archetype</packaging>
+
+  <build>
+    <extensions>
+      <extension>
+        <groupId>org.apache.maven.archetype</groupId>
+        <artifactId>archetype-packaging</artifactId>
+        <version>${maven-archetype-packaging-version}</version>
+      </extension>
+    </extensions>
+
+    <!-- include all resources but only filter archetype-metadata.xml -->
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>false</filtering>
+      </resource>
+      <resource>
+        <directory>src/main/resources-filtered</directory>
+        <filtering>true</filtering>
+        <includes>
+          <include>**/archetype-metadata.xml</include>
+        </includes>
+      </resource>
+    </resources>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..96b096c
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="camel-archetype-from-apis"
+    xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+  <requiredProperties>
+    <requiredProperty key="name"/>
+    <requiredProperty key="scheme"/>
+    <requiredProperty key="camel-version">
+      <defaultValue>${project.version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="log4j-version">
+      <defaultValue>${log4j-version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="maven-compiler-plugin-version">
+      <defaultValue>${maven-compiler-plugin-version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="maven-resources-plugin-version">
+      <defaultValue>${maven-resources-plugin-version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="maven-bundle-plugin-version">
+      <defaultValue>${maven-bundle-plugin-version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="build-helper-maven-plugin-version">
+      <defaultValue>${build-helper-maven-plugin-version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="slf4j-version">
+      <defaultValue>${slf4j-version}</defaultValue>
+    </requiredProperty>
+    <requiredProperty key="log4j-version">
+      <defaultValue>${log4j-version}</defaultValue>
+    </requiredProperty>
+  </requiredProperties>
+
+  <fileSets>
+
+    <!-- root pom.xml -->
+    <fileSet filtered="true" encoding="UTF-8">
+      <directory></directory>
+      <includes>
+        <include>pom.xml</include>
+      </includes>
+    </fileSet>
+
+    <!-- component directories -->
+    <fileSet filtered="true" encoding="UTF-8">
+      <directory>__artifactId__-component/</directory>
+      <includes>
+        <include>ReadMe.txt</include>
+        <include>pom.xml</include>
+      </includes>
+    </fileSet>
+    <fileSet filtered="true" packaged="true" encoding="UTF-8">
+      <directory>__artifactId__-component/src/main/java</directory>
+      <includes>
+        <include>**/*.java</include>
+      </includes>
+    </fileSet>
+    <fileSet filtered="true" encoding="UTF-8">
+      <directory>__artifactId__-component/src/main/resources</directory>
+      <includes>
+        <include>**/*</include>
+      </includes>
+    </fileSet>
+    <fileSet filtered="true" encoding="UTF-8">
+      <directory>__artifactId__-component/src/test/resources</directory>
+      <includes>
+        <include>**/*</include>
+      </includes>
+    </fileSet>
+    <fileSet encoding="UTF-8">
+      <directory>__artifactId__-component/signatures</directory>
+      <includes>
+        <include>**/*.txt</include>
+      </includes>
+    </fileSet>
+
+    <!-- api directories -->
+    <fileSet filtered="true" encoding="UTF-8">
+      <directory>__artifactId__-api/</directory>
+      <includes>
+        <include>pom.xml</include>
+      </includes>
+    </fileSet>
+    <fileSet filtered="true" packaged="true" encoding="UTF-8">
+      <directory>__artifactId__-api/src/main/java</directory>
+      <includes>
+        <include>**/*.java</include>
+      </includes>
+    </fileSet>
+
+  </fileSets>
+
+</archetype-descriptor>

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/LICENSE.txt b/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/NOTICE.txt b/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/ReadMe.txt
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/ReadMe.txt b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/ReadMe.txt
new file mode 100644
index 0000000..f327e1e
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/ReadMe.txt
@@ -0,0 +1,13 @@
+Camel Component Project
+=======================
+
+This project is a template of a Camel component.
+
+To build this project use
+
+    mvn install
+
+For more help see the Apache Camel documentation:
+
+    http://camel.apache.org/writing-components.html
+    

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
new file mode 100644
index 0000000..632a897
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>${groupId}</groupId>
+    <artifactId>${artifactId}-parent</artifactId>
+    <version>${version}</version>
+  </parent>
+
+  <artifactId>${artifactId}-api</artifactId>
+  <name>Camel ${name} Component API</name>
+  <url>http://www.myorganization.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <plugins>
+      
+      <!-- to generate API Javadoc -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>${maven-javadoc-plugin-version}</version>
+        <executions>
+          <execution>
+            <id>add-javadoc</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java
new file mode 100644
index 0000000..4c86927
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__FileSigApi.java
@@ -0,0 +1,31 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+/**
+ * Sample API used by ${name} Component whose method signatures are read from File.
+ */
+public class ${name}FileSigApi {
+
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String greetMe(String name) {
+        return "Hello " + name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java
new file mode 100644
index 0000000..3ab3f82
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/__name__JavadocSigApi.java
@@ -0,0 +1,31 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+/**
+ * Sample API used by ${name} Component whose method signatures are read from Javadoc.
+ */
+public class ${name}JavadocSigApi {
+
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String greetMe(String name) {
+        return "Hello " + name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
new file mode 100644
index 0000000..f724e37
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -0,0 +1,245 @@
+<?xml version="1.0" encoding="UTF-8"?>
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>${groupId}</groupId>
+    <artifactId>${artifactId}-parent</artifactId>
+    <version>${version}</version>
+  </parent>
+
+  <artifactId>${artifactId}</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel ${name} Component</name>
+  <url>http://www.myorganization.org</url>
+
+  <properties>
+    <schemeName>${scheme}</schemeName>
+    <componentName>${name}</componentName>
+    <componentPackage>${package}</componentPackage>
+    <outPackage>${package}.internal</outPackage>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <version>${camel-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${groupId}</groupId>
+      <artifactId>${artifactId}-api</artifactId>
+      <version>${version}</version>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${slf4j-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>${log4j-version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <version>${camel-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- include component API javadoc in test scope to read API signatures -->
+    <dependency>
+      <groupId>${groupId}</groupId>
+      <artifactId>${artifactId}-api</artifactId>
+      <version>${version}</version>
+      <classifier>javadoc</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <plugins>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>${maven-compiler-plugin-version}</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>${maven-resources-plugin-version}</version>
+        <configuration>
+          <encoding>UTF-8</encoding>
+        </configuration>
+      </plugin>
+
+      <!-- to generate the MANIFEST-FILE of the bundle -->
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>${maven-bundle-plugin-version}</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>${groupId}.${artifactId}</Bundle-SymbolicName>
+            <Export-Service>org.apache.camel.spi.ComponentResolver;component=${scheme}</Export-Service>
+          </instructions>
+        </configuration>
+      </plugin>
+
+      <!-- generate Component source and test source -->
+      <plugin>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-component-util-maven-plugin</artifactId>
+        <version>${camel-version}</version>
+        <executions>
+          <execution>
+            <id>generate-from-file-api</id>
+            <goals>
+              <goal>fromFile</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${schemeName}</scheme>
+              <componentName>${componentName}</componentName>
+              <proxyClass>${package}.${name}FileSigApi</proxyClass>
+              <!-- Use substitutions to manipulate parameter names and avoid name clashes
+              <substitutions>
+                <substitution>
+                  <method>^.+$</method>
+                  <argName>^.+$</argName>
+                  <argType>java.lang.String</argType>
+                  <replacement>$1Param</replacement>
+                </substitution>
+              </substitutions>
+              -->
+              <signatureFile>signatures/file-sig-api.txt</signatureFile>
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-from-javadoc-api</id>
+            <goals>
+              <goal>fromJavadoc</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${schemeName}</scheme>
+              <componentName>${componentName}</componentName>
+              <proxyClass>${package}.${name}JavadocSigApi</proxyClass>
+              <!-- Use substitutions to manipulate parameter names and avoid name clashes
+              <substitutions>
+                <substitution>
+                  <method>^.+$</method>
+                  <argName>^.+$</argName>
+                  <argType>java.lang.String</argType>
+                  <replacement>$1Arg</replacement>
+                </substitution>
+              </substitutions>
+              -->
+              <!-- Use exclude patterns to limit what gets exposed in component endpoint
+              <excludePackages>package-name-patterns</excludePackages>
+              <excludeClasses>class-name-patterns</excludeClasses>
+              <excludeMethods>method-name-patterns</excludeMethods>
+              -->
+            </configuration>
+          </execution>
+          <execution>
+            <id>generate-test-component-classes</id>
+            <goals>
+              <goal>fromApis</goal>
+            </goals>
+            <configuration>
+              <outPackage>${outPackage}</outPackage>
+              <componentPackage>${componentPackage}</componentPackage>
+              <scheme>${schemeName}</scheme>
+              <componentName>${componentName}</componentName>
+              <apis>
+                <api>
+                  <apiName>hello1</apiName>
+                  <proxyClass>${package}.${name}FileSigApi</proxyClass>
+                </api>
+                <api>
+                  <apiName>hello2</apiName>
+                  <proxyClass>${package}.${name}JavadocSigApi</proxyClass>
+                </api>
+              </apis>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!-- add generated source and test source to build -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <version>${build-helper-maven-plugin-version}</version>
+        <executions>
+          <execution>
+            <id>add-generated-sources</id>
+            <goals>
+              <goal>add-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-sources/camel-component</source>
+              </sources>
+            </configuration>
+          </execution>
+          <execution>
+            <id>add-generated-test-sources</id>
+            <goals>
+              <goal>add-test-source</goal>
+            </goals>
+            <configuration>
+              <sources>
+                <source>${project.build.directory}/generated-test-sources/camel-component</source>
+              </sources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/signatures/file-sig-api.txt
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/signatures/file-sig-api.txt b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/signatures/file-sig-api.txt
new file mode 100644
index 0000000..f9c1310
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/signatures/file-sig-api.txt
@@ -0,0 +1,2 @@
+public String sayHi();
+public String greetMe(String name);

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
new file mode 100644
index 0000000..a87f1f4
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Component.java
@@ -0,0 +1,34 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Represents the component that manages {@link ${name}Endpoint}.
+ */
+public class ${name}Component extends DefaultComponent {
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        Endpoint endpoint = new ${name}Endpoint(uri, this);
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
new file mode 100644
index 0000000..340fb68
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Consumer.java
@@ -0,0 +1,56 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+import java.util.Date;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+/**
+ * The ${name} consumer.
+ */
+public class ${name}Consumer extends ScheduledPollConsumer {
+
+    private final ${name}Endpoint endpoint;
+
+    public ${name}Consumer(${name}Endpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        Exchange exchange = endpoint.createExchange();
+
+        // create a message body
+        Date now = new Date();
+        exchange.getIn().setBody("Hello World! The time is " + now);
+
+        try {
+            // send message to next processor in the route
+            getProcessor().process(exchange);
+            return 1; // number of messages polled
+        } finally {
+            // log exception if an exception occurred and was not handled
+            if (exchange.getException() != null) {
+                getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
new file mode 100644
index 0000000..9c25c8e
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
@@ -0,0 +1,51 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * Represents a ${name} endpoint.
+ */
+public class ${name}Endpoint extends DefaultEndpoint {
+
+    public ${name}Endpoint() {
+    }
+
+    public ${name}Endpoint(String uri, ${name}Component component) {
+        super(uri, component);
+    }
+
+    public ${name}Endpoint(String endpointUri) {
+        super(endpointUri);
+    }
+
+    public Producer createProducer() throws Exception {
+        return new ${name}Producer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new ${name}Consumer(this, processor);
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
new file mode 100644
index 0000000..3fd064a
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Producer.java
@@ -0,0 +1,40 @@
+## ------------------------------------------------------------------------
+## 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 ${package};
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The ${name} producer.
+ */
+public class ${name}Producer extends DefaultProducer {
+    private static final Logger LOG = LoggerFactory.getLogger(${name}Producer.class);
+    private ${name}Endpoint endpoint;
+
+    public ${name}Producer(${name}Endpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        System.out.println(exchange.getIn().getBody());    
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/resources/META-INF/services/org/apache/camel/component/__scheme__
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/resources/META-INF/services/org/apache/camel/component/__scheme__ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/resources/META-INF/services/org/apache/camel/component/__scheme__
new file mode 100644
index 0000000..ff171b5
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/resources/META-INF/services/org/apache/camel/component/__scheme__
@@ -0,0 +1,17 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+class=${package}.${name}Component

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/log4j.properties b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/log4j.properties
new file mode 100644
index 0000000..a937abd
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/test/resources/log4j.properties
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/pom.xml b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..c623fa3
--- /dev/null
+++ b/tooling/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>${groupId}</groupId>
+  <artifactId>${artifactId}-parent</artifactId>
+  <packaging>pom</packaging>
+  <version>${version}</version>
+
+  <name>Camel ${name} Component Parent</name>
+  <url>http://www.myorganization.org</url>
+
+  <modules>
+    <module>${artifactId}-component</module>
+    <module>${artifactId}-api</module>
+  </modules>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>${maven-compiler-plugin-version}</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/a056dfad/tooling/archetypes/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/archetypes/pom.xml b/tooling/archetypes/pom.xml
index 99c6cb3..618127e 100644
--- a/tooling/archetypes/pom.xml
+++ b/tooling/archetypes/pom.xml
@@ -32,6 +32,7 @@
 
   <modules>
     <module>camel-archetype-activemq</module>
+    <module>camel-archetype-api-component</module>
     <module>camel-archetype-blueprint</module>
     <module>camel-archetype-component</module>
     <module>camel-archetype-component-scala</module>


[17/35] git commit: Updated ApiComponentGeneratorMojo to generate ApiName enumeration

Posted by dh...@apache.org.
Updated ApiComponentGeneratorMojo to generate ApiName enumeration


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

Branch: refs/heads/master
Commit: dd70b99d643b5257ca90694338df5f9cc50a02fd
Parents: a38476c
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon Jun 2 15:47:54 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:32 2014 -0700

----------------------------------------------------------------------
 .../camel/maven/ApiComponentGeneratorMojo.java  | 53 +++++++++++++++---
 .../src/main/resources/api-collection.vm        |  4 +-
 .../src/main/resources/api-name-enum.vm         | 56 ++++++++++++++++++++
 3 files changed, 103 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/dd70b99d/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
index b967817..d0d4b97 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java
@@ -42,33 +42,70 @@ public class ApiComponentGeneratorMojo extends AbstractGeneratorMojo {
             throw new MojoExecutionException("One or more API proxies are required");
         }
 
-        // TODO generate Component classes
         // generate ApiCollection
-        mergeTemplate(getApiCollectionContext(), getApiCollectionFile(), "/api-collection.vm");
+        mergeTemplate(getApiContext(), getApiCollectionFile(), "/api-collection.vm");
+
+        // generate ApiName
+        mergeTemplate(getApiContext(), getApiNameFile(), "/api-name-enum.vm");
     }
 
-    private VelocityContext getApiCollectionContext() {
+    private VelocityContext getApiContext() {
         final VelocityContext context = new VelocityContext();
         context.put("componentName", componentName);
-        context.put("collectionName", getApiCollectionName());
         context.put("packageName", outPackage);
         context.put("apis", apis);
         context.put("helper", getClass());
+        context.put("collectionName", getApiCollectionName());
+        context.put("apiNameEnum", getApiNameEnum());
         return context;
     }
 
+    private String getApiCollectionName() {
+        return componentName + "ApiCollection";
+    }
+
+    private String getApiNameEnum() {
+        return componentName + "ApiName";
+    }
+
     private File getApiCollectionFile() {
-        final StringBuilder fileName = new StringBuilder();
-        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        final StringBuilder fileName = getFileBuilder();
         fileName.append(getApiCollectionName()).append(".java");
         return new File(generatedSrcDir, fileName.toString());
     }
 
-    private String getApiCollectionName() {
-        return componentName + "ApiCollection";
+    private File getApiNameFile() {
+        final StringBuilder fileName = getFileBuilder();
+        fileName.append(getApiNameEnum()).append(".java");
+        return new File(generatedSrcDir, fileName.toString());
+    }
+
+    private StringBuilder getFileBuilder() {
+        final StringBuilder fileName = new StringBuilder();
+        fileName.append(outPackage.replaceAll("\\.", File.separator)).append(File.separator);
+        return fileName;
     }
 
     public static String getApiMethod(String proxyClass) {
         return proxyClass.substring(proxyClass.lastIndexOf('.') + 1) + "ApiMethod";
     }
+
+    public static String getEnumConstant(String enumValue) {
+        if (enumValue == null || enumValue.isEmpty()) {
+            return "DEFAULT";
+        }
+        StringBuilder builder = new StringBuilder();
+        if (!Character.isJavaIdentifierStart(enumValue.charAt(0))) {
+            builder.append('_');
+        }
+        for (char c : enumValue.toCharArray()) {
+            char upperCase = Character.toUpperCase(c);
+            if (!Character.isJavaIdentifierPart(upperCase)) {
+                builder.append('_');
+            } else {
+                builder.append(upperCase);
+            }
+        }
+        return builder.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/dd70b99d/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
index 7529712..b7213c6 100644
--- a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-collection.vm
@@ -30,7 +30,7 @@ import org.apache.camel.util.component.ApiMethodHelper;
 /**
  * Camel {@link ApiCollection} for $componentName
  */
-public final class $collectionName extends ApiCollection {
+public final class $collectionName extends ApiCollection<${apiNameEnum}> {
 
     private static $collectionName collection;
 
@@ -42,7 +42,7 @@ public final class $collectionName extends ApiCollection {
         aliases.put("$alias.Key", "$alias.Value");
 #end
 #set( $apiMethod = $helper.getApiMethod($api.ProxyClass) )
-        apis.put("$api.ApiName", new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
+        apis.put(${apiNameEnum}.${helper.getEnumConstant($api.ApiName)}, new ApiMethodHelper<$apiMethod>(${apiMethod}.class, aliases));
 #end
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/dd70b99d/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
new file mode 100644
index 0000000..f4fa253
--- /dev/null
+++ b/tooling/maven/camel-component-util-maven-plugin/src/main/resources/api-name-enum.vm
@@ -0,0 +1,56 @@
+## ------------------------------------------------------------------------
+## 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.
+## ------------------------------------------------------------------------
+## api-name-enum.vm
+/*
+ * Camel ApiName Enumeration generated by camel-component-util-maven-plugin
+ * Generated on: $generatedDate
+ */
+package $packageName;
+
+import org.apache.camel.util.component.ApiName;
+
+/**
+ * Camel {@link ApiName} Enumeration for Component $componentName
+ */
+public enum $apiNameEnum implements ApiName {
+
+#foreach ( $api in $apis )
+#set ( $apiName = $api.ApiName )
+    ${helper.getEnumConstant($apiName)}("$apiName")#if ( $foreach.hasNext ),#else;#end
+
+#end
+
+    private final String name;
+
+    private ${apiNameEnum}(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    public static $apiNameEnum fromValue(String value) {
+        for ($apiNameEnum api : ${apiNameEnum}.values()) {
+            if (api.name.equals(value)) {
+                return api;
+            }
+        }
+        throw new IllegalArgumentException("Invalid value " + value);
+    }
+}


[05/35] git commit: Initial version of Component utilities

Posted by dh...@apache.org.
Initial version of Component utilities


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

Branch: refs/heads/master
Commit: 10a0b6156a1a2a7ad8d349d3e561b713b5e51377
Parents: c59a0ff
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 23 13:29:39 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:29 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiCollection.java     |  33 ++
 .../apache/camel/util/component/ApiMethod.java  |  57 +++
 .../camel/util/component/ApiMethodHelper.java   | 366 +++++++++++++++++++
 .../camel/util/component/ApiMethodImpl.java     | 123 +++++++
 .../camel/util/component/ApiMethodParser.java   | 288 +++++++++++++++
 .../component/ApiMethodPropertiesHelper.java    | 103 ++++++
 .../component/ArgumentSubstitutionParser.java   | 143 ++++++++
 .../util/component/ApiMethodHelperTest.java     | 169 +++++++++
 .../ApiMethodPropertiesHelperTest.java          | 122 +++++++
 .../ArgumentSubstitutionParserTest.java         |  52 +++
 .../apache/camel/util/component/TestProxy.java  |  64 ++++
 11 files changed, 1520 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
new file mode 100644
index 0000000..585fbb2
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiCollection.java
@@ -0,0 +1,33 @@
+/**
+ * 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.util.component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Base class for a collection of ApiMethods. Meant to be extended by Components to create the api name map.
+ */
+public abstract class ApiCollection {
+
+    protected final Map<String, ApiMethodHelper> apis = new HashMap<String, ApiMethodHelper>();
+
+    public final ApiMethodHelper getHelper(String apiName) {
+        return apis.get(apiName);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ApiMethod.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethod.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethod.java
new file mode 100644
index 0000000..7ee7cb9
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethod.java
@@ -0,0 +1,57 @@
+/**
+ * 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.util.component;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+/**
+ * Interface for proxy methods.
+ */
+public interface ApiMethod {
+
+    /**
+     * Returns method name.
+     * @return
+     */
+    String getName();
+
+    /**
+     * Returns method result type.
+     * @return
+     */
+    Class<?> getResultType();
+
+    /**
+     * Returns method argument names.
+     * @return
+     */
+    List<String> getArgNames();
+
+    /**
+     * Return method argument types.
+     * @return
+     */
+    List<Class<?>> getArgTypes();
+
+    /**
+     * Returns {@link Method} in proxy type.
+     * @return
+     */
+    Method getMethod();
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
new file mode 100644
index 0000000..9f250f0
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
@@ -0,0 +1,366 @@
+/**
+ * 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.util.component;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.RuntimeCamelException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Helper class for working with {@link ApiMethod}.
+ */
+public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ApiMethodHelper.class);
+
+    // maps method name to ApiMethod
+    private final Map<String, List<T>> METHOD_MAP = new HashMap<String, List<T>>();
+
+    // maps method name to method arguments of the form Class type1, String name1, Class type2, String name2,...
+    private final Map<String, List<Object>> ARGUMENTS_MAP = new HashMap<String, List<Object>>();
+
+    // maps argument name to argument type
+    private final Map<String, Class<?>> VALID_ARGUMENTS = new HashMap<String, Class<?>>();
+
+    // maps aliases to actual method names
+    private final HashMap<String, String> ALIASES = new HashMap<String, String>();
+
+    /**
+     * Create a helper to work with a {@link ApiMethod}, using optional method aliases.
+     * @param apiMethodEnum {@link ApiMethod} enumeration class
+     * @param aliases Aliases mapped to actual method names
+     */
+    public ApiMethodHelper(Class<T> apiMethodEnum, Map<String, String> aliases) {
+
+        // validate ApiMethod Enum
+        if (apiMethodEnum == null) {
+            throw new IllegalArgumentException("ApiMethod enumeration cannot be null");
+        }
+
+        final Map<Pattern, String> aliasPatterns = new HashMap<Pattern, String>();
+        for (Map.Entry<String, String> alias : aliases.entrySet()) {
+            if (alias.getKey() == null || alias.getValue() == null) {
+                throw new IllegalArgumentException("Alias pattern and replacement cannot be null");
+            }
+            aliasPatterns.put(Pattern.compile(alias.getKey()), alias.getValue());
+        }
+
+        LOG.debug("Processing " + apiMethodEnum.getName());
+        final T[] methods = apiMethodEnum.getEnumConstants();
+
+        // load lookup maps
+        for (T method : methods) {
+
+            final String name = method.getName();
+
+            // add method name aliases
+            for (Map.Entry<Pattern, String> aliasEntry : aliasPatterns.entrySet()) {
+                final Matcher matcher = aliasEntry.getKey().matcher(name);
+                if (matcher.find()) {
+                    // add method name alias
+                    String alias = matcher.replaceAll(aliasEntry.getValue());
+                    // convert first character to lowercase
+                    assert alias.length() > 1;
+                    final char firstChar = alias.charAt(0);
+                    if (!Character.isLowerCase(firstChar)) {
+                        final StringBuilder builder = new StringBuilder();
+                        builder.append(Character.toLowerCase(firstChar)).append(alias.substring(1));
+                        alias = builder.toString();
+                    }
+                    ALIASES.put(alias, name);
+                }
+            }
+
+            // map method name to Enum
+            List<T> overloads = METHOD_MAP.get(name);
+            if (overloads == null) {
+                overloads = new ArrayList<T>();
+                METHOD_MAP.put(method.getName(), overloads);
+            }
+            overloads.add(method);
+
+            // add arguments for this method
+            List<Object> arguments = ARGUMENTS_MAP.get(name);
+            if (arguments == null) {
+                arguments = new ArrayList<Object>();
+                ARGUMENTS_MAP.put(name, arguments);
+            }
+
+            // process all arguments for this method
+            final int nArgs = method.getArgNames().size();
+            final String[] argNames = method.getArgNames().toArray(new String[nArgs]);
+            final Class<?>[] argTypes = method.getArgTypes().toArray(new Class[nArgs]);
+            for (int i = 0; i < nArgs; i++) {
+                final String argName = argNames[i];
+                final Class<?> argType = argTypes[i];
+                if (!arguments.contains(argName)) {
+                    arguments.add(argType);
+                    arguments.add(argName);
+                }
+
+                // also collect argument names for all methods, and detect clashes here
+                final Class<?> previousType = VALID_ARGUMENTS.get(argName);
+                if (previousType != null && previousType != argType) {
+                    throw new ExceptionInInitializerError(String.format(
+                        "Argument %s has ambiguous types (%s, %s) across methods!",
+                        name, previousType, argType));
+                } else if (previousType == null) {
+                    VALID_ARGUMENTS.put(argName, argType);
+                }
+            }
+
+        }
+
+        LOG.debug("Found {} unique method names in {} methods", METHOD_MAP.size(), methods.length);
+    }
+
+    /**
+     * Gets methods that match the given name and arguments.<p/>
+     * Note that the args list is a required subset of arguments for returned methods.
+     * @param name case sensitive full method name to lookup
+     * @param argNames unordered required argument names
+     * @return non-null unmodifiable list of methods that take all of the given arguments, empty if there is no match
+     */
+    public List<T> getCandidateMethods(String name, String... argNames) {
+        List<T> methods = METHOD_MAP.get(name);
+        if (methods == null) {
+            if (ALIASES.containsKey(name)) {
+                methods = METHOD_MAP.get(ALIASES.get(name));
+            }
+        }
+        if (methods == null) {
+            LOG.debug("No matching method for method {}", name);
+            return Collections.emptyList();
+        }
+        int nArgs = argNames != null ? argNames.length : 0;
+        if (nArgs == 0) {
+            LOG.debug("Found {} methods for method {}", methods.size(), name);
+            return Collections.unmodifiableList(methods);
+        } else {
+            final List<T> filteredSet = filterMethods(methods, MatchType.SUBSET, argNames);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Found {} filtered methods for {}",
+                    filteredSet.size(), name + Arrays.toString(argNames).replace('[', '(').replace(']', ')'));
+            }
+            return filteredSet;
+        }
+    }
+
+    /**
+     * Filters a list of methods to those that take the given set of arguments.
+     *
+     * @param methods list of methods to filter
+     * @param matchType whether the arguments are an exact match, a subset or a super set of method args
+     * @param argNames argument names to filter the list
+     * @return methods with arguments that satisfy the match type.<p/>
+     * For SUPER_SET match, if methods with exact match are found, methods that take a subset are ignored
+     */
+    public List<T> filterMethods(List<T> methods, MatchType matchType,
+                                                          String... argNames) {
+        List<String> argsList = Arrays.asList(argNames);
+        // list of methods that have all args in the given names
+        final List<T> result = new ArrayList<T>();
+        final List<T> extraArgs = new ArrayList<T>();
+
+        for (T method : methods) {
+            final List<String> methodArgs = method.getArgNames();
+            switch (matchType) {
+            case EXACT:
+                // method must take all args, and no more
+                if (methodArgs.containsAll(argsList) && argsList.containsAll(methodArgs)) {
+                    result.add(method);
+                }
+                break;
+            case SUBSET:
+                // all args are required, method may take more
+                if (methodArgs.containsAll(argsList)) {
+                    result.add(method);
+                }
+                break;
+            default:
+            case SUPER_SET:
+                // all method args must be present
+                if (argsList.containsAll(methodArgs)) {
+                    if (methodArgs.containsAll(argsList)) {
+                        // prefer exact match to avoid unused args
+                        result.add(method);
+                    } else {
+                        // method takes a subset, unused args
+                        extraArgs.add(method);
+                    }
+                }
+                break;
+            }
+        }
+
+        return Collections.unmodifiableList(result.isEmpty() ? extraArgs : result);
+    }
+
+    /**
+     * Gets argument types and names for all overloaded methods and aliases with the given name.
+     * @param name method name, either an exact name or an alias, exact matches are checked first
+     * @return list of arguments of the form Class type1, String name1, Class type2, String name2,...
+     */
+    public List<Object> getArguments(final String name) throws IllegalArgumentException {
+        List<Object> arguments = ARGUMENTS_MAP.get(name);
+        if (arguments == null) {
+            if (ALIASES.containsKey(name)) {
+                arguments = ARGUMENTS_MAP.get(ALIASES.get(name));
+            }
+        }
+        if (arguments == null) {
+            throw new IllegalArgumentException(name);
+        }
+        return Collections.unmodifiableList(arguments);
+    }
+
+    /**
+     * Get missing properties.
+     * @param methodName method name
+     * @param argNames available arguments
+     * @return Set of missing argument names
+     */
+    public Set<String> getMissingProperties(String methodName, Set<String> argNames) {
+        final List<Object> argsWithTypes = getArguments(methodName);
+        final Set<String> missingArgs = new HashSet<String>();
+
+        for (int i = 1; i < argsWithTypes.size(); i += 2) {
+            final String name = (String) argsWithTypes.get(i);
+            if (!argNames.contains(name)) {
+                missingArgs.add(name);
+            }
+        }
+
+        return missingArgs;
+    }
+
+    /**
+     * Get argument types and names used by all methods.
+     * @return map with argument names as keys, and types as values
+     */
+    public Map<String, Class<?>> allArguments() {
+        return Collections.unmodifiableMap(VALID_ARGUMENTS);
+    }
+
+    /**
+     * Get the type for the given argument name.
+     * @param argName argument name
+     * @return argument type
+     */
+    public Class<?> getType(String argName) throws IllegalArgumentException {
+        final Class<?> type = VALID_ARGUMENTS.get(argName);
+        if (type == null) {
+            throw new IllegalArgumentException(argName);
+        }
+        return type;
+    }
+
+    public T getHighestPriorityMethod(List<T> filteredMethods) {
+        T highest = null;
+        for (T method : filteredMethods) {
+            if (highest == null || method.compareTo(highest) > 0) {
+                highest = method;
+            }
+        }
+        return highest;
+    }
+
+    /**
+     * Invokes given method with argument values from given properties.
+     *
+     * @param proxy Proxy object for invoke
+     * @param method method to invoke
+     * @param properties Map of arguments
+     * @return result of method invocation
+     * @throws org.apache.camel.RuntimeCamelException on errors
+     */
+    public Object invokeMethod(Object proxy, T method, Map<String, Object> properties)
+        throws RuntimeCamelException {
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Invoking {} with arguments {}", method.getName(), properties);
+        }
+
+        final List<String> argNames = method.getArgNames();
+        final Object[] values = new Object[argNames.size()];
+        final List<Class<?>> argTypes = method.getArgTypes();
+        final Class<?>[] types = argTypes.toArray(new Class[argTypes.size()]);
+        int index = 0;
+        for (String name : argNames) {
+            Object value = properties.get(name);
+
+            // is the parameter an array type?
+            if (value != null && types[index].isArray()) {
+                Class<?> type = types[index];
+
+                if (value instanceof Collection) {
+                    // convert collection to array
+                    Collection<?> collection = (Collection<?>) value;
+                    Object array = Array.newInstance(type.getComponentType(), collection.size());
+                    if (array instanceof Object[]) {
+                        collection.toArray((Object[]) array);
+                    } else {
+                        int i = 0;
+                        for (Object el : collection) {
+                            Array.set(array, i++, el);
+                        }
+                    }
+                    value = array;
+                } else if (value.getClass().isArray()
+                    && type.getComponentType().isAssignableFrom(value.getClass().getComponentType())) {
+                    // convert derived array to super array
+                    final int size = Array.getLength(value);
+                    Object array = Array.newInstance(type.getComponentType(), size);
+                    for (int i = 0; i < size; i++) {
+                        Array.set(array, i, Array.get(value, i));
+                    }
+                    value = array;
+                } else {
+                    throw new IllegalArgumentException(
+                        String.format("Cannot convert %s to %s", value.getClass(), type));
+                }
+            }
+
+            values[index++] = value;
+        }
+
+        try {
+            return method.getMethod().invoke(proxy, values);
+        } catch (Throwable e) {
+            throw new RuntimeCamelException(
+                String.format("Error invoking %s with %s: %s", method.getName(), properties, e.getMessage()), e);
+        }
+    }
+
+    public static enum MatchType {
+        EXACT, SUBSET, SUPER_SET
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodImpl.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodImpl.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodImpl.java
new file mode 100644
index 0000000..2884164
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodImpl.java
@@ -0,0 +1,123 @@
+/**
+ * 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.util.component;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Delegate class for {@link ApiMethod}.
+ * This class is instantiated by Enumerations for Api Proxy types.
+ * <p>
+ *     For example:
+ * </p>
+ * <pre>
+ * {@code
+ *     public enum HelloWorldMethod implements ApiMethod {
+ *         SAYHI(String.class, "sayHi", "name", String.class);
+ *
+ *         private ApiMethodImpl apiMethod;
+ *
+ *         private HelloWorldMethods(Class<?> resultType, String name, Object... args) throws IllegalArgumentException {
+ *             this.apiMethod = new ApiMethod(HelloWorld.class, resultType, name, args);
+ *         }
+ *
+ *         // implement ApiMethod interface
+ *         String getName() { return apiMethod.getName(); }
+ *         Class<?> getResultType() {return apiMethod.getResultType(); }
+ *         List<String> getArgNames() { return apiMethod.getArgNames(); }
+ *         List<Class<?>> getArgTypes() {return apiMethod.getArgTypes(); }
+ *         Method getMethod() { return apiMethod.getMethod(); }
+ *     }
+ * }
+ * </pre>
+ */
+public final class ApiMethodImpl implements ApiMethod {
+
+    // name, result class, ordered argument names and classes, and Method to invoke
+    private final String name;
+    private final Class<?> resultType;
+    private final List<String> argNames;
+    private final List<Class<?>> argTypes;
+    private final Method method;
+
+    public ApiMethodImpl(Class<?> proxyType, Class<?> resultType, String name, Object... args) throws IllegalArgumentException {
+        this.name = name;
+        this.resultType = resultType;
+
+        if (args.length % 2 != 0) {
+            throw new IllegalArgumentException("Invalid parameter list, "
+                + "must be of the form 'Class arg1, String arg1Name, Class arg2, String arg2Name...");
+        }
+        int nArgs = args.length / 2;
+        this.argNames = new ArrayList<String>(nArgs);
+        this.argTypes = new ArrayList<Class<?>>(nArgs);
+        for (int i = 0; i < nArgs; i++) {
+            this.argTypes.add((Class<?>) args[i * 2]);
+            this.argNames.add((String) args[i * 2 + 1]);
+        }
+
+        // find method in Proxy type
+        try {
+            this.method = proxyType.getMethod(name, argTypes.toArray(new Class[nArgs]));
+        } catch (NoSuchMethodException e) {
+            throw new IllegalArgumentException(
+                String.format("Missing method %s %s", name, argTypes.toString().replace('[', '(').replace(']', ')')),
+                e);
+        }
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Class<?> getResultType() {
+        return resultType;
+    }
+
+    @Override
+    public List<String> getArgNames() {
+        return Collections.unmodifiableList(argNames);
+    }
+
+    @Override
+    public List<Class<?>> getArgTypes() {
+        return Collections.unmodifiableList(argTypes);
+    }
+
+    @Override
+    public Method getMethod() {
+        return method;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("{")
+            .append("name=").append(name)
+            .append(", resultType=").append(resultType)
+            .append(", argNames=").append(argNames)
+            .append(", argTypes=").append(argTypes)
+            .append("}");
+        return builder.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
new file mode 100644
index 0000000..4c6523a
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -0,0 +1,288 @@
+/**
+ * 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.util.component;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Parser base class for generating ApiMethod enumerations.
+ */
+public abstract class ApiMethodParser<T> {
+
+    private static final Pattern METHOD_PATTERN = Pattern.compile("\\s*(\\S+)\\s+(\\S+)\\s*\\(\\s*([\\S\\s,]*)\\)\\s*;?\\s*");
+    private static final Pattern ARGS_PATTERN = Pattern.compile("\\s*(\\S+)\\s+([^\\s,]+)\\s*,?");
+    private static final String JAVA_LANG = "java.lang.";
+    private static final Map<String, Class> PRIMITIVE_TYPES;
+
+    static {
+        PRIMITIVE_TYPES = new HashMap<String, Class>();
+        PRIMITIVE_TYPES.put("int", Integer.TYPE);
+        PRIMITIVE_TYPES.put("long", Long.TYPE);
+        PRIMITIVE_TYPES.put("double", Double.TYPE);
+        PRIMITIVE_TYPES.put("float", Float.TYPE);
+        PRIMITIVE_TYPES.put("boolean", Boolean.TYPE);
+        PRIMITIVE_TYPES.put("char", Character.TYPE);
+        PRIMITIVE_TYPES.put("byte", Byte.TYPE);
+        PRIMITIVE_TYPES.put("void", Void.TYPE);
+        PRIMITIVE_TYPES.put("short", Short.TYPE);
+    }
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final Class<T> proxyType;
+    private List<String> signatures;
+    private ClassLoader classLoader = ApiMethodParser.class.getClassLoader();
+
+    public ApiMethodParser(Class<T> proxyType) {
+        this.proxyType = proxyType;
+    }
+
+    public Class<T> getProxyType() {
+        return proxyType;
+    }
+
+    public final List<String> getSignatures() {
+        return signatures;
+    }
+
+    public final void setSignatures(List<String> signatures) {
+        this.signatures = new ArrayList<String>();
+        this.signatures.addAll(signatures);
+    }
+
+    public final ClassLoader getClassLoader() {
+        return classLoader;
+    }
+
+    public final void setClassLoader(ClassLoader classLoader) {
+        this.classLoader = classLoader;
+    }
+
+    /**
+     * Parses the method signatures from {@code getSignatures()}.
+     * @return list of Api methods as {@link ApiMethodModel}
+     */
+    public List<ApiMethodModel> parse() {
+        // parse sorted signatures and generate descriptions
+        List<ApiMethodModel> result = new ArrayList<ApiMethodModel>();
+        for (String signature: signatures) {
+            // remove all type parameters and modifiers
+            signature = signature.replaceAll("<[^>]*>|public|final", "");
+            log.debug("Processing " + signature);
+
+            final Matcher methodMatcher = METHOD_PATTERN.matcher(signature);
+            if (!methodMatcher.matches()) {
+                throw new IllegalArgumentException("Invalid method signature " + signature);
+            }
+
+            final Class<?> resultType = forName(methodMatcher.group(1));
+            final String name = methodMatcher.group(2);
+            final String argSignature = methodMatcher.group(3);
+
+            final List<Argument> arguments = new ArrayList<Argument>();
+
+            List<Class<?>> argTypes = new ArrayList<Class<?>>();
+            final Matcher argsMatcher = ARGS_PATTERN.matcher(argSignature);
+            while (argsMatcher.find()) {
+                final Class<?> type = forName(argsMatcher.group(1));
+                arguments.add(new Argument(argsMatcher.group(2), type));
+                argTypes.add(type);
+            }
+
+            Method method;
+            try {
+                method = proxyType.getMethod(name, argTypes.toArray(new Class<?>[argTypes.size()]));
+            } catch (NoSuchMethodException e) {
+                throw new IllegalArgumentException("Method not found [" + signature + "] in type " + proxyType.getName());
+            }
+            result.add(new ApiMethodModel(name, resultType, arguments, method));
+        }
+
+        Collections.sort(result, new Comparator<ApiMethodModel>() {
+            @Override
+            public int compare(ApiMethodModel model1, ApiMethodModel model2) {
+                final int nameCompare = model1.name.compareTo(model2.name);
+                if (nameCompare != 0) {
+                    return nameCompare;
+                } else {
+
+                    final int nArgs1 = model1.arguments.size();
+                    final int nArgsCompare = nArgs1 - model2.arguments.size();
+                    if (nArgsCompare != 0) {
+                        return nArgsCompare;
+                    } else {
+                        // same number of args, compare arg names, kinda arbitrary to use alphabetized order
+                        for (int i = 0; i < nArgs1; i++) {
+                            final int argCompare = model1.arguments.get(i).name.compareTo(model2.arguments.get(i).name);
+                            if (argCompare != 0) {
+                                return argCompare;
+                            }
+                        }
+                        // duplicate methods???
+                        log.warn("Duplicate methods found [" + model1 + "], [" + model2 + "]");
+                        return 0;
+                    }
+                }
+            }
+        });
+
+        // assign unique names to every method model
+        final Map<String, Integer> dups = new HashMap<String, Integer>();
+        for (ApiMethodModel model : result) {
+            // TODO watch out, this uses default locale to convert to upper case
+            String uniqueName = model.name.toUpperCase();
+            Integer suffix = dups.get(uniqueName);
+            if (suffix == null) {
+                dups.put(uniqueName, 1);
+            } else {
+                dups.put(uniqueName, suffix + 1);
+                StringBuilder builder = new StringBuilder(uniqueName);
+                builder.append("_").append(suffix);
+                uniqueName = builder.toString();
+            }
+            model.uniqueName = uniqueName;
+        }
+        return result;
+    }
+
+    protected Class<?> forName(String className) {
+        return forName(className, classLoader);
+    }
+
+    public static Class<?> forName(String className, ClassLoader classLoader) {
+        Class<?> result;
+        try {
+            // lookup primitive types first
+            result = PRIMITIVE_TYPES.get(className);
+            if (result == null) {
+                result = Class.forName(className, true, classLoader);
+            }
+        } catch (ClassNotFoundException e) {
+            // check if array type
+            if (className.endsWith("[]")) {
+                final int firstDim = className.indexOf('[');
+                final int nDimensions = (className.length() - firstDim) / 2;
+                return Array.newInstance(forName(className.substring(0, firstDim), classLoader), new int[nDimensions]).getClass();
+            }
+            try {
+                // try loading from default Java package java.lang
+                result = Class.forName(JAVA_LANG + className, true, classLoader);
+            } catch (ClassNotFoundException e1) {
+                throw new IllegalArgumentException("Error loading class " + className);
+            }
+        }
+
+        return result;
+    }
+
+    public static final class ApiMethodModel {
+        private final String name;
+        private final Class<?> resultType;
+        private final List<Argument> arguments;
+        private final Method method;
+
+        private String uniqueName;
+
+        protected ApiMethodModel(String name, Class<?> resultType, List<Argument> arguments, Method method) {
+            this.name = name;
+            this.resultType = resultType;
+            this.arguments = arguments;
+            this.method = method;
+        }
+
+        protected ApiMethodModel(String uniqueName, String name, Class<?> resultType, List<Argument> arguments, Method method) {
+            this.name = name;
+            this.uniqueName = uniqueName;
+            this.resultType = resultType;
+            this.arguments = arguments;
+            this.method = method;
+        }
+
+        public String getUniqueName() {
+            return uniqueName;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public Class<?> getResultType() {
+            return resultType;
+        }
+
+        public Method getMethod() {
+            return method;
+        }
+
+        public List<Argument> getArguments() {
+            return arguments;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append(resultType.getName()).append(" ");
+            builder.append(name).append("(");
+            for (Argument argument : arguments) {
+                builder.append(argument.getType().getCanonicalName()).append(" ");
+                builder.append(argument.getName()).append(", ");
+            }
+            if (!arguments.isEmpty()) {
+                builder.delete(builder.length() - 2, builder.length());
+            }
+            builder.append(");");
+            return builder.toString();
+        }
+    }
+
+    public static final class Argument {
+        private final String name;
+        private final Class<?> type;
+
+        protected Argument(String name, Class<?> type) {
+            this.name = name;
+            this.type = type;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public Class<?> getType() {
+            return type;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
+            builder.append(type.getCanonicalName()).append(" ").append(name);
+            return builder.toString();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
new file mode 100644
index 0000000..ea0f442
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodPropertiesHelper.java
@@ -0,0 +1,103 @@
+/**
+ * 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.util.component;
+
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.util.IntrospectionSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Helper class to work with ApiMethod arguments.
+ */
+public final class ApiMethodPropertiesHelper<C> {
+
+    private final Logger LOG = LoggerFactory.getLogger(ApiMethodPropertiesHelper.class);
+
+    // set of field names which are specific to the api, to be excluded from method argument considerations
+    private final Set<String> COMPONENT_CONFIG_FIELDS = new HashSet<String>();
+
+    private final Class<?> componentConfigClass;
+    private final String propertyPrefix;
+
+    public ApiMethodPropertiesHelper(Class<C> componentConfiguration, String propertyPrefix) {
+
+        this.componentConfigClass = componentConfiguration;
+        this.propertyPrefix = propertyPrefix;
+
+        for (Field field : componentConfiguration.getDeclaredFields()) {
+            COMPONENT_CONFIG_FIELDS.add(field.getName());
+        }
+    }
+
+    /**
+     * Gets exchange header properties that start with propertyPrefix.
+     *
+     * @param exchange Camel exchange
+     * @param properties map to collect properties with required prefix
+     */
+    public Map<String, Object> getExchangeProperties(Exchange exchange, Map<String, Object> properties) {
+        final int prefixLength = propertyPrefix.length();
+        int nProperties = 0;
+        for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
+            if (entry.getKey().startsWith(propertyPrefix)) {
+                properties.put(entry.getKey().substring(prefixLength),
+                    entry.getValue());
+                nProperties++;
+            }
+        }
+        LOG.debug("Found {} properties in exchange", nProperties);
+        return properties;
+    }
+
+    public void getEndpointProperties(Object endpointConfiguration,
+                                             Map<String, Object> properties) {
+
+        if (IntrospectionSupport.getProperties(endpointConfiguration, properties, null, false)) {
+            final Set<String> names = properties.keySet();
+            // remove component config properties so we only have endpoint properties
+            names.removeAll(COMPONENT_CONFIG_FIELDS);
+        }
+        if (LOG.isDebugEnabled()) {
+            final Set<String> names = properties.keySet();
+            LOG.debug("Found endpoint properties {}",
+                    names.retainAll(getValidEndpointProperties(endpointConfiguration)));
+        }
+    }
+
+    public Set<String> getEndpointPropertyNames(Object endpointConfiguration) {
+        Map<String, Object> properties = new HashMap<String, Object>();
+        getEndpointProperties(endpointConfiguration, properties);
+        return Collections.unmodifiableSet(properties.keySet());
+    }
+
+    public Set<String> getValidEndpointProperties(Object endpointConfiguration) {
+        Set<String> fields = new HashSet<String>();
+        for (Field field : endpointConfiguration.getClass().getDeclaredFields()) {
+            fields.add(field.getName());
+        }
+        return Collections.unmodifiableSet(fields);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
new file mode 100644
index 0000000..06ab253
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
@@ -0,0 +1,143 @@
+package org.apache.camel.util.component;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Adds support for parameter name substitutions.
+ */
+public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
+
+    private final HashMap<Pattern, Map<Pattern, List<NameReplacement>>> methodMap;
+
+    /**
+     * Create a parser using regular expressions to adapt parameter names.
+     * @param proxyType Proxy class.
+     * @param substitutions an array of <b>ordered</b> Argument adapters.
+     */
+    public ArgumentSubstitutionParser(Class<T> proxyType, Substitution[] substitutions) {
+        super(proxyType);
+        Map<String, Map<String, List<NameReplacement>>> regexMap = new HashMap<String, Map<String, List<NameReplacement>>>();
+
+        for (Substitution tuple : substitutions) {
+            tuple.validate();
+
+            final NameReplacement nameReplacement = new NameReplacement();
+            nameReplacement.replacement = tuple.replacement;
+            if (tuple.argType != null) {
+                nameReplacement.type = forName(tuple.argType);
+            }
+
+            Map<String, List<NameReplacement>> replacementMap = regexMap.get(tuple.method);
+            if (replacementMap == null) {
+                replacementMap = new HashMap<String, List<NameReplacement>>();
+                regexMap.put(tuple.method, replacementMap);
+            }
+            List<NameReplacement> replacements = replacementMap.get(tuple.argName);
+            if (replacements == null) {
+                replacements = new ArrayList<NameReplacement>();
+                replacementMap.put(tuple.argName, replacements);
+            }
+            replacements.add(nameReplacement);
+        }
+
+        // now compile the patterns, all this because Pattern doesn't override equals()!!!
+        this.methodMap = new LinkedHashMap<Pattern, Map<Pattern, List<NameReplacement>>>();
+        for (Map.Entry<String, Map<String, List<NameReplacement>>> method : regexMap.entrySet()) {
+            Map<Pattern, List<NameReplacement>> argMap = new LinkedHashMap<Pattern, List<NameReplacement>>();
+            for (Map.Entry<String, List<NameReplacement>> arg : method.getValue().entrySet()) {
+                argMap.put(Pattern.compile(arg.getKey()), arg.getValue());
+            }
+            methodMap.put(Pattern.compile(method.getKey()), argMap);
+        }
+    }
+
+    @Override
+    public List<ApiMethodModel> parse() {
+        final List<ApiMethodModel> result = new ArrayList<ApiMethodModel>();
+
+        for (ApiMethodModel model : super.parse()) {
+            // look for method name matches
+            for (Map.Entry<Pattern, Map<Pattern, List<NameReplacement>>> methodEntry : methodMap.entrySet()) {
+                if (methodEntry.getKey().matcher(model.getName()).matches()) {
+
+                    // look for arg name matches
+                    final List<Argument> updatedArguments = new ArrayList<Argument>();
+                    final Map<Pattern, List<NameReplacement>> argMap = methodEntry.getValue();
+                    for (Argument argument : model.getArguments()) {
+                        for (Map.Entry<Pattern, List<NameReplacement>> argEntry : argMap.entrySet()) {
+                            final Matcher matcher = argEntry.getKey().matcher(argument.getName());
+                            if (matcher.find()) {
+                                final List<NameReplacement> adapters = argEntry.getValue();
+                                for (NameReplacement adapter : adapters) {
+                                    if (adapter.type == null || adapter.type.isAssignableFrom(argument.getType())) {
+                                        argument = new Argument(matcher.replaceAll(adapter.replacement), argument.getType());
+                                    }
+                                }
+                            }
+                        }
+
+                        updatedArguments.add(argument);
+                    }
+
+                    model = new ApiMethodModel(model.getName(), model.getUniqueName(), model.getResultType(),
+                            updatedArguments, model.getMethod());
+                }
+            }
+
+            result.add(model);
+        }
+
+        return result;
+    }
+
+    public static class Substitution {
+
+        private String method;
+        private String argName;
+        private String argType;
+        private String replacement;
+
+        /**
+         * Creates a substitution for all argument types.
+         * @param method regex to match method name
+         * @param argName regex to match argument name
+         * @param replacement replacement text for argument name
+         */
+        public Substitution(String method, String argName, String replacement) {
+            this.method = method;
+            this.argName = argName;
+            this.replacement = replacement;
+        }
+
+        /**
+         * Creates a substitution for a specific argument type.
+         * @param method regex to match method name
+         * @param argName regex to match argument name
+         * @param argType argument type as String
+         * @param replacement replacement text for argument name
+         */
+        public Substitution(String method, String argName, String argType, String replacement) {
+            this.method = method;
+            this.argName = argName;
+            this.argType = argType;
+            this.replacement = replacement;
+        }
+
+        public void validate() {
+            if (method == null || argName == null || replacement == null) {
+                throw new IllegalArgumentException("Properties method, argName and replacement MUST be provided");
+            }
+        }
+    }
+
+    private static class NameReplacement {
+        private String replacement;
+        private Class<?> type;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
new file mode 100644
index 0000000..f41bc76
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodHelperTest.java
@@ -0,0 +1,169 @@
+/**
+ * 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.util.component;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class ApiMethodHelperTest {
+
+    private static TestMethod[] sayHis = new TestMethod[] { TestMethod.SAYHI, TestMethod.SAYHI_1};
+    private static ApiMethodHelper<TestMethod> apiMethodHelper;
+
+    static {
+        final HashMap<String, String> aliases = new HashMap<String, String>();
+        aliases.put("say(.*)", "$1");
+        apiMethodHelper = new ApiMethodHelper<TestMethod>(TestMethod.class, aliases);
+    }
+
+    @Test
+    public void testGetCandidateMethods() {
+        List<TestMethod> methods = apiMethodHelper.getCandidateMethods("sayHi");
+        assertEquals("Can't find sayHi(*)", 2, methods.size());
+
+        methods = apiMethodHelper.getCandidateMethods("hi");
+        assertEquals("Can't find sayHi(name)", 2, methods.size());
+
+        methods = apiMethodHelper.getCandidateMethods("hi", "name");
+        assertEquals("Can't find sayHi(name)", 1, methods.size());
+
+        methods = apiMethodHelper.getCandidateMethods("greetMe");
+        assertEquals("Can't find greetMe(name)", 1, methods.size());
+
+        methods = apiMethodHelper.getCandidateMethods("greetUs", "name1");
+        assertEquals("Can't find greetUs(name1, name2)", 1, methods.size());
+    }
+
+    @Test
+    public void testFilterMethods() {
+        List<TestMethod> methods = apiMethodHelper.filterMethods(Arrays.asList(sayHis), ApiMethodHelper.MatchType.EXACT);
+        assertEquals("Exact match failed for sayHi()", 1, methods.size());
+        assertEquals("Exact match failed for sayHi()", TestMethod.SAYHI, methods.get(0));
+
+        methods = apiMethodHelper.filterMethods(Arrays.asList(sayHis), ApiMethodHelper.MatchType.SUBSET);
+        assertEquals("Subset match failed for sayHi(*)", 2, methods.size());
+
+        methods = apiMethodHelper.filterMethods(Arrays.asList(sayHis), ApiMethodHelper.MatchType.SUBSET, "name");
+        assertEquals("Subset match failed for sayHi(name)", 1, methods.size());
+        assertEquals("Exact match failed for sayHi()", TestMethod.SAYHI_1, methods.get(0));
+
+        methods = apiMethodHelper.filterMethods(Arrays.asList(sayHis), ApiMethodHelper.MatchType.SUPER_SET, "name");
+        assertEquals("Super set match failed for sayHi(name)", 1, methods.size());
+        assertEquals("Exact match failed for sayHi()", TestMethod.SAYHI_1, methods.get(0));
+
+        methods = apiMethodHelper.filterMethods(Arrays.asList(TestMethod.values()), ApiMethodHelper.MatchType.SUPER_SET, "name");
+        assertEquals("Super set match failed for sayHi(name)", 2, methods.size());
+    }
+
+    @Test
+    public void testGetArguments() {
+        assertEquals("GetArguments failed for hi", 2, apiMethodHelper.getArguments("hi").size());
+        assertEquals("GetArguments failed for greetMe", 2, apiMethodHelper.getArguments("greetMe").size());
+        assertEquals("GetArguments failed for greetUs", 4, apiMethodHelper.getArguments("greetUs").size());
+    }
+
+    @Test
+    public void testGetMissingProperties() throws Exception {
+        assertEquals("Missing properties for hi", 1,
+                apiMethodHelper.getMissingProperties("hi", new HashSet<String>()).size());
+
+        final HashSet<String> argNames = new HashSet<String>();
+        argNames.add("name");
+        assertEquals("Missing properties for greetMe", 0,
+                apiMethodHelper.getMissingProperties("greetMe", argNames).size());
+
+        argNames.clear();
+        argNames.add("name1");
+        assertEquals("Missing properties for greetMe", 1,
+                apiMethodHelper.getMissingProperties("greetUs", argNames).size());
+    }
+
+    @Test
+    public void testAllArguments() throws Exception {
+        assertEquals("Get all arguments", 6, apiMethodHelper.allArguments().size());
+    }
+
+    @Test
+    public void testGetType() throws Exception {
+        assertEquals("Get type name", String.class, apiMethodHelper.getType("name"));
+        assertEquals("Get type name1", String.class, apiMethodHelper.getType("name1"));
+        assertEquals("Get type name2", String.class, apiMethodHelper.getType("name2"));
+    }
+
+    @Test
+    public void testGetHighestPriorityMethod() throws Exception {
+        assertEquals("Get highest priority method",
+                TestMethod.SAYHI_1, apiMethodHelper.getHighestPriorityMethod(Arrays.asList(sayHis)));
+    }
+
+    @Test
+    public void testInvokeMethod() throws Exception {
+        TestProxy proxy = new TestProxy();
+        assertEquals("sayHi()", "Hello!", apiMethodHelper.invokeMethod(proxy, TestMethod.SAYHI, Collections.EMPTY_MAP));
+
+        final HashMap<String, Object> properties = new HashMap<String, Object>();
+        properties.put("name", "Dave");
+
+        assertEquals("sayHi(name)", "Hello Dave", apiMethodHelper.invokeMethod(proxy, TestMethod.SAYHI_1, properties));
+        assertEquals("greetMe(name)", "Greetings Dave", apiMethodHelper.invokeMethod(proxy, TestMethod.GREETME, properties));
+
+        properties.clear();
+        properties.put("name1", "Dave");
+        properties.put("name2", "Frank");
+        assertEquals("greetUs(name1, name2)", "Greetings Dave, Frank", apiMethodHelper.invokeMethod(proxy, TestMethod.GREETUS, properties));
+    }
+
+    static enum TestMethod implements ApiMethod {
+
+        SAYHI(String.class, "sayHi"),
+        SAYHI_1(String.class, "sayHi", String.class, "name"),
+        GREETME(String.class, "greetMe", String.class, "name"),
+        GREETUS(String.class, "greetUs", String.class, "name1", String.class, "name2"),
+        GREETALL(String.class, "greetAll", new String[0].getClass(), "names"),
+        GREETALL_1(String.class, "greetAll", List.class, "nameList"),
+        GREETTIMES(new String[0].getClass(), "greetTimes", String.class, "name", int.class, "times");
+
+        private final ApiMethod apiMethod;
+
+        private TestMethod(Class<?> resultType, String name, Object... args) {
+            this.apiMethod = new ApiMethodImpl(TestProxy.class, resultType, name, args);
+        }
+
+        @Override
+        public String getName() { return apiMethod.getName(); }
+
+        @Override
+        public Class<?> getResultType() { return apiMethod.getResultType(); }
+
+        @Override
+        public List<String> getArgNames() { return apiMethod.getArgNames(); }
+
+        @Override
+        public List<Class<?>> getArgTypes() { return apiMethod.getArgTypes(); }
+
+        @Override
+        public Method getMethod() { return apiMethod.getMethod(); }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
new file mode 100644
index 0000000..c711c5f
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/component/ApiMethodPropertiesHelperTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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.util.component;
+
+import java.util.HashMap;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+public class ApiMethodPropertiesHelperTest {
+
+    private static final String TEST_PREFIX = "TestComponent.";
+
+    private static final String PROPERTY_1 = TEST_PREFIX + "property1";
+    private static final String PROPERTY_2 = TEST_PREFIX + "property2";
+    private static final String PROPERTY_3 = TEST_PREFIX + "property3";
+    private static final String PROPERTY_4 = TEST_PREFIX + "property4";
+
+    private static final String VALUE_1 = "value1";
+    private static final long VALUE_2 = 2;
+    private static final String VALUE_3 = "value3";
+    private static final String VALUE_4 = "true";
+
+    private static ApiMethodPropertiesHelper propertiesHelper =
+            new ApiMethodPropertiesHelper(TestComponentConfiguration.class, TEST_PREFIX);
+
+    @Test
+    public void testGetExchangeProperties() throws Exception {
+        final HashMap<String, Object> properties = new HashMap<String, Object>();
+        final DefaultExchange exchange = new DefaultExchange(new MockEndpoint());
+        exchange.getIn().setHeader(PROPERTY_1, VALUE_1);
+        exchange.getIn().setHeader(PROPERTY_2, VALUE_2);
+        exchange.getIn().setHeader(PROPERTY_3, VALUE_3);
+        exchange.getIn().setHeader(PROPERTY_4, VALUE_4);
+        propertiesHelper.getExchangeProperties(exchange, properties);
+        assertEquals(4, properties.size());
+    }
+
+    @Test
+    public void testGetEndpointProperties() throws Exception {
+        final HashMap<String, Object> properties = new HashMap<String, Object>();
+        final TestEndpointConfiguration endpointConfiguration = new TestEndpointConfiguration();
+        endpointConfiguration.setProperty1(VALUE_1);
+        endpointConfiguration.setProperty2(VALUE_2);
+        endpointConfiguration.setProperty3(VALUE_3);
+        endpointConfiguration.setProperty4(Boolean.valueOf(VALUE_4));
+        propertiesHelper.getEndpointProperties(endpointConfiguration, properties);
+        assertEquals(2, properties.size());
+    }
+
+    @Test
+    public void testGetEndpointPropertyNames() throws Exception {
+        final TestEndpointConfiguration endpointConfiguration = new TestEndpointConfiguration();
+        endpointConfiguration.setProperty1(VALUE_1);
+        endpointConfiguration.setProperty4(Boolean.valueOf(VALUE_4));
+        assertEquals(1, propertiesHelper.getEndpointPropertyNames(endpointConfiguration).size());
+    }
+
+    @Test
+    public void testGetValidEndpointProperties() throws Exception {
+        assertEquals(2, propertiesHelper.getValidEndpointProperties(new TestEndpointConfiguration()).size());
+    }
+
+    private static class TestComponentConfiguration {
+        private String property1;
+        private Long property2;
+
+        public String getProperty1() {
+            return property1;
+        }
+
+        public void setProperty1(String property1) {
+            this.property1 = property1;
+        }
+
+        public long getProperty2() {
+            return property2;
+        }
+
+        public void setProperty2(Long property2) {
+            this.property2 = property2;
+        }
+    }
+
+    private static class TestEndpointConfiguration extends TestComponentConfiguration {
+        private String property3;
+        private Boolean property4;
+
+        public String getProperty3() {
+            return property3;
+        }
+
+        public void setProperty3(String property3) {
+            this.property3 = property3;
+        }
+
+        public Boolean getProperty4() {
+            return property4;
+        }
+
+        public void setProperty4(Boolean property4) {
+            this.property4 = property4;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java b/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
new file mode 100644
index 0000000..ce0153d
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/component/ArgumentSubstitutionParserTest.java
@@ -0,0 +1,52 @@
+package org.apache.camel.util.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import static org.apache.camel.util.component.ArgumentSubstitutionParser.*;
+import static org.junit.Assert.assertEquals;
+
+public class ArgumentSubstitutionParserTest {
+
+    private static final String PERSON = "person";
+
+    @Test
+    public void testParse() throws Exception {
+
+        final Substitution[] adapters = new Substitution[3];
+        adapters[0] = new Substitution(".+", "name", PERSON);
+        adapters[1] = new Substitution("greet.+", "person([0-9]+)", "astronaut$1");
+        adapters[2] = new Substitution(".+", "(.+)", "java.util.List", "$1List");
+
+        final ApiMethodParser<TestProxy> parser = new ArgumentSubstitutionParser<TestProxy>(TestProxy.class, adapters);
+
+        final ArrayList<String> signatures = new ArrayList<String>();
+        signatures.add("public String sayHi();");
+        signatures.add("public String sayHi(final String name);");
+        signatures.add("public final String greetMe(final String name);");
+        signatures.add("public final String greetUs(final String name1, String name2);");
+        signatures.add("public final String greetAll(String[] names);");
+        signatures.add("public final String greetAll(java.util.List<String> names);");
+        signatures.add("public final String[] greetTimes(String name, int times);");
+        parser.setSignatures(signatures);
+
+        final List<ApiMethodParser.ApiMethodModel> methodModels = parser.parse();
+        assertEquals(7, methodModels.size());
+
+        final ApiMethodParser.ApiMethodModel sayHi1 = methodModels.get(6);
+        assertEquals(PERSON, sayHi1.getArguments().get(0).getName());
+        assertEquals("SAYHI_1", sayHi1.getUniqueName());
+
+        final ApiMethodParser.ApiMethodModel greetMe = methodModels.get(2);
+        assertEquals(PERSON, greetMe.getArguments().get(0).getName());
+
+        final ApiMethodParser.ApiMethodModel greetUs = methodModels.get(4);
+        assertEquals("astronaut1", greetUs.getArguments().get(0).getName());
+        assertEquals("astronaut2", greetUs.getArguments().get(1).getName());
+
+        final ApiMethodParser.ApiMethodModel greetAll = methodModels.get(1);
+        assertEquals("personsList", greetAll.getArguments().get(0).getName());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/10a0b615/camel-core/src/test/java/org/apache/camel/util/component/TestProxy.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/component/TestProxy.java b/camel-core/src/test/java/org/apache/camel/util/component/TestProxy.java
new file mode 100644
index 0000000..d707eb8
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/component/TestProxy.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.util.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class TestProxy {
+    public String sayHi() {
+        return "Hello!";
+    }
+
+    public String sayHi(final String name) {
+        return "Hello " + name;
+    }
+
+    public final String greetMe(final String name) {
+        return "Greetings " + name;
+    }
+
+    public final String greetUs(final String name1, String name2) {
+        return "Greetings " + name1 + ", " + name2;
+    }
+
+    public final String greetAll(final String[] names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String greetAll(List<String> names) {
+        StringBuilder builder = new StringBuilder("Greetings ");
+        for (String name : names) {
+            builder.append(name).append(", ");
+        }
+        builder.delete(builder.length() - 2, builder.length());
+        return builder.toString();
+    }
+
+    public final String[] greetTimes(String name, int times) {
+        final List<String> result = new ArrayList<String>();
+        for (int i = 0; i < times; i++) {
+            result.add("Greetings " + name);
+        }
+        return result.toArray(new String[result.size()]);
+    }
+}


[14/35] git commit: Added argument name and type uniqueness check

Posted by dh...@apache.org.
Added argument name and type uniqueness check


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

Branch: refs/heads/master
Commit: 32677ffe8291c698b7caa745212a765048a64de4
Parents: ec5a57e
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:20:13 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:31 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ApiMethodParser.java   | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/32677ffe/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
index 0e839df..933a0b9 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodParser.java
@@ -124,8 +124,29 @@ public abstract class ApiMethodParser<T> {
             result.add(new ApiMethodModel(name, resultType, arguments, method));
         }
 
+        // allow derived classes to post process
         result = processResults(result);
 
+        // check that argument names have the same type across methods
+        Map<String, Class<?>> allArguments = new HashMap<String, Class<?>>();
+        for (ApiMethodModel model : result) {
+            for (Argument argument : model.getArguments()) {
+                String name = argument.getName();
+                Class<?> argClass = allArguments.get(name);
+                Class<?> type = argument.getType();
+                if (argClass == null) {
+                    allArguments.put(name, type);
+                } else {
+                    if (argClass != type) {
+                        throw new IllegalArgumentException("Argument [" + name +
+                                "] is used in multiple methods with different types " +
+                                argClass.getCanonicalName() + ", " + type.getCanonicalName());
+                    }
+                }
+            }
+        }
+        allArguments.clear();
+
         Collections.sort(result, new Comparator<ApiMethodModel>() {
             @Override
             public int compare(ApiMethodModel model1, ApiMethodModel model2) {


[06/35] git commit: Fixed argument substituion check to use exact type match

Posted by dh...@apache.org.
Fixed argument substituion check to use exact type match


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

Branch: refs/heads/master
Commit: ace29c891d5ae8eff7708f713ebdedd49a4733e1
Parents: 0932ed4
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Wed May 28 14:19:08 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:30 2014 -0700

----------------------------------------------------------------------
 .../apache/camel/util/component/ArgumentSubstitutionParser.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ace29c89/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
index 43f60e9..0ebf63c 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
@@ -74,7 +74,7 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
                             if (matcher.find()) {
                                 final List<NameReplacement> adapters = argEntry.getValue();
                                 for (NameReplacement adapter : adapters) {
-                                    if (adapter.type == null || adapter.type.isAssignableFrom(argument.getType())) {
+                                    if (adapter.type == null || adapter.type == argument.getType()) {
                                         argument = new Argument(matcher.replaceAll(adapter.replacement), argument.getType());
                                     }
                                 }


[04/35] git commit: Fixed substitution order in ArgumentSubstitutionParser

Posted by dh...@apache.org.
Fixed substitution order in ArgumentSubstitutionParser


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

Branch: refs/heads/master
Commit: 2ffeacc0217a21a4c883e367f58a8a709219cf79
Parents: 10a0b61
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Fri May 23 17:47:51 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 10 12:48:29 2014 -0700

----------------------------------------------------------------------
 .../camel/util/component/ArgumentSubstitutionParser.java    | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2ffeacc0/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
index 06ab253..0e15833 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ArgumentSubstitutionParser.java
@@ -1,7 +1,6 @@
 package org.apache.camel.util.component;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -13,7 +12,7 @@ import java.util.regex.Pattern;
  */
 public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
 
-    private final HashMap<Pattern, Map<Pattern, List<NameReplacement>>> methodMap;
+    private final Map<Pattern, Map<Pattern, List<NameReplacement>>> methodMap;
 
     /**
      * Create a parser using regular expressions to adapt parameter names.
@@ -22,7 +21,7 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
      */
     public ArgumentSubstitutionParser(Class<T> proxyType, Substitution[] substitutions) {
         super(proxyType);
-        Map<String, Map<String, List<NameReplacement>>> regexMap = new HashMap<String, Map<String, List<NameReplacement>>>();
+        Map<String, Map<String, List<NameReplacement>>> regexMap = new LinkedHashMap<String, Map<String, List<NameReplacement>>>();
 
         for (Substitution tuple : substitutions) {
             tuple.validate();
@@ -35,7 +34,7 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
 
             Map<String, List<NameReplacement>> replacementMap = regexMap.get(tuple.method);
             if (replacementMap == null) {
-                replacementMap = new HashMap<String, List<NameReplacement>>();
+                replacementMap = new LinkedHashMap<String, List<NameReplacement>>();
                 regexMap.put(tuple.method, replacementMap);
             }
             List<NameReplacement> replacements = replacementMap.get(tuple.argName);
@@ -85,7 +84,7 @@ public class ArgumentSubstitutionParser<T> extends ApiMethodParser<T> {
                         updatedArguments.add(argument);
                     }
 
-                    model = new ApiMethodModel(model.getName(), model.getUniqueName(), model.getResultType(),
+                    model = new ApiMethodModel(model.getUniqueName(), model.getName(), model.getResultType(),
                             updatedArguments, model.getMethod());
                 }
             }