This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit ed96bc1b1d47d121fe71550120783abe8fc1311f Author: Claus Ibsen <[email protected]> AuthorDate: Wed Jan 18 06:58:07 2023 +0100 CAMEL-17895: Add option for vertx-websocket consumer to connect as a WS client --- .../camel/catalog/components/vertx-websocket.json | 4 +- .../VertxWebsocketEndpointUriFactory.java | 10 +++-- .../component/vertx/websocket/vertx-websocket.json | 4 +- .../websocket/VertxWebsocketConfiguration.java | 46 +++++++++++++++++++++- .../builder/endpoint/StaticEndpointBuilders.java | 22 +++++++++-- .../dsl/VertxWebsocketEndpointBuilderFactory.java | 22 +++++++++-- 6 files changed, 94 insertions(+), 14 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/vertx-websocket.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/vertx-websocket.json index 5d27296ec1e..0cb487a2259 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/vertx-websocket.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/vertx-websocket.json @@ -36,7 +36,9 @@ "CamelVertxWebsocket.remoteAddress": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "io.vertx.core.net.SocketAddress", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote address.", "constantName": "org.apache.camel.component.vertx.websocket.VertxWebsocketConstants#REMOTE_ADDRESS" } }, "properties": { - "websocketURI": { "kind": "path", "displayName": "Websocket URI", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.net.URI", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "The WebSocket URI address to use." }, + "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "WebSocket hostname, such as localhost or a remote host when in client mode." }, + "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": true, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "WebSocket port number to use." }, + "path": { "kind": "path", "displayName": "Path", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "WebSocket path to use." }, "allowedOriginPattern": { "kind": "parameter", "displayName": "Allowed Origin Pattern", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "Regex pattern to match the origin header sent by WebSocket clients" }, "consumeAsClient": { "kind": "parameter", "displayName": "Consume As Client", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "When set to true, the consumer acts as a WebSocket client, creating exchang [...] "maxReconnectAttempts": { "kind": "parameter", "displayName": "Max Reconnect Attempts", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "When consumeAsClient is set to true this sets the maximum number of allow [...] diff --git a/components/camel-vertx/camel-vertx-websocket/src/generated/java/org/apache/camel/component/vertx/websocket/VertxWebsocketEndpointUriFactory.java b/components/camel-vertx/camel-vertx-websocket/src/generated/java/org/apache/camel/component/vertx/websocket/VertxWebsocketEndpointUriFactory.java index 11bc9610b1d..549d1a1811c 100644 --- a/components/camel-vertx/camel-vertx-websocket/src/generated/java/org/apache/camel/component/vertx/websocket/VertxWebsocketEndpointUriFactory.java +++ b/components/camel-vertx/camel-vertx-websocket/src/generated/java/org/apache/camel/component/vertx/websocket/VertxWebsocketEndpointUriFactory.java @@ -21,7 +21,7 @@ public class VertxWebsocketEndpointUriFactory extends org.apache.camel.support.c private static final Set<String> SECRET_PROPERTY_NAMES; private static final Set<String> MULTI_VALUE_PREFIXES; static { - Set<String> props = new HashSet<>(16); + Set<String> props = new HashSet<>(18); props.add("allowedOriginPattern"); props.add("bridgeErrorHandler"); props.add("clientOptions"); @@ -29,15 +29,17 @@ public class VertxWebsocketEndpointUriFactory extends org.apache.camel.support.c props.add("consumeAsClient"); props.add("exceptionHandler"); props.add("exchangePattern"); + props.add("host"); props.add("lazyStartProducer"); props.add("maxReconnectAttempts"); + props.add("path"); + props.add("port"); props.add("reconnectInitialDelay"); props.add("reconnectInterval"); props.add("router"); props.add("sendToAll"); props.add("serverOptions"); props.add("sslContextParameters"); - props.add("websocketURI"); PROPERTY_NAMES = Collections.unmodifiableSet(props); SECRET_PROPERTY_NAMES = Collections.emptySet(); MULTI_VALUE_PREFIXES = Collections.emptySet(); @@ -55,7 +57,9 @@ public class VertxWebsocketEndpointUriFactory extends org.apache.camel.support.c Map<String, Object> copy = new HashMap<>(properties); - uri = buildPathParameter(syntax, uri, "websocketURI", null, true, copy); + uri = buildPathParameter(syntax, uri, "host", null, true, copy); + uri = buildPathParameter(syntax, uri, "port", null, true, copy); + uri = buildPathParameter(syntax, uri, "path", null, true, copy); uri = buildQueryParameters(uri, copy, encode); return uri; } diff --git a/components/camel-vertx/camel-vertx-websocket/src/generated/resources/org/apache/camel/component/vertx/websocket/vertx-websocket.json b/components/camel-vertx/camel-vertx-websocket/src/generated/resources/org/apache/camel/component/vertx/websocket/vertx-websocket.json index 5d27296ec1e..0cb487a2259 100644 --- a/components/camel-vertx/camel-vertx-websocket/src/generated/resources/org/apache/camel/component/vertx/websocket/vertx-websocket.json +++ b/components/camel-vertx/camel-vertx-websocket/src/generated/resources/org/apache/camel/component/vertx/websocket/vertx-websocket.json @@ -36,7 +36,9 @@ "CamelVertxWebsocket.remoteAddress": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "io.vertx.core.net.SocketAddress", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The remote address.", "constantName": "org.apache.camel.component.vertx.websocket.VertxWebsocketConstants#REMOTE_ADDRESS" } }, "properties": { - "websocketURI": { "kind": "path", "displayName": "Websocket URI", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.net.URI", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "The WebSocket URI address to use." }, + "host": { "kind": "path", "displayName": "Host", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "WebSocket hostname, such as localhost or a remote host when in client mode." }, + "port": { "kind": "path", "displayName": "Port", "group": "common", "label": "", "required": true, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "WebSocket port number to use." }, + "path": { "kind": "path", "displayName": "Path", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "WebSocket path to use." }, "allowedOriginPattern": { "kind": "parameter", "displayName": "Allowed Origin Pattern", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "Regex pattern to match the origin header sent by WebSocket clients" }, "consumeAsClient": { "kind": "parameter", "displayName": "Consume As Client", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "When set to true, the consumer acts as a WebSocket client, creating exchang [...] "maxReconnectAttempts": { "kind": "parameter", "displayName": "Max Reconnect Attempts", "group": "consumer", "label": "consumer", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.vertx.websocket.VertxWebsocketConfiguration", "configurationField": "configuration", "description": "When consumeAsClient is set to true this sets the maximum number of allow [...] diff --git a/components/camel-vertx/camel-vertx-websocket/src/main/java/org/apache/camel/component/vertx/websocket/VertxWebsocketConfiguration.java b/components/camel-vertx/camel-vertx-websocket/src/main/java/org/apache/camel/component/vertx/websocket/VertxWebsocketConfiguration.java index 9f4ea89fae8..56170c4a4ad 100644 --- a/components/camel-vertx/camel-vertx-websocket/src/main/java/org/apache/camel/component/vertx/websocket/VertxWebsocketConfiguration.java +++ b/components/camel-vertx/camel-vertx-websocket/src/main/java/org/apache/camel/component/vertx/websocket/VertxWebsocketConfiguration.java @@ -30,9 +30,17 @@ import org.apache.camel.support.jsse.SSLContextParameters; @UriParams public class VertxWebsocketConfiguration { + private URI websocketURI; + @UriPath @Metadata(required = true) - private URI websocketURI; + private String host; + @UriPath + @Metadata(required = true) + private int port; + @UriPath + @Metadata(required = true) + private String path; @UriParam(label = "consumer") private String allowedOriginPattern; @UriParam(label = "consumer") @@ -61,12 +69,48 @@ public class VertxWebsocketConfiguration { */ public void setWebsocketURI(URI websocketURI) { this.websocketURI = websocketURI; + this.host = websocketURI.getHost(); + this.port = websocketURI.getPort(); + this.path = websocketURI.getPath(); } public URI getWebsocketURI() { return websocketURI; } + public String getHost() { + return host; + } + + /** + * WebSocket hostname, such as localhost or a remote host when in client mode. + */ + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + /** + * WebSocket port number to use. + */ + public void setPort(int port) { + this.port = port; + } + + public String getPath() { + return path; + } + + /** + * WebSocket path to use. + */ + public void setPath(String path) { + this.path = path; + } + /** * Sets customized options for configuring the WebSocket client used in the producer */ 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 4da8cb972d8..9f1dcb1cc30 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 @@ -14293,8 +14293,15 @@ public class StaticEndpointBuilders { * * Syntax: <code>vertx-websocket:host:port/path</code> * - * Path parameter: websocketURI (required) - * The WebSocket URI address to use. + * Path parameter: host (required) + * WebSocket hostname, such as localhost or a remote host when in client + * mode. + * + * Path parameter: port (required) + * WebSocket port number to use. + * + * Path parameter: path (required) + * WebSocket path to use. * * @param path host:port/path * @return the dsl builder @@ -14314,8 +14321,15 @@ public class StaticEndpointBuilders { * * Syntax: <code>vertx-websocket:host:port/path</code> * - * Path parameter: websocketURI (required) - * The WebSocket URI address to use. + * Path parameter: host (required) + * WebSocket hostname, such as localhost or a remote host when in client + * mode. + * + * Path parameter: port (required) + * WebSocket port number to use. + * + * Path parameter: path (required) + * WebSocket path to use. * * @param componentName to use a custom component name for the endpoint * instead of the default name diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/VertxWebsocketEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/VertxWebsocketEndpointBuilderFactory.java index 43217d9e002..8b0faa30412 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/VertxWebsocketEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/VertxWebsocketEndpointBuilderFactory.java @@ -700,8 +700,15 @@ public interface VertxWebsocketEndpointBuilderFactory { * * Syntax: <code>vertx-websocket:host:port/path</code> * - * Path parameter: websocketURI (required) - * The WebSocket URI address to use. + * Path parameter: host (required) + * WebSocket hostname, such as localhost or a remote host when in client + * mode. + * + * Path parameter: port (required) + * WebSocket port number to use. + * + * Path parameter: path (required) + * WebSocket path to use. * * @param path host:port/path * @return the dsl builder @@ -720,8 +727,15 @@ public interface VertxWebsocketEndpointBuilderFactory { * * Syntax: <code>vertx-websocket:host:port/path</code> * - * Path parameter: websocketURI (required) - * The WebSocket URI address to use. + * Path parameter: host (required) + * WebSocket hostname, such as localhost or a remote host when in client + * mode. + * + * Path parameter: port (required) + * WebSocket port number to use. + * + * Path parameter: path (required) + * WebSocket path to use. * * @param componentName to use a custom component name for the endpoint * instead of the default name
