You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/09/19 17:43:48 UTC
[camel] branch master updated: CAMEL-15478: Fix api component
archetype
This is an automated email from the ASF dual-hosted git repository.
janbednar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new d13fa8b CAMEL-15478: Fix api component archetype
d13fa8b is described below
commit d13fa8b7dde8216555af7f75b172845283670088
Author: bedlaj <ma...@janbednar.eu>
AuthorDate: Sat Sep 19 19:27:15 2020 +0200
CAMEL-15478: Fix api component archetype
---
.../archetype-resources/__artifactId__-api/pom.xml | 17 +++++-
.../{__name__FileHello.java => __name__Hello.java} | 4 +-
.../src/main/java/api/__name__JavadocHello.java | 35 ------------
.../__artifactId__-component/pom.xml | 65 ++++------------------
.../src/main/java/__name__Configuration.java | 46 ++++++++++++++-
.../src/main/java/__name__Endpoint.java | 10 +---
.../projects/build-it/archetype.properties | 4 +-
7 files changed, 79 insertions(+), 102 deletions(-)
diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
index 3df8e61..11ebc54 100644
--- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
+++ b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/pom.xml
@@ -38,7 +38,22 @@
<defaultGoal>install</defaultGoal>
<plugins>
-
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <classifier>sources</classifier>
+ </configuration>
+ </plugin>
+
<!-- to generate API Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__FileHello.java b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__Hello.java
similarity index 95%
rename from archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__FileHello.java
rename to archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__Hello.java
index 8f509df..a8a8714 100644
--- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__FileHello.java
+++ b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__Hello.java
@@ -17,9 +17,9 @@
package ${package}.api;
/**
- * Sample API used by ${name} Component whose method signatures are read from File.
+ * Sample API used by ${name} Component whose method signatures are read from Java source.
*/
-public class ${name}FileHello {
+public class ${name}Hello {
public String sayHi() {
return "Hello!";
diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__JavadocHello.java b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__JavadocHello.java
deleted file mode 100644
index 0b983a0..0000000
--- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-api/src/main/java/api/__name__JavadocHello.java
+++ /dev/null
@@ -1,35 +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}.api;
-
-/**
- * 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;
- }
-
- public String greetUs(String name1, String name2) {
- return "Hello " + name1 + ", " + name2;
- }
-}
diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
index 251e912..519ef25 100644
--- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
+++ b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/pom.xml
@@ -112,60 +112,9 @@
<configuration>
<apis>
<api>
- <apiName>hello-file</apiName>
- <proxyClass>${package}.api.${name}FileHello</proxyClass>
- <fromSignatureFile>signatures/file-sig-api.txt</fromSignatureFile>
- <!-- Use substitutions to manipulate parameter names and avoid name clashes
- <substitutions>
- <substitution>
- <method>^(.+)$</method>
- <argName>^(.+)$</argName>
- <argType>java.lang.String</argType>
- <replacement>$1Param</replacement>
- <replaceWithType>false</replaceWithType>
- </substitution>
- </substitutions>
- -->
- <!-- Exclude automatically generated endpoint options by name
- <excludeConfigNames>name-pattern<excludeConfigNames>
- -->
- <!-- Exclude automatically generated endpoint options by type
- <excludeConfigTypes>type-pattern<excludeConfigTypes>
- -->
- <!-- Add custom endpoint options to generated EndpointConfiguration class for this API
- <extraOptions>
- <extraOption>
- <type>java.util.List<String></type>
- <name>customOption</name>
- </extraOption>
- </extraOptions>
- -->
- <!-- Use method aliases in endpoint URIs, e.g. support 'widget' as alias for getWidget or setWidget
- <aliases>
- <alias>
- <methodPattern>[gs]et(.+)</methodPattern>
- <methodAlias>$1</methodAlias>
- </alias>
- </aliases>
- -->
- <!-- for some methods, null can be a valid input
- <nullableOptions>
- <nullableOption>option-name</nullableOption>
- </nullableOptions>
- -->
- </api>
- <api>
- <apiName>hello-javadoc</apiName>
- <proxyClass>${package}.api.${name}JavadocHello</proxyClass>
- <fromJavadoc>
- <!-- Use exclude patterns to limit what gets exposed in component endpoint
- <excludePackages>package-name-patterns</excludePackages>
- <excludeClasses>class-name-patterns</excludeClasses>
- <includeMethods>method-name-patterns</includeMethods>
- <excludeMethods>method-name-patterns</excludeMethods>
- <includeStaticMethods>use 'true' to include static methods, false by default<includeStaticMethods>
- -->
- </fromJavadoc>
+ <apiName>hello</apiName>
+ <proxyClass>${package}.api.${name}Hello</proxyClass>
+ <fromJavasource />
</api>
</apis>
<!-- Specify global values for all APIs here, these are overridden at API level
@@ -180,6 +129,14 @@
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}-api</artifactId>
+ <version>${version}</version>
+ <classifier>sources</classifier>
+ </dependency>
+ </dependencies>
</plugin>
<!-- generate camel meta-data -->
diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java
index ba168ea..8f6f010 100644
--- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java
+++ b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Configuration.java
@@ -16,10 +16,54 @@
## ------------------------------------------------------------------------
package ${package};
+import org.apache.camel.spi.Configurer;
+import org.apache.camel.spi.ApiMethod;
+import org.apache.camel.spi.ApiParam;
+import org.apache.camel.spi.ApiParams;
+import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
+@ApiParams(apiName = "DEFAULT", description = "This is greeter",
+ apiMethods = {
+ @ApiMethod(methodName = "greetMe", signatures={"String greetMe(String name)"}),
+ @ApiMethod(methodName = "greetUs", signatures={"String greetUs(String name1, String name2)"}),
+ @ApiMethod(methodName = "sayHi", signatures={"String greetHi()"})},
+ aliases = {})
@UriParams
+@Configurer
public class ${name}Configuration {
- // TODO add component configuration properties
+ @ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = "greetMe")})
+ private String name;
+
+ @ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = "greetUs")})
+ private String name1;
+
+ @ApiParam(optional = false, apiMethods = {@ApiMethod(methodName = "greetUs")})
+ private String name2;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName1() {
+ return name1;
+ }
+
+ public void setName1(String name1) {
+ this.name1 = name1;
+ }
+
+ public String getName2() {
+ return name2;
+ }
+
+ public void setName2(String name2) {
+ this.name2 = name2;
+ }
+
}
diff --git a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
index fd9c83e..4204cf9 100644
--- a/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
+++ b/archetypes/camel-archetype-api-component/src/main/resources/archetype-resources/__artifactId__-component/src/main/java/__name__Endpoint.java
@@ -28,8 +28,7 @@ import org.apache.camel.support.component.AbstractApiEndpoint;
import org.apache.camel.support.component.ApiMethod;
import org.apache.camel.support.component.ApiMethodPropertiesHelper;
-import ${package}.api.${name}FileHello;
-import ${package}.api.${name}JavadocHello;
+import ${package}.api.${name}Hello;
import ${package}.internal.${name}ApiCollection;
import ${package}.internal.${name}ApiName;
import ${package}.internal.${name}Constants;
@@ -83,11 +82,8 @@ public class ${name}Endpoint extends AbstractApiEndpoint<${name}ApiName, ${name}
protected void afterConfigureProperties() {
// TODO create API proxy, set connection properties, etc.
switch (apiName) {
- case HELLO_FILE:
- apiProxy = new ${name}FileHello();
- break;
- case HELLO_JAVADOC:
- apiProxy = new ${name}JavadocHello();
+ case HELLO:
+ apiProxy = new ${name}Hello();
break;
default:
throw new IllegalArgumentException("Invalid API name " + apiName);
diff --git a/archetypes/camel-archetype-api-component/src/test/resources/projects/build-it/archetype.properties b/archetypes/camel-archetype-api-component/src/test/resources/projects/build-it/archetype.properties
index dcc90e1..4944434 100644
--- a/archetypes/camel-archetype-api-component/src/test/resources/projects/build-it/archetype.properties
+++ b/archetypes/camel-archetype-api-component/src/test/resources/projects/build-it/archetype.properties
@@ -14,10 +14,10 @@
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
-groupId=org.apache.camel.archetypes.archetypeIT.camel-archetype-api-component
+groupId=com.example
artifactId=build-it
version=0.0.1
-package=org.apache.camel.archetypes.archetypeIT
+package=com.example
name=Dummy
scheme=dummy