This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch dsl-https in repository https://gitbox.apache.org/repos/asf/camel.git
commit 381e9cfdb4a44b065c237efe4e566b8c22d1a8e7 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Oct 25 18:50:14 2023 +0200 CAMEL-20036: camel-endpointdsl - Add static builders for alias schemes such as https --- .../builder/endpoint/StaticEndpointBuilders.java | 249 +++++++++++++++++++++ .../apache/camel/builder/endpoint/HttpsTest.java | 54 +++++ .../camel/maven/packaging/EndpointDslMojo.java | 37 ++- 3 files changed, 318 insertions(+), 22 deletions(-) diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index 6459890cd79..3a0a2809710 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -2591,6 +2591,66 @@ public class StaticEndpointBuilders { String path) { return org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * CoAP (Secure) (camel-coap) + * Send and receive messages to/from COAP capable devices. + * + * Category: iot + * Since: 2.16 + * Maven coordinates: org.apache.camel:camel-coap + * + * Syntax: <code>coaps:uri</code> + * + * Path parameter: uri + * The URI for the CoAP endpoint + * + * @param path uri + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.CoAPEndpointBuilder coaps( + String path) { + return org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.endpointBuilder("coaps", path); + } + /** + * CoAP (camel-coap) + * Send and receive messages to/from COAP capable devices. + * + * Category: iot + * Since: 2.16 + * Maven coordinates: org.apache.camel:camel-coap + * + * Syntax: <code>coaps+tcp:uri</code> + * + * Path parameter: uri + * The URI for the CoAP endpoint + * + * @param path uri + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.CoAPEndpointBuilder coapsTcp( + String path) { + return org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.endpointBuilder("coaps+tcp", path); + } + /** + * CoAP (camel-coap) + * Send and receive messages to/from COAP capable devices. + * + * Category: iot + * Since: 2.16 + * Maven coordinates: org.apache.camel:camel-coap + * + * Syntax: <code>coap+tcp:uri</code> + * + * Path parameter: uri + * The URI for the CoAP endpoint + * + * @param path uri + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.CoAPEndpointBuilder coapTcp( + String path) { + return org.apache.camel.builder.endpoint.dsl.CoAPEndpointBuilderFactory.endpointBuilder("coap+tcp", path); + } /** * CometD (camel-cometd) * Offers publish/subscribe, peer-to-peer (via a server), and RPC style @@ -2650,6 +2710,34 @@ public class StaticEndpointBuilders { String path) { return org.apache.camel.builder.endpoint.dsl.CometdEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * CometD (Secure) (camel-cometd) + * Offers publish/subscribe, peer-to-peer (via a server), and RPC style + * messaging using the CometD/Bayeux protocol. + * + * Category: networking,messaging + * Since: 2.0 + * Maven coordinates: org.apache.camel:camel-cometd + * + * Syntax: <code>cometds:host:port/channelName</code> + * + * Path parameter: host (required) + * Hostname + * + * Path parameter: port (required) + * Host port number + * + * Path parameter: channelName (required) + * The channelName represents a topic that can be subscribed to by the Camel + * endpoints. + * + * @param path host:port/channelName + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.CometdEndpointBuilderFactory.CometdEndpointBuilder cometds( + String path) { + return org.apache.camel.builder.endpoint.dsl.CometdEndpointBuilderFactory.endpointBuilder("cometds", path); + } /** * Consul (camel-consul) * Integrate with Consul service discovery and configuration store. @@ -6407,6 +6495,26 @@ public class StaticEndpointBuilders { String path) { return org.apache.camel.builder.endpoint.dsl.HttpEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * HTTPS (Secure) (camel-http) + * Send requests to external HTTP servers using Apache HTTP Client 5.x. + * + * Category: http + * Since: 2.3 + * Maven coordinates: org.apache.camel:camel-http + * + * Syntax: <code>https://httpUri</code> + * + * Path parameter: httpUri (required) + * The url of the HTTP endpoint to call. + * + * @param path //httpUri + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.HttpEndpointBuilderFactory.HttpEndpointBuilder https( + String path) { + return org.apache.camel.builder.endpoint.dsl.HttpEndpointBuilderFactory.endpointBuilder("https", path); + } /** * Huawei Distributed Message Service (DMS) (camel-huaweicloud-dms) * To integrate with a fully managed, high-performance message queuing @@ -7164,6 +7272,29 @@ public class StaticEndpointBuilders { String path) { return org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * IMAPS (Secure) (camel-mail) + * Send and receive emails using imap, pop3 and smtp protocols. + * + * Category: mail + * Since: 1.0 + * Maven coordinates: org.apache.camel:camel-mail + * + * Syntax: <code>imaps:host:port</code> + * + * Path parameter: host (required) + * The mail server host name + * + * Path parameter: port + * The port number of the mail server + * + * @param path host:port + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.MailEndpointBuilder imaps( + String path) { + return org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.endpointBuilder("imaps", path); + } /** * Infinispan (camel-infinispan) * Read and write from/to Infinispan distributed key/value store and data @@ -11497,6 +11628,52 @@ public class StaticEndpointBuilders { String path) { return org.apache.camel.builder.endpoint.dsl.Plc4XEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * POP3 (camel-mail) + * Send and receive emails using imap, pop3 and smtp protocols. + * + * Category: mail + * Since: 1.0 + * Maven coordinates: org.apache.camel:camel-mail + * + * Syntax: <code>pop3:host:port</code> + * + * Path parameter: host (required) + * The mail server host name + * + * Path parameter: port + * The port number of the mail server + * + * @param path host:port + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.MailEndpointBuilder pop3( + String path) { + return org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.endpointBuilder("pop3", path); + } + /** + * POP3S (camel-mail) + * Send and receive emails using imap, pop3 and smtp protocols. + * + * Category: mail + * Since: 1.0 + * Maven coordinates: org.apache.camel:camel-mail + * + * Syntax: <code>pop3s:host:port</code> + * + * Path parameter: host (required) + * The mail server host name + * + * Path parameter: port + * The port number of the mail server + * + * @param path host:port + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.MailEndpointBuilder pop3s( + String path) { + return org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.endpointBuilder("pop3s", path); + } /** * PubNub (camel-pubnub) * Send and receive messages to/from PubNub data stream network for @@ -12902,6 +13079,78 @@ public class StaticEndpointBuilders { String path) { return org.apache.camel.builder.endpoint.dsl.SmppEndpointBuilderFactory.endpointBuilder(componentName, path); } + /** + * SMPP (Secure) (camel-smpp) + * Send and receive SMS messages using a SMSC (Short Message Service + * Center). + * + * Category: mobile + * Since: 2.2 + * Maven coordinates: org.apache.camel:camel-smpp + * + * Syntax: <code>smpps:host:port</code> + * + * Path parameter: host + * Hostname for the SMSC server to use. + * Default value: localhost + * + * Path parameter: port + * Port number for the SMSC server to use. + * Default value: 2775 + * + * @param path host:port + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.SmppEndpointBuilderFactory.SmppEndpointBuilder smpps( + String path) { + return org.apache.camel.builder.endpoint.dsl.SmppEndpointBuilderFactory.endpointBuilder("smpps", path); + } + /** + * SMTP (camel-mail) + * Send and receive emails using imap, pop3 and smtp protocols. + * + * Category: mail + * Since: 1.0 + * Maven coordinates: org.apache.camel:camel-mail + * + * Syntax: <code>smtp:host:port</code> + * + * Path parameter: host (required) + * The mail server host name + * + * Path parameter: port + * The port number of the mail server + * + * @param path host:port + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.MailEndpointBuilder smtp( + String path) { + return org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.endpointBuilder("smtp", path); + } + /** + * SMTPS (camel-mail) + * Send and receive emails using imap, pop3 and smtp protocols. + * + * Category: mail + * Since: 1.0 + * Maven coordinates: org.apache.camel:camel-mail + * + * Syntax: <code>smtps:host:port</code> + * + * Path parameter: host (required) + * The mail server host name + * + * Path parameter: port + * The port number of the mail server + * + * @param path host:port + * @return the dsl builder + */ + public static org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.MailEndpointBuilder smtps( + String path) { + return org.apache.camel.builder.endpoint.dsl.MailEndpointBuilderFactory.endpointBuilder("smtps", path); + } /** * SNMP (camel-snmp) * Receive traps and poll SNMP (Simple Network Management Protocol) capable diff --git a/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpsTest.java b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpsTest.java new file mode 100644 index 00000000000..26888c861ee --- /dev/null +++ b/dsl/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/HttpsTest.java @@ -0,0 +1,54 @@ +/* + * 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.builder.endpoint; + +import org.apache.camel.Endpoint; +import org.apache.camel.builder.endpoint.dsl.HttpEndpointBuilderFactory; +import org.apache.camel.component.http.HttpEndpoint; +import org.junit.jupiter.api.Test; + +import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class HttpsTest extends BaseEndpointDslTest { + + @Override + public boolean isUseRouteBuilder() { + return false; + } + + @Test + public void testHttps() throws Exception { + context.start(); + + context.addRoutes(new EndpointRouteBuilder() { + @Override + public void configure() throws Exception { + HttpEndpointBuilderFactory.HttpEndpointBuilder builder + = https("mysecurehost.com/foo"); + Endpoint endpoint = builder.resolve(context); + assertNotNull(endpoint); + HttpEndpoint he = assertIsInstanceOf(HttpEndpoint.class, endpoint); + assertEquals("https://mysecurehost.com/foo", he.getHttpUri().toString()); + } + }); + + context.stop(); + } + +} diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java index 55bc352194a..b25de2feb00 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/EndpointDslMojo.java @@ -469,16 +469,13 @@ public class EndpointDslMojo extends AbstractGeneratorMojo { method.addAnnotation(Deprecated.class); } - // we only want the first alias (master scheme) as static builders - if (firstAlias) { - // copy method for the static builders (which allows to use the endpoint-dsl from outside EndpointRouteBuilder) - method = method.copy(); - method.setPublic().setStatic(); - method.setReturnType(builderClass.getCanonicalName().replace('$', '.')); - method.setBodyF("return %s.%s(%s);", javaClass.getCanonicalName(), "endpointBuilder", - "\"" + componentModel.getScheme() + "\", path"); - staticBuilders.add(method); - } + // copy method for the static builders (which allows to use the endpoint-dsl from outside EndpointRouteBuilder) + method = method.copy(); + method.setPublic().setStatic(); + method.setReturnType(builderClass.getCanonicalName().replace('$', '.')); + method.setBodyF("return %s.%s(%s);", javaClass.getCanonicalName(), "endpointBuilder", + "\"" + componentModel.getScheme() + "\", path"); + staticBuilders.add(method); // we only want first alias for variation with custom component name if (firstAlias) { @@ -497,20 +494,16 @@ public class EndpointDslMojo extends AbstractGeneratorMojo { if (componentModel.isDeprecated()) { method.addAnnotation(Deprecated.class); } + firstAlias = false; } - // we only want the first alias (master scheme) as static builders - if (firstAlias) { - // copy method for the static builders (which allows to use the endpoint-dsl from outside EndpointRouteBuilder) - method = method.copy(); - method.setPublic().setStatic(); - method.setReturnType(builderClass.getCanonicalName().replace('$', '.')); - method.setBodyF("return %s.%s(%s);", javaClass.getCanonicalName(), "endpointBuilder", - "componentName, path"); - staticBuilders.add(method); - } - - firstAlias = false; + // copy method for the static builders (which allows to use the endpoint-dsl from outside EndpointRouteBuilder) + method = method.copy(); + method.setPublic().setStatic(); + method.setReturnType(builderClass.getCanonicalName().replace('$', '.')); + method.setBodyF("return %s.%s(%s);", javaClass.getCanonicalName(), "endpointBuilder", + "componentName, path"); + staticBuilders.add(method); } }