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:52:02 UTC
[34/35] git commit: Renamed component-util plugin to api-component
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(" ", " ").replaceAll(" ", " ");
+ 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);
+ }
+}