This is an automated email from the ASF dual-hosted git repository.
oalsafi 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 3aa9f2b CAMEL-14801: Add Category field support to @UriEndpoint
(#3832)
3aa9f2b is described below
commit 3aa9f2b08d2b72deffcc077e7e94b3554995983e
Author: Omar Al-Safi <[email protected]>
AuthorDate: Mon May 18 17:47:07 2020 +0200
CAMEL-14801: Add Category field support to @UriEndpoint (#3832)
* CAMEL-14801: Initial Category enum
* CAMEL-14801: Add all categories
* CAMEL-14801: Add the maven modifications and add it in azure queue
component
---
.../azure/storage/queue/QueueEndpoint.java | 3 +-
.../generated/java/org/apache/camel/Category.java | 127 +++++++++++++++++++++
.../java/org/apache/camel/spi/UriEndpoint.java | 15 +++
.../packaging/EndpointSchemaGeneratorMojo.java | 11 +-
.../src/main/java/org/apache/camel/Category.java | 127 +++++++++++++++++++++
.../java/org/apache/camel/spi/UriEndpoint.java | 15 +++
6 files changed, 296 insertions(+), 2 deletions(-)
diff --git
a/components/camel-azure-storage-queue/src/main/java/org/apache/camel/component/azure/storage/queue/QueueEndpoint.java
b/components/camel-azure-storage-queue/src/main/java/org/apache/camel/component/azure/storage/queue/QueueEndpoint.java
index ab37e23..fd53099 100644
---
a/components/camel-azure-storage-queue/src/main/java/org/apache/camel/component/azure/storage/queue/QueueEndpoint.java
+++
b/components/camel-azure-storage-queue/src/main/java/org/apache/camel/component/azure/storage/queue/QueueEndpoint.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.azure.storage.queue;
import com.azure.storage.queue.QueueServiceClient;
import com.azure.storage.queue.models.QueueMessageItem;
+import org.apache.camel.Category;
import org.apache.camel.Component;
import org.apache.camel.Consumer;
import org.apache.camel.Exchange;
@@ -33,7 +34,7 @@ import org.apache.camel.util.ObjectHelper;
/**
* The azure-storage-queue component is used for storing and retrieving the
messages to/from Azure Storage Queue using Azure SDK v12.
*/
-@UriEndpoint(firstVersion = "3.3.0", scheme = "azure-storage-queue", title =
"Azure Storage Queue Service", syntax = "azure-storage-queue:queueName", label
= "cloud,messaging")
+@UriEndpoint(firstVersion = "3.3.0", scheme = "azure-storage-queue", title =
"Azure Storage Queue Service", syntax = "azure-storage-queue:queueName",
category = {Category.CLOUD, Category.MESSAGING})
public class QueueEndpoint extends DefaultEndpoint {
private QueueServiceClient queueServiceClient;
diff --git a/core/camel-api/src/generated/java/org/apache/camel/Category.java
b/core/camel-api/src/generated/java/org/apache/camel/Category.java
new file mode 100644
index 0000000..955913a
--- /dev/null
+++ b/core/camel-api/src/generated/java/org/apache/camel/Category.java
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+/**
+ * This enum set various categories options into the UriEndpoint.
+ * This can be extended.
+ */
+public enum Category {
+ DATAMINING("datamining"),
+ AI("ai"),
+ API("api"),
+ AZURE("azure"),
+ BATCH("batch"),
+ BIGDATA("bigdata"),
+ BITCOIN("bitcoin"),
+ BLOCKCHAIN("blockchain"),
+ CACHE("cache"),
+ CHAT("chat"),
+ CHATSCRIPT("chatscript"),
+ CLOUD("cloud"),
+ CLUSTERING("clustering"),
+ CMS("cms"),
+ COMPUTE("compute"),
+ COMPUTING("computing"),
+ CONTAINER("container"),
+ CORDA("corda"),
+ CORE("core"),
+ CRM("crm"),
+ DATA("data"),
+ DATABASE("database"),
+ DATAGRID("datagrid"),
+ DEEPLEARNING("deeplearning"),
+ DEPLOYMENT("deployment"),
+ DOCUMENT("document"),
+ ENDPOINT("endpoint"),
+ ENGINE("engine"),
+ EVENTBUS("eventbus"),
+ FILE("file"),
+ HADOOP("hadoop"),
+ HCM("hcm"),
+ HL7("hl7"),
+ HTTP("http"),
+ IOT("iot"),
+ IPFS("ipfs"),
+ JAVA("java"),
+ LDAP("ldap"),
+ LEDGER("ledger"),
+ LOCATION("location"),
+ LOG("log"),
+ MAIL("mail"),
+ MANAGEMENT("management"),
+ MESSAGING("messaging"),
+ MLLP("mllp"),
+ MOBILE("mobile"),
+ MONGODB("mongodb"),
+ MONITORING("monitoring"),
+ MYSQL("mysql"),
+ NETWORKING("networking"),
+ NOSQL("nosql"),
+ OPENAPI("openapi"),
+ PAAS("paas"),
+ PAYMENT("payment"),
+ PLANNING("planning"),
+ POSTGRES("postgres"),
+ PRINTING("printing"),
+ PROCESS("process"),
+ QUEUE("queue"),
+ REACTIVE("reactive"),
+ REPORTING("reporting"),
+ REST("rest"),
+ RPC("rpc"),
+ RSS("rss"),
+ SAP("sap"),
+ SCHEDULING("scheduling"),
+ SCRIPT("script"),
+ SEARCH("search"),
+ SECURITY("security"),
+ SERVERLESS("serverless"),
+ SHEETS("sheets"),
+ SOAP("soap"),
+ SOCIAL("social"),
+ SPRING("spring"),
+ SQL("sql"),
+ SQLSERVER("sqlserver"),
+ STREAMS("streams"),
+ SUPPORT("support"),
+ SWAGGER("swagger"),
+ SYSTEM("system"),
+ TCP("tcp"),
+ TESTING("testing"),
+ TRANSFORMATION("transformation"),
+ UDP("udp"),
+ VALIDATION("validation"),
+ VOIP("voip"),
+ WEBSERVICE("webservice"),
+ WEBSOCKET("websocket"),
+ WORKFLOW("workflow");
+
+ private final String value;
+
+ Category(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Returns the string representation of this value
+ * @return Returns the string representation of this value
+ */
+ public String getValue() {
+ return this.value;
+ }
+}
diff --git
a/core/camel-api/src/generated/java/org/apache/camel/spi/UriEndpoint.java
b/core/camel-api/src/generated/java/org/apache/camel/spi/UriEndpoint.java
index ea2bc60..8ba07ac 100644
--- a/core/camel-api/src/generated/java/org/apache/camel/spi/UriEndpoint.java
+++ b/core/camel-api/src/generated/java/org/apache/camel/spi/UriEndpoint.java
@@ -22,6 +22,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.apache.camel.Category;
+
/**
* Represents an annotated Camel <a
href="http://camel.apache.org/endpoint.html">Endpoint</a>
* which can have its properties (and the properties on its consumer) injected
from the
@@ -115,10 +117,23 @@ public @interface UriEndpoint {
* Multiple labels can be defined as a comma separated value.
* <p/>
* The labels is intended for grouping the endpoints, such as
<tt>core</tt>, <tt>file</tt>, <tt>messaging</tt>, <tt>database</tt>, etc.
+ * <p/>
+ * Deprecated: Use the category field instead
*/
+ @Deprecated
String label() default "";
/**
+ * To associate this endpoint with category(ies).
+ * <p/>
+ * This category is intended for grouping the endpoints, such as
<tt>Category.CORE</tt>, <tt>Category.FILE</tt>, <tt>Category.DATABASE</tt>,
etc, but supplied with
+ * as array of {@link Category} enums.
+ * </p>
+ * For example: @UriEndpoint(category = {Category.CORE, Category.DATABASE})
+ */
+ Category[] category() default {};
+
+ /**
* Whether this endpoint can only be used as a producer.
* <p/>
* By default its assumed the endpoint can be used as both consumer and
producer.
diff --git
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
index b64ca84..793d332 100644
---
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
+++
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointSchemaGeneratorMojo.java
@@ -47,6 +47,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.apache.camel.Category;
import org.apache.camel.maven.packaging.generics.ClassUtil;
import org.apache.camel.maven.packaging.generics.GenericsUtil;
import org.apache.camel.spi.Metadata;
@@ -149,7 +150,15 @@ public class EndpointSchemaGeneratorMojo extends
AbstractGeneratorMojo {
String scheme = uriEndpoint.scheme();
String extendsScheme = uriEndpoint.extendsScheme();
String title = uriEndpoint.title();
- final String label = uriEndpoint.label();
+ Category[] categories = uriEndpoint.category();
+ String label;
+ if (categories.length > 0) {
+ label = Arrays.stream(categories)
+ .map(Category::getValue)
+ .collect(Collectors.joining(","));
+ } else {
+ label = uriEndpoint.label();
+ }
validateSchemaName(scheme, classElement);
// support multiple schemes separated by comma, which maps to
// the exact same component
diff --git
a/tooling/spi-annotations/src/main/java/org/apache/camel/Category.java
b/tooling/spi-annotations/src/main/java/org/apache/camel/Category.java
new file mode 100644
index 0000000..955913a
--- /dev/null
+++ b/tooling/spi-annotations/src/main/java/org/apache/camel/Category.java
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+/**
+ * This enum set various categories options into the UriEndpoint.
+ * This can be extended.
+ */
+public enum Category {
+ DATAMINING("datamining"),
+ AI("ai"),
+ API("api"),
+ AZURE("azure"),
+ BATCH("batch"),
+ BIGDATA("bigdata"),
+ BITCOIN("bitcoin"),
+ BLOCKCHAIN("blockchain"),
+ CACHE("cache"),
+ CHAT("chat"),
+ CHATSCRIPT("chatscript"),
+ CLOUD("cloud"),
+ CLUSTERING("clustering"),
+ CMS("cms"),
+ COMPUTE("compute"),
+ COMPUTING("computing"),
+ CONTAINER("container"),
+ CORDA("corda"),
+ CORE("core"),
+ CRM("crm"),
+ DATA("data"),
+ DATABASE("database"),
+ DATAGRID("datagrid"),
+ DEEPLEARNING("deeplearning"),
+ DEPLOYMENT("deployment"),
+ DOCUMENT("document"),
+ ENDPOINT("endpoint"),
+ ENGINE("engine"),
+ EVENTBUS("eventbus"),
+ FILE("file"),
+ HADOOP("hadoop"),
+ HCM("hcm"),
+ HL7("hl7"),
+ HTTP("http"),
+ IOT("iot"),
+ IPFS("ipfs"),
+ JAVA("java"),
+ LDAP("ldap"),
+ LEDGER("ledger"),
+ LOCATION("location"),
+ LOG("log"),
+ MAIL("mail"),
+ MANAGEMENT("management"),
+ MESSAGING("messaging"),
+ MLLP("mllp"),
+ MOBILE("mobile"),
+ MONGODB("mongodb"),
+ MONITORING("monitoring"),
+ MYSQL("mysql"),
+ NETWORKING("networking"),
+ NOSQL("nosql"),
+ OPENAPI("openapi"),
+ PAAS("paas"),
+ PAYMENT("payment"),
+ PLANNING("planning"),
+ POSTGRES("postgres"),
+ PRINTING("printing"),
+ PROCESS("process"),
+ QUEUE("queue"),
+ REACTIVE("reactive"),
+ REPORTING("reporting"),
+ REST("rest"),
+ RPC("rpc"),
+ RSS("rss"),
+ SAP("sap"),
+ SCHEDULING("scheduling"),
+ SCRIPT("script"),
+ SEARCH("search"),
+ SECURITY("security"),
+ SERVERLESS("serverless"),
+ SHEETS("sheets"),
+ SOAP("soap"),
+ SOCIAL("social"),
+ SPRING("spring"),
+ SQL("sql"),
+ SQLSERVER("sqlserver"),
+ STREAMS("streams"),
+ SUPPORT("support"),
+ SWAGGER("swagger"),
+ SYSTEM("system"),
+ TCP("tcp"),
+ TESTING("testing"),
+ TRANSFORMATION("transformation"),
+ UDP("udp"),
+ VALIDATION("validation"),
+ VOIP("voip"),
+ WEBSERVICE("webservice"),
+ WEBSOCKET("websocket"),
+ WORKFLOW("workflow");
+
+ private final String value;
+
+ Category(final String value) {
+ this.value = value;
+ }
+
+ /**
+ * Returns the string representation of this value
+ * @return Returns the string representation of this value
+ */
+ public String getValue() {
+ return this.value;
+ }
+}
diff --git
a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java
b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java
index ea2bc60..8ba07ac 100644
---
a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java
+++
b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriEndpoint.java
@@ -22,6 +22,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.apache.camel.Category;
+
/**
* Represents an annotated Camel <a
href="http://camel.apache.org/endpoint.html">Endpoint</a>
* which can have its properties (and the properties on its consumer) injected
from the
@@ -115,10 +117,23 @@ public @interface UriEndpoint {
* Multiple labels can be defined as a comma separated value.
* <p/>
* The labels is intended for grouping the endpoints, such as
<tt>core</tt>, <tt>file</tt>, <tt>messaging</tt>, <tt>database</tt>, etc.
+ * <p/>
+ * Deprecated: Use the category field instead
*/
+ @Deprecated
String label() default "";
/**
+ * To associate this endpoint with category(ies).
+ * <p/>
+ * This category is intended for grouping the endpoints, such as
<tt>Category.CORE</tt>, <tt>Category.FILE</tt>, <tt>Category.DATABASE</tt>,
etc, but supplied with
+ * as array of {@link Category} enums.
+ * </p>
+ * For example: @UriEndpoint(category = {Category.CORE, Category.DATABASE})
+ */
+ Category[] category() default {};
+
+ /**
* Whether this endpoint can only be used as a producer.
* <p/>
* By default its assumed the endpoint can be used as both consumer and
producer.