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 2024/01/23 15:29:54 UTC
(camel) 04/19: CAMEL-19749: EIPs should make it easy to use together with variables.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch var
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 048a7eca8f5ab5af1f61806fdae422dd1c2fafc8
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 20 10:03:40 2024 +0100
CAMEL-19749: EIPs should make it easy to use together with variables.
---
.../camel/spring/processor/FromVariableTest.xml | 2 +-
.../resources/org/apache/camel/model/from.json | 2 +-
.../org/apache/camel/model/FromDefinition.java | 15 ++++++------
.../org/apache/camel/model/RouteDefinition.java | 28 +++++++++++-----------
.../org/apache/camel/model/RoutesDefinition.java | 28 +++++++++++-----------
.../org/apache/camel/reifier/RouteReifier.java | 2 +-
.../java/org/apache/camel/xml/in/ModelParser.java | 2 +-
.../java/org/apache/camel/xml/out/ModelWriter.java | 2 +-
.../org/apache/camel/yaml/out/ModelWriter.java | 2 +-
.../deserializers/FromDefinitionDeserializer.java | 12 +++++-----
.../OutputAwareFromDefinitionDeserializer.java | 12 +++++-----
.../generated/resources/schema/camelYamlDsl.json | 6 ++---
.../apache/camel/dsl/yaml/FromVariableTest.groovy | 2 +-
13 files changed, 57 insertions(+), 58 deletions(-)
diff --git a/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/FromVariableTest.xml b/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/FromVariableTest.xml
index 00e697e7f59..1f578ec457d 100644
--- a/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/FromVariableTest.xml
+++ b/components/camel-spring-xml/src/test/resources/org/apache/camel/spring/processor/FromVariableTest.xml
@@ -28,7 +28,7 @@
<camelContext xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="jmx" disabled="true"/>
<route>
- <from uri="direct:start" variable="myKey"/>
+ <from uri="direct:start" variableReceive="myKey"/>
<transform><simple>Bye ${body}</simple></transform>
<to uri="mock:foo"/>
<setBody>
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/from.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/from.json
index b753ab0fa4f..8eee8ec59c0 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/from.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/from.json
@@ -15,6 +15,6 @@
"id": { "index": 0, "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" },
"description": { "index": 1, "kind": "element", "displayName": "Description", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" },
"uri": { "index": 2, "kind": "attribute", "displayName": "Uri", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the URI of the endpoint to use" },
- "variable": { "index": 3, "kind": "attribute", "displayName": "Variable", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable to store a copy of the incoming message body (only body, not headers). This is handy for easy access to the incoming message body via variables." }
+ "variableReceive": { "index": 3, "kind": "attribute", "displayName": "Variable Receive", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable to store a copy of the received message body (only body, not headers). This is handy for easy access to the received message body via variables." }
}
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java
index a0b29da52ee..c23893241cf 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/FromDefinition.java
@@ -46,7 +46,7 @@ public class FromDefinition extends OptionalIdentifiedDefinition<FromDefinition>
@Metadata(required = true)
private String uri;
@XmlAttribute
- private String variable;
+ private String variableReceive;
public FromDefinition() {
}
@@ -121,17 +121,16 @@ public class FromDefinition extends OptionalIdentifiedDefinition<FromDefinition>
this.uri = uri;
}
- public String getVariable() {
- return variable;
+ public String getVariableReceive() {
+ return variableReceive;
}
/**
- * To use a variable to store a copy of the incoming message body (only body, not headers).
- *
- * This is handy for easy access to the incoming message body via variables.
+ * To use a variable to store a copy of the received message body (only body, not headers).
+ * This is handy for easy access to the received message body via variables.
*/
- public void setVariable(String variable) {
- this.variable = variable;
+ public void setVariableReceive(String variableReceive) {
+ this.variableReceive = variableReceive;
}
/**
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
index dc4fc72c2cd..c62560e9259 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RouteDefinition.java
@@ -218,31 +218,31 @@ public class RouteDefinition extends OutputDefinition<RouteDefinition>
}
/**
- * Creates an input to the route, and use a variable to store a copy of the incoming message body (only body, not headers).
- * This is handy for easy access to the incoming message body via variables.
+ * Creates an input to the route, and uses a variable to store a copy of the received message body (only body, not headers).
+ * This is handy for easy access to the received message body via variables.
*
- * @param uri the from uri
- * @param variable the name of the variable
- * @return the builder
+ * @param uri the from uri
+ * @param variableReceive the name of the variable
+ * @return the builder
*/
- public RouteDefinition fromV(@AsEndpointUri String uri, String variable) {
+ public RouteDefinition fromV(@AsEndpointUri String uri, String variableReceive) {
FromDefinition from = new FromDefinition(uri);
- from.setVariable(variable);
+ from.setVariableReceive(variableReceive);
setInput(from);
return this;
}
/**
- * Creates an input to the route, and use a variable to store a copy of the incoming message body (only body, not headers).
- * This is handy for easy access to the incoming message body via variables.
+ * Creates an input to the route, and uses a variable to store a copy of the received message body (only body, not headers).
+ * This is handy for easy access to the received message body via variables.
*
- * @param endpoint the from endpoint
- * @param variable the name of the variable
- * @return the builder
+ * @param endpoint the from endpoint
+ * @param variableReceive the name of the variable
+ * @return the builder
*/
- public RouteDefinition fromV(EndpointConsumerBuilder endpoint, String variable) {
+ public RouteDefinition fromV(EndpointConsumerBuilder endpoint, String variableReceive) {
FromDefinition from = new FromDefinition(endpoint);
- from.setVariable(variable);
+ from.setVariableReceive(variableReceive);
setInput(from);
return this;
}
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
index d6dcb4832c0..81b013e4d0b 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RoutesDefinition.java
@@ -197,16 +197,16 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit
}
/**
- * Creates an input to the route, and use a variable to store a copy of the incoming message body (only body, not headers).
- * This is handy for easy access to the incoming message body via variables.
+ * Creates an input to the route, and uses a variable to store a copy of the received message body (only body, not headers).
+ * This is handy for easy access to the received message body via variables.
*
- * @param uri the from uri
- * @param variable the name of the variable
- * @return the builder
+ * @param uri the from uri
+ * @param variableReceive the name of the variable
+ * @return the builder
*/
- public RouteDefinition fromV(@AsEndpointUri String uri, String variable) {
+ public RouteDefinition fromV(@AsEndpointUri String uri, String variableReceive) {
RouteDefinition route = createRoute();
- route.fromV(uri, variable);
+ route.fromV(uri, variableReceive);
return route(route);
}
@@ -235,16 +235,16 @@ public class RoutesDefinition extends OptionalIdentifiedDefinition<RoutesDefinit
}
/**
- * Creates an input to the route, and use a variable to store a copy of the incoming message body (only body, not headers).
- * This is handy for easy access to the incoming message body via variables.
+ * Creates an input to the route, and uses a variable to store a copy of the received message body (only body, not headers).
+ * This is handy for easy access to the received message body via variables.
*
- * @param endpoint the from endpoint
- * @param variable the name of the variable
- * @return the builder
+ * @param endpoint the from endpoint
+ * @param variableReceive the name of the variable
+ * @return the builder
*/
- public RouteDefinition fromV(EndpointConsumerBuilder endpoint, String variable) {
+ public RouteDefinition fromV(EndpointConsumerBuilder endpoint, String variableReceive) {
RouteDefinition route = createRoute();
- route.fromV(endpoint, variable);
+ route.fromV(endpoint, variableReceive);
return route(route);
}
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java
index 8d1088b5e11..025497ace88 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RouteReifier.java
@@ -110,7 +110,7 @@ public class RouteReifier extends ProcessorReifier<RouteDefinition> {
route.setErrorHandlerFactory(definition.getErrorHandlerFactory());
// configure variable
- String variable = definition.getInput().getVariable();
+ String variable = definition.getInput().getVariableReceive();
if (variable != null) {
// when using variable we need to turn on original message
route.setAllowUseOriginalMessage(true);
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 61c0e7c0174..f542022a12f 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -478,7 +478,7 @@ public class ModelParser extends BaseParser {
return doParse(new FromDefinition(), (def, key, val) -> {
switch (key) {
case "uri": def.setUri(val); break;
- case "variable": def.setVariable(val); break;
+ case "variableReceive": def.setVariableReceive(val); break;
default: return optionalIdentifiedDefinitionAttributeHandler().accept(def, key, val);
}
return true;
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index 023547e5bd8..fd48d046a6c 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -1365,7 +1365,7 @@ public class ModelWriter extends BaseWriter {
throws IOException {
startElement(name);
doWriteOptionalIdentifiedDefinitionAttributes(def);
- doWriteAttribute("variable", def.getVariable());
+ doWriteAttribute("variableReceive", def.getVariableReceive());
doWriteAttribute("uri", def.getUri());
endElement(name);
}
diff --git a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
index 4daf3bd618d..0f2cf3ae648 100644
--- a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
+++ b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/ModelWriter.java
@@ -1365,7 +1365,7 @@ public class ModelWriter extends BaseWriter {
throws IOException {
startElement(name);
doWriteOptionalIdentifiedDefinitionAttributes(def);
- doWriteAttribute("variable", def.getVariable());
+ doWriteAttribute("variableReceive", def.getVariableReceive());
doWriteAttribute("uri", def.getUri());
endElement(name);
}
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/FromDefinitionDeserializer.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/FromDefinitionDeserializer.java
index 041eb98795a..ece57eeff55 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/FromDefinitionDeserializer.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/FromDefinitionDeserializer.java
@@ -38,7 +38,7 @@ import static org.apache.camel.dsl.yaml.common.YamlDeserializerSupport.getDeseri
order = YamlDeserializerResolver.ORDER_DEFAULT,
properties = {
@YamlProperty(name = "uri", type = "string", required = true),
- @YamlProperty(name = "variable", type = "string"),
+ @YamlProperty(name = "variableReceive", type = "string"),
@YamlProperty(name = "id", type = "string"),
@YamlProperty(name = "description", type = "string"),
@YamlProperty(name = "parameters", type = "object"),
@@ -55,7 +55,7 @@ public class FromDefinitionDeserializer implements ConstructNode {
String desc = null;
String id = null;
- String variable = null;
+ String variableReceive = null;
if (node.getNodeType() == NodeType.MAPPING) {
final MappingNode mn = (MappingNode) node;
for (NodeTuple tuple : mn.getValue()) {
@@ -69,8 +69,8 @@ public class FromDefinitionDeserializer implements ConstructNode {
desc = asText(tuple.getValueNode());
} else if ("id".equals(key)) {
id = asText(tuple.getValueNode());
- } else if ("variable".equals(key)) {
- variable = asText(tuple.getValueNode());
+ } else if ("variableReceive".equals(key)) {
+ variableReceive = asText(tuple.getValueNode());
}
}
}
@@ -95,8 +95,8 @@ public class FromDefinitionDeserializer implements ConstructNode {
if (id != null) {
target.setId(id);
}
- if (variable != null) {
- target.setVariable(variable);
+ if (variableReceive != null) {
+ target.setVariableReceive(variableReceive);
}
// enrich model with line number
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/OutputAwareFromDefinitionDeserializer.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/OutputAwareFromDefinitionDeserializer.java
index b932c448e10..82e4388e3dd 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/OutputAwareFromDefinitionDeserializer.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/main/java/org/apache/camel/dsl/yaml/deserializers/OutputAwareFromDefinitionDeserializer.java
@@ -36,7 +36,7 @@ import org.snakeyaml.engine.v2.nodes.NodeTuple;
order = YamlDeserializerResolver.ORDER_DEFAULT,
properties = {
@YamlProperty(name = "uri", type = "string", required = true),
- @YamlProperty(name = "variable", type = "string"),
+ @YamlProperty(name = "variableReceive", type = "string"),
@YamlProperty(name = "id", type = "string"),
@YamlProperty(name = "description", type = "string"),
@YamlProperty(name = "parameters", type = "object"),
@@ -70,7 +70,7 @@ public class OutputAwareFromDefinitionDeserializer extends YamlDeserializerBase<
String uri = null;
String id = null;
String desc = null;
- String variable = null;
+ String variableReceive = null;
Map<String, Object> parameters = null;
for (NodeTuple tuple : node.getValue()) {
@@ -90,8 +90,8 @@ public class OutputAwareFromDefinitionDeserializer extends YamlDeserializerBase<
case "uri":
uri = asText(val);
break;
- case "variable":
- variable = asText(val);
+ case "variableReceive":
+ variableReceive = asText(val);
break;
case "parameters":
parameters = parseParameters(tuple);
@@ -119,8 +119,8 @@ public class OutputAwareFromDefinitionDeserializer extends YamlDeserializerBase<
if (desc != null) {
from.setDescription(desc);
}
- if (variable != null) {
- from.setVariable(variable);
+ if (variableReceive != null) {
+ from.setVariableReceive(variableReceive);
}
target.setDelegate(from);
}
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index e4c6f9e3fdc..6964a70e2b1 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -314,7 +314,7 @@
"uri" : {
"type" : "string"
},
- "variable" : {
+ "variableReceive" : {
"type" : "string"
}
},
@@ -343,7 +343,7 @@
"uri" : {
"type" : "string"
},
- "variable" : {
+ "variableReceive" : {
"type" : "string"
}
},
@@ -1968,7 +1968,7 @@
"uri" : {
"type" : "string"
},
- "variable" : {
+ "variableReceive" : {
"type" : "string"
}
},
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/FromVariableTest.groovy b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/FromVariableTest.groovy
index 08eecb16ad2..7316a4f874a 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/FromVariableTest.groovy
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/FromVariableTest.groovy
@@ -26,7 +26,7 @@ class FromVariableTest extends YamlTestSupport {
loadRoutes '''
- from:
uri: "direct:start"
- variable: "myKey"
+ variableReceive: "myKey"
steps:
- transform:
simple: "Bye ${body}"