This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-4.4.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push: new 35c9c317ece CAMEL-20470: camel-jbang - Rest dsl with /api context path should auto detect platform-http as consumer 35c9c317ece is described below commit 35c9c317ece040a07f0657f0b3f5838fed4d44cb Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Feb 28 17:21:46 2024 +0100 CAMEL-20470: camel-jbang - Rest dsl with /api context path should auto detect platform-http as consumer --- .../apache/camel/catalog/components/rest-api.json | 3 ++- .../component/rest/RestApiComponentConfigurer.java | 6 ++++++ .../org/apache/camel/component/rest/rest-api.json | 3 ++- .../camel/component/rest/RestApiComponent.java | 19 +++++++++++++++++++ .../dsl/RestApiComponentBuilderFactory.java | 21 +++++++++++++++++++++ dsl/camel-kamelet-main/pom.xml | 9 ++++----- .../java/org/apache/camel/main/KameletMain.java | 1 + 7 files changed, 55 insertions(+), 7 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-api.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-api.json index 83a6abce640..a2e59a6cbbf 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-api.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/rest-api.json @@ -24,7 +24,8 @@ }, "componentProperties": { "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...] - "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] + "consumerComponentName": { "index": 1, "kind": "property", "displayName": "Consumer Component Name", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The Camel Rest API component to use for the consumer REST transport, such as jetty, servlet, undertow. If no component has been explicitly configured, then Camel will lookup if there is a Camel componen [...] + "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] }, "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The base path" }, diff --git a/components/camel-rest/src/generated/java/org/apache/camel/component/rest/RestApiComponentConfigurer.java b/components/camel-rest/src/generated/java/org/apache/camel/component/rest/RestApiComponentConfigurer.java index 105cba16aed..01a0255e02b 100644 --- a/components/camel-rest/src/generated/java/org/apache/camel/component/rest/RestApiComponentConfigurer.java +++ b/components/camel-rest/src/generated/java/org/apache/camel/component/rest/RestApiComponentConfigurer.java @@ -25,6 +25,8 @@ public class RestApiComponentConfigurer extends PropertyConfigurerSupport implem case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true; case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; + case "consumercomponentname": + case "consumerComponentName": target.setConsumerComponentName(property(camelContext, java.lang.String.class, value)); return true; default: return false; } } @@ -36,6 +38,8 @@ public class RestApiComponentConfigurer extends PropertyConfigurerSupport implem case "autowiredEnabled": return boolean.class; case "bridgeerrorhandler": case "bridgeErrorHandler": return boolean.class; + case "consumercomponentname": + case "consumerComponentName": return java.lang.String.class; default: return null; } } @@ -48,6 +52,8 @@ public class RestApiComponentConfigurer extends PropertyConfigurerSupport implem case "autowiredEnabled": return target.isAutowiredEnabled(); case "bridgeerrorhandler": case "bridgeErrorHandler": return target.isBridgeErrorHandler(); + case "consumercomponentname": + case "consumerComponentName": return target.getConsumerComponentName(); default: return null; } } diff --git a/components/camel-rest/src/generated/resources/org/apache/camel/component/rest/rest-api.json b/components/camel-rest/src/generated/resources/org/apache/camel/component/rest/rest-api.json index 83a6abce640..a2e59a6cbbf 100644 --- a/components/camel-rest/src/generated/resources/org/apache/camel/component/rest/rest-api.json +++ b/components/camel-rest/src/generated/resources/org/apache/camel/component/rest/rest-api.json @@ -24,7 +24,8 @@ }, "componentProperties": { "bridgeErrorHandler": { "index": 0, "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the like [...] - "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] + "consumerComponentName": { "index": 1, "kind": "property", "displayName": "Consumer Component Name", "group": "consumer", "label": "consumer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The Camel Rest API component to use for the consumer REST transport, such as jetty, servlet, undertow. If no component has been explicitly configured, then Camel will lookup if there is a Camel componen [...] + "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] }, "properties": { "path": { "index": 0, "kind": "path", "displayName": "Path", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The base path" }, diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiComponent.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiComponent.java index c4526ec5fe6..b8b32791696 100644 --- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiComponent.java +++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestApiComponent.java @@ -19,6 +19,7 @@ package org.apache.camel.component.rest; import java.util.Map; import org.apache.camel.Endpoint; +import org.apache.camel.spi.Metadata; import org.apache.camel.support.DefaultComponent; /** @@ -27,12 +28,16 @@ import org.apache.camel.support.DefaultComponent; @org.apache.camel.spi.annotations.Component("rest-api") public class RestApiComponent extends DefaultComponent { + @Metadata(label = "consumer") + private String consumerComponentName; + public RestApiComponent() { } @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { RestApiEndpoint answer = new RestApiEndpoint(uri, this); + answer.setConsumerComponentName(getConsumerComponentName()); answer.setPath(remaining); setProperties(answer, parameters); @@ -46,4 +51,18 @@ public class RestApiComponent extends DefaultComponent { return answer; } + public String getConsumerComponentName() { + return consumerComponentName; + } + + /** + * The Camel Rest API component to use for the consumer REST transport, such as jetty, servlet, undertow. If no + * component has been explicitly configured, then Camel will lookup if there is a Camel component that integrates + * with the Rest DSL, or if a org.apache.camel.spi.RestApiConsumerFactory is registered in the registry. If either + * one is found, then that is being used. + */ + public void setConsumerComponentName(String consumerComponentName) { + this.consumerComponentName = consumerComponentName; + } + } diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestApiComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestApiComponentBuilderFactory.java index b4ec7944267..d934374f89b 100644 --- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestApiComponentBuilderFactory.java +++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/RestApiComponentBuilderFactory.java @@ -79,6 +79,26 @@ public interface RestApiComponentBuilderFactory { doSetProperty("bridgeErrorHandler", bridgeErrorHandler); return this; } + /** + * The Camel Rest API component to use for the consumer REST transport, + * such as jetty, servlet, undertow. If no component has been explicitly + * configured, then Camel will lookup if there is a Camel component that + * integrates with the Rest DSL, or if a + * org.apache.camel.spi.RestApiConsumerFactory is registered in the + * registry. If either one is found, then that is being used. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: consumer + * + * @param consumerComponentName the value to set + * @return the dsl builder + */ + default RestApiComponentBuilder consumerComponentName( + java.lang.String consumerComponentName) { + doSetProperty("consumerComponentName", consumerComponentName); + return this; + } /** * Whether autowiring is enabled. This is used for automatic autowiring * options (the option must be marked as autowired) by looking up in the @@ -118,6 +138,7 @@ public interface RestApiComponentBuilderFactory { Object value) { switch (name) { case "bridgeErrorHandler": ((RestApiComponent) component).setBridgeErrorHandler((boolean) value); return true; + case "consumerComponentName": ((RestApiComponent) component).setConsumerComponentName((java.lang.String) value); return true; case "autowiredEnabled": ((RestApiComponent) component).setAutowiredEnabled((boolean) value); return true; default: return false; } diff --git a/dsl/camel-kamelet-main/pom.xml b/dsl/camel-kamelet-main/pom.xml index 010bf75b2eb..3c33dfc3b43 100644 --- a/dsl/camel-kamelet-main/pom.xml +++ b/dsl/camel-kamelet-main/pom.xml @@ -87,6 +87,10 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-rest</artifactId> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-stub</artifactId> @@ -157,11 +161,6 @@ <artifactId>camel-mock</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-rest</artifactId> - <scope>test</scope> - </dependency> <!-- Entire Maven downloading/resolution support is made using camel-tooling-maven --> <dependency> diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java index 1c4b46f6515..5e2ea60a590 100644 --- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java +++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java @@ -730,6 +730,7 @@ public class KameletMain extends MainCommandLineSupport { */ protected void configureInitialProperties(String location) { addInitialProperty("camel.component.kamelet.location", location); + addInitialProperty("camel.component.rest-api.consumerComponentName", "platform-http"); addInitialProperty("camel.component.rest.consumerComponentName", "platform-http"); addInitialProperty("camel.component.rest.producerComponentName", "vertx-http"); addInitialProperty("came.main.jmxUpdateRouteEnabled", "true");