You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/09/01 14:19:21 UTC
[camel] 01/10: CAMEL-15478: API components tooling that generates
configuration classes should add apiName to @UriParams so we would know
which api method the configuration belongs to.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7301503f4fa2e94a7f983e24626c78bdf1b0130d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 1 11:07:23 2020 +0200
CAMEL-15478: API components tooling that generates configuration classes should add apiName to @UriParams so we would know which api method the configuration belongs to.
---
.../camel-api/src/generated/java/org/apache/camel/spi/UriParams.java | 5 +++++
.../java/org/apache/camel/maven/AbstractApiMethodGeneratorMojo.java | 4 ++++
.../main/java/org/apache/camel/maven/ApiComponentGeneratorMojo.java | 1 +
.../src/main/resources/api-endpoint-config.vm | 2 +-
.../src/main/java/org/apache/camel/spi/UriParams.java | 5 +++++
5 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/core/camel-api/src/generated/java/org/apache/camel/spi/UriParams.java b/core/camel-api/src/generated/java/org/apache/camel/spi/UriParams.java
index 0ffadd2..d3dc5af 100644
--- a/core/camel-api/src/generated/java/org/apache/camel/spi/UriParams.java
+++ b/core/camel-api/src/generated/java/org/apache/camel/spi/UriParams.java
@@ -36,4 +36,9 @@ public @interface UriParams {
*/
String prefix() default "";
+ /**
+ * The API name for API based components where configurations are separated by API names (grouping).
+ */
+ String apiName() default "";
+
}
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
index 0fd0974..9aa035d 100644
--- 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
@@ -47,6 +47,9 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractApiMethodBa
@Parameter
protected String classPrefix;
+ @Parameter
+ protected String apiName;
+
// cached fields
private Class<?> proxyType;
@@ -172,6 +175,7 @@ public abstract class AbstractApiMethodGeneratorMojo extends AbstractApiMethodBa
private VelocityContext getEndpointContext(List<ApiMethodParser.ApiMethodModel> models) throws MojoExecutionException {
VelocityContext context = getCommonContext(models);
+ context.put("apiName", apiName);
context.put("configName", getConfigName());
context.put("componentName", componentName);
context.put("componentPackage", componentPackage);
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
index ad4f1f4..df3160c 100644
--- 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
@@ -151,6 +151,7 @@ public class ApiComponentGeneratorMojo extends AbstractApiMethodBaseMojo {
// set AbstractAPIMethodGeneratorMojo properties
mojo.proxyClass = apiProxy.getProxyClass();
mojo.classPrefix = apiProxy.getClassPrefix();
+ mojo.apiName = apiProxy.getApiName();
}
private AbstractApiMethodGeneratorMojo getApiMethodGenerator(ApiProxy api) {
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
index d0f6403..47acf03 100644
--- 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
@@ -43,7 +43,7 @@ import org.apache.camel.spi.UriParams;
/**
* Camel EndpointConfiguration for $proxyType.Name
*/
-@UriParams
+@UriParams(apiName = "$apiName")
@Configurer
public final class $configName extends ${componentName}Configuration {
#foreach( $parameter in $parameters.entrySet() )
diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParams.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParams.java
index 0ffadd2..d3dc5af 100644
--- a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParams.java
+++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParams.java
@@ -36,4 +36,9 @@ public @interface UriParams {
*/
String prefix() default "";
+ /**
+ * The API name for API based components where configurations are separated by API names (grouping).
+ */
+ String apiName() default "";
+
}