This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch lang6 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7f808b8d5991fa04cf77e62a14473b74bdee4881 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sun Feb 4 11:23:56 2024 +0100 CAMEL-20378: Languages should be thread-safe and be configured only via properties array, all in the same way. --- .../org/apache/camel/language/xpath/xpath.json | 4 +- .../apache/camel/language/xpath/XPathLanguage.java | 2 +- .../org/apache/camel/model/language/xpath.json | 6 +-- .../org/apache/camel/model/language/xquery.json | 14 +++--- .../org/apache/camel/model/language/xtokenize.json | 14 +++--- .../model/language/NamespaceAwareExpression.java | 2 +- .../model/language/XMLTokenizerExpression.java | 50 ---------------------- .../camel/model/language/XPathExpression.java | 29 +------------ .../camel/model/language/XQueryExpression.java | 50 ---------------------- .../language/AbstractSingleInputLanguageTest.java | 1 + .../AbstractSingleInputTypedLanguageTest.java | 37 +--------------- .../apache/camel/language/XPathLanguageTest.java | 12 ++++-- .../java/org/apache/camel/xml/in/ModelParser.java | 19 ++------ .../java/org/apache/camel/xml/out/ModelWriter.java | 27 ++---------- .../org/apache/camel/yaml/out/ModelWriter.java | 27 ++---------- 15 files changed, 44 insertions(+), 250 deletions(-) diff --git a/components/camel-xpath/src/generated/resources/org/apache/camel/language/xpath/xpath.json b/components/camel-xpath/src/generated/resources/org/apache/camel/language/xpath/xpath.json index b90d9ef9185..f2739357e7a 100644 --- a/components/camel-xpath/src/generated/resources/org/apache/camel/language/xpath/xpath.json +++ b/components/camel-xpath/src/generated/resources/org/apache/camel/language/xpath/xpath.json @@ -19,7 +19,7 @@ "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" }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax" }, "documentType": { "index": 2, "kind": "attribute", "displayName": "Document Type", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of class for document type The default value is org.w3c.dom.Document" }, - "resultType": { "index": 3, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "NUMBER", "STRING", "BOOLEAN", "NODESET", "NODE" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "NODESET", "description": "Sets the class name of the result type (type from output) The default result type is NodeSet" }, + "resultType": { "index": 3, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class of the result type (type from output)" }, "saxon": { "index": 4, "kind": "attribute", "displayName": "Saxon", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use Saxon." }, "factoryRef": { "index": 5, "kind": "attribute", "displayName": "Factory Ref", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "References to a custom XPathFactory to lookup in the registry" }, "objectModel": { "index": 6, "kind": "attribute", "displayName": "Object Model", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The XPath object model to use" }, @@ -27,7 +27,7 @@ "threadSafety": { "index": 8, "kind": "attribute", "displayName": "Thread Safety", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable thread-safety for the returned result of the xpath expression. This applies to when using NODESET as the result type, and the returned set has multiple elements. In this situation there can be threa [...] "preCompile": { "index": 9, "kind": "attribute", "displayName": "Pre Compile", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to enable pre-compiling the xpath expression during initialization phase. pre-compile is enabled by default. This can be used to turn off, for example in cases the compilation phase is desired at the starting phas [...] "namespace": { "index": 10, "kind": "element", "displayName": "Namespace", "label": "common", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Injects the XML Namespaces of prefix - uri mappings" }, - "variableName": { "index": 11, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body" }, + "variableName": { "index": 11, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body It has as higher precedent if other are set." }, "headerName": { "index": 12, "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body It has as higher precedent than the propertyName if both are set." }, "propertyName": { "index": 13, "kind": "attribute", "displayName": "Property Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of property to use as input, instead of the message body. It has a lower precedent than the headerName if both are set." }, "trim": { "index": 14, "kind": "attribute", "displayName": "Trim", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" } diff --git a/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathLanguage.java b/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathLanguage.java index 2156f392c1a..93244c25290 100644 --- a/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathLanguage.java +++ b/components/camel-xpath/src/main/java/org/apache/camel/language/xpath/XPathLanguage.java @@ -184,7 +184,7 @@ public class XPathLanguage extends SingleInputTypedLanguageSupport implements Pr throw new IllegalStateException("Can only configure our own instance !"); } switch (ignoreCase ? name.toLowerCase() : name) { - case "resulttype": + case "resultqname": case "resultQName": setResultQName(PropertyConfigurerSupport.property(camelContext, QName.class, value)); return true; diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xpath.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xpath.json index 64ba6b80fbc..e5f2e88310d 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xpath.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xpath.json @@ -16,7 +16,7 @@ "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" }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax" }, "documentType": { "index": 2, "kind": "attribute", "displayName": "Document Type", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of class for document type The default value is org.w3c.dom.Document" }, - "resultType": { "index": 3, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "NUMBER", "STRING", "BOOLEAN", "NODESET", "NODE" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "NODESET", "description": "Sets the class name of the result type (type from output) The default result type is NodeSet" }, + "resultType": { "index": 14, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class of the result type (type from output)" }, "saxon": { "index": 4, "kind": "attribute", "displayName": "Saxon", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to use Saxon." }, "factoryRef": { "index": 5, "kind": "attribute", "displayName": "Factory Ref", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "References to a custom XPathFactory to lookup in the registry" }, "objectModel": { "index": 6, "kind": "attribute", "displayName": "Object Model", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The XPath object model to use" }, @@ -24,9 +24,9 @@ "threadSafety": { "index": 8, "kind": "attribute", "displayName": "Thread Safety", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to enable thread-safety for the returned result of the xpath expression. This applies to when using NODESET as the result type, and the returned set has multiple elements. In this situation there can be threa [...] "preCompile": { "index": 9, "kind": "attribute", "displayName": "Pre Compile", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to enable pre-compiling the xpath expression during initialization phase. pre-compile is enabled by default. This can be used to turn off, for example in cases the compilation phase is desired at the starting phas [...] "namespace": { "index": 10, "kind": "element", "displayName": "Namespace", "label": "common", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Injects the XML Namespaces of prefix - uri mappings" }, - "variableName": { "index": 11, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body" }, + "variableName": { "index": 11, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body It has as higher precedent if other are set." }, "headerName": { "index": 12, "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body It has as higher precedent than the propertyName if both are set." }, "propertyName": { "index": 13, "kind": "attribute", "displayName": "Property Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of property to use as input, instead of the message body. It has a lower precedent than the headerName if both are set." }, - "trim": { "index": 14, "kind": "attribute", "displayName": "Trim", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" } + "trim": { "index": 15, "kind": "attribute", "displayName": "Trim", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" } } } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xquery.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xquery.json index dfef4422e13..52eb006e16c 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xquery.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xquery.json @@ -15,13 +15,13 @@ "properties": { "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" }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax" }, - "resultType": { "index": 2, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class of the result type (type from output)" }, - "type": { "index": 3, "kind": "attribute", "displayName": "Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class name of the result type (type from output) The default result type is NodeSet" }, - "configurationRef": { "index": 4, "kind": "attribute", "displayName": "Configuration Ref", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Reference to a saxon configuration instance in the registry to use for xquery (requires camel-saxon). This may be needed to add custom functions to a saxon configuration, so these custom functions can be used in xquery expressions." }, - "namespace": { "index": 5, "kind": "element", "displayName": "Namespace", "label": "common", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Injects the XML Namespaces of prefix - uri mappings" }, - "variableName": { "index": 6, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body" }, - "headerName": { "index": 7, "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body It has as higher precedent than the propertyName if both are set." }, - "propertyName": { "index": 8, "kind": "attribute", "displayName": "Property Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of property to use as input, instead of the message body. It has a lower precedent than the headerName if both are set." }, + "type": { "index": 2, "kind": "attribute", "displayName": "Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class name of the result type (type from output) The default result type is NodeSet" }, + "configurationRef": { "index": 3, "kind": "attribute", "displayName": "Configuration Ref", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Reference to a saxon configuration instance in the registry to use for xquery (requires camel-saxon). This may be needed to add custom functions to a saxon configuration, so these custom functions can be used in xquery expressions." }, + "namespace": { "index": 4, "kind": "element", "displayName": "Namespace", "label": "common", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Injects the XML Namespaces of prefix - uri mappings" }, + "variableName": { "index": 5, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body It has as higher precedent if other are set." }, + "headerName": { "index": 6, "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body It has as higher precedent than the propertyName if both are set." }, + "propertyName": { "index": 7, "kind": "attribute", "displayName": "Property Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of property to use as input, instead of the message body. It has a lower precedent than the headerName if both are set." }, + "resultType": { "index": 8, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class of the result type (type from output)" }, "trim": { "index": 9, "kind": "attribute", "displayName": "Trim", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" } } } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xtokenize.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xtokenize.json index fe64a44a46c..781d214fe31 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xtokenize.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/language/xtokenize.json @@ -15,13 +15,13 @@ "properties": { "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" }, "expression": { "index": 1, "kind": "value", "displayName": "Expression", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The expression value in your chosen language syntax" }, - "resultType": { "index": 2, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class of the result type (type from output)" }, - "mode": { "index": 3, "kind": "attribute", "displayName": "Mode", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "i", "w", "u", "t" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "i", "description": "The extraction mode. The available extraction modes are: i - injecting the contextual namespace bindings into the extracted token (default) w - wrapping the extracted token in its ancestor context u - unwrapping the extracted to [...] - "group": { "index": 4, "kind": "attribute", "displayName": "Group", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "To group N parts together" }, - "namespace": { "index": 5, "kind": "element", "displayName": "Namespace", "label": "common", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Injects the XML Namespaces of prefix - uri mappings" }, - "variableName": { "index": 6, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body" }, - "headerName": { "index": 7, "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body It has as higher precedent than the propertyName if both are set." }, - "propertyName": { "index": 8, "kind": "attribute", "displayName": "Property Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of property to use as input, instead of the message body. It has a lower precedent than the headerName if both are set." }, + "mode": { "index": 2, "kind": "attribute", "displayName": "Mode", "required": false, "type": "enum", "javaType": "java.lang.String", "enum": [ "i", "w", "u", "t" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "i", "description": "The extraction mode. The available extraction modes are: i - injecting the contextual namespace bindings into the extracted token (default) w - wrapping the extracted token in its ancestor context u - unwrapping the extracted to [...] + "group": { "index": 3, "kind": "attribute", "displayName": "Group", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "To group N parts together" }, + "namespace": { "index": 4, "kind": "element", "displayName": "Namespace", "label": "common", "required": false, "type": "array", "javaType": "java.util.List<org.apache.camel.model.PropertyDefinition>", "deprecated": false, "autowired": false, "secret": false, "description": "Injects the XML Namespaces of prefix - uri mappings" }, + "variableName": { "index": 5, "kind": "attribute", "displayName": "Variable Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of variable to use as input, instead of the message body It has as higher precedent if other are set." }, + "headerName": { "index": 6, "kind": "attribute", "displayName": "Header Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of header to use as input, instead of the message body It has as higher precedent than the propertyName if both are set." }, + "propertyName": { "index": 7, "kind": "attribute", "displayName": "Property Name", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Name of property to use as input, instead of the message body. It has a lower precedent than the headerName if both are set." }, + "resultType": { "index": 8, "kind": "attribute", "displayName": "Result Type", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the class of the result type (type from output)" }, "trim": { "index": 9, "kind": "attribute", "displayName": "Trim", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to trim the value to remove leading and trailing whitespaces and line breaks" } } } diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java index 3bd113bf208..5047872cd84 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/NamespaceAwareExpression.java @@ -35,7 +35,7 @@ import org.apache.camel.support.builder.Namespaces; * {@link XQueryExpression} */ @XmlAccessorType(XmlAccessType.FIELD) -public abstract class NamespaceAwareExpression extends SingleInputExpressionDefinition implements NamespaceAware { +public abstract class NamespaceAwareExpression extends SingleInputTypedExpressionDefinition implements NamespaceAware { @XmlElement(name = "namespace") @Metadata(label = "common") diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/XMLTokenizerExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/XMLTokenizerExpression.java index 4bb2116b615..5dfed81e3c2 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/XMLTokenizerExpression.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/XMLTokenizerExpression.java @@ -33,10 +33,6 @@ import org.apache.camel.spi.Metadata; @XmlAccessorType(XmlAccessType.FIELD) public class XMLTokenizerExpression extends NamespaceAwareExpression { - @XmlTransient - private Class<?> resultType; - @XmlAttribute(name = "resultType") - private String resultTypeName; @XmlAttribute @Metadata(defaultValue = "i", enums = "i,w,u,t") private String mode; @@ -57,8 +53,6 @@ public class XMLTokenizerExpression extends NamespaceAwareExpression { private XMLTokenizerExpression(Builder builder) { super(builder); - this.resultTypeName = builder.resultTypeName; - this.resultType = builder.resultType; this.mode = builder.mode; this.group = builder.group; } @@ -68,30 +62,6 @@ public class XMLTokenizerExpression extends NamespaceAwareExpression { return "xtokenize"; } - public Class<?> getResultType() { - return resultType; - } - - /** - * Sets the class of the result type (type from output). - * <p/> - * The default result type is NodeSet - */ - public void setResultType(Class<?> resultType) { - this.resultType = resultType; - } - - public String getResultTypeName() { - return resultTypeName; - } - - /** - * Sets the class of the result type (type from output) - */ - public void setResultTypeName(String resultTypeName) { - this.resultTypeName = resultTypeName; - } - public String getMode() { return mode; } @@ -126,29 +96,9 @@ public class XMLTokenizerExpression extends NamespaceAwareExpression { @XmlTransient public static class Builder extends AbstractNamespaceAwareBuilder<Builder, XMLTokenizerExpression> { - private String resultTypeName; - private Class<?> resultType; private String mode; private String group; - /** - * Sets the class of the result type (type from output) - */ - public Builder resultTypeName(String resultTypeName) { - this.resultTypeName = resultTypeName; - return this; - } - - /** - * Sets the class of the result type (type from output). - * <p/> - * The default result type is NodeSet - */ - public Builder resultType(Class<?> resultType) { - this.resultType = resultType; - return this; - } - /** * The extraction mode. The available extraction modes are: * <ul> diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/XPathExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/XPathExpression.java index 835283ba74c..e8c33af9cff 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/XPathExpression.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/XPathExpression.java @@ -22,7 +22,7 @@ import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlTransient; -// TODO: camel4 +// TODO: camel4 (need jakarta api) import javax.xml.xpath.XPathFactory; import org.apache.camel.Expression; @@ -39,8 +39,6 @@ public class XPathExpression extends NamespaceAwareExpression { @XmlTransient private Class<?> documentType; @XmlTransient - private Class<?> resultType; - @XmlTransient private XPathFactory xpathFactory; @XmlAttribute(name = "documentType") @@ -82,7 +80,6 @@ public class XPathExpression extends NamespaceAwareExpression { private XPathExpression(Builder builder) { super(builder); this.documentType = builder.documentType; - this.resultType = builder.resultType; this.xpathFactory = builder.xpathFactory; this.documentTypeName = builder.documentTypeName; this.resultTypeName = builder.resultTypeName; @@ -125,19 +122,6 @@ public class XPathExpression extends NamespaceAwareExpression { this.documentTypeName = documentTypeName; } - public Class<?> getResultType() { - return resultType; - } - - /** - * Sets the class of the result type (type from output). - * <p/> - * The default result type is NodeSet - */ - public void setResultType(Class<?> resultType) { - this.resultType = resultType; - } - public String getResultTypeName() { return resultTypeName; } @@ -243,7 +227,6 @@ public class XPathExpression extends NamespaceAwareExpression { public static class Builder extends AbstractNamespaceAwareBuilder<Builder, XPathExpression> { private Class<?> documentType; - private Class<?> resultType; private XPathFactory xpathFactory; private String documentTypeName; private String resultTypeName; @@ -264,16 +247,6 @@ public class XPathExpression extends NamespaceAwareExpression { return this; } - /** - * Sets the class of the result type (type from output). - * <p/> - * The default result type is NodeSet - */ - public Builder resultType(Class<?> resultType) { - this.resultType = resultType; - return this; - } - public Builder xpathFactory(XPathFactory xpathFactory) { this.xpathFactory = xpathFactory; return this; diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/language/XQueryExpression.java b/core/camel-core-model/src/main/java/org/apache/camel/model/language/XQueryExpression.java index e603c410727..9892796edc1 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/language/XQueryExpression.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/language/XQueryExpression.java @@ -32,10 +32,6 @@ import org.apache.camel.spi.Metadata; @XmlAccessorType(XmlAccessType.FIELD) public class XQueryExpression extends NamespaceAwareExpression { - @XmlTransient - private Class<?> resultType; - @XmlAttribute(name = "resultType") - private String resultTypeName; @XmlTransient private Object configuration; @@ -54,8 +50,6 @@ public class XQueryExpression extends NamespaceAwareExpression { private XQueryExpression(Builder builder) { super(builder); - this.resultTypeName = builder.resultTypeName; - this.resultType = builder.resultType; this.configuration = builder.configuration; this.type = builder.type; this.configurationRef = builder.configurationRef; @@ -79,30 +73,6 @@ public class XQueryExpression extends NamespaceAwareExpression { this.type = type; } - public Class<?> getResultType() { - return resultType; - } - - /** - * Sets the class of the result type (type from output). - * <p/> - * The default result type is NodeSet - */ - public void setResultType(Class<?> resultType) { - this.resultType = resultType; - } - - public String getResultTypeName() { - return resultTypeName; - } - - /** - * Sets the class of the result type (type from output) - */ - public void setResultTypeName(String resultTypeName) { - this.resultTypeName = resultTypeName; - } - public String getConfigurationRef() { return configurationRef; } @@ -134,30 +104,10 @@ public class XQueryExpression extends NamespaceAwareExpression { @XmlTransient public static class Builder extends AbstractNamespaceAwareBuilder<Builder, XQueryExpression> { - private String resultTypeName; - private Class<?> resultType; private Object configuration; private String type; private String configurationRef; - /** - * Sets the class of the result type (type from output) - */ - public Builder resultTypeName(String resultTypeName) { - this.resultTypeName = resultTypeName; - return this; - } - - /** - * Sets the class of the result type (type from output). - * <p/> - * The default result type is NodeSet - */ - public Builder resultType(Class<?> resultType) { - this.resultType = resultType; - return this; - } - /** * Custom saxon configuration (requires camel-saxon). This may be needed to add custom functions to a saxon * configuration, so these custom functions can be used in xquery expressions. diff --git a/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputLanguageTest.java b/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputLanguageTest.java index 92724ca3011..116fd85445b 100644 --- a/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputLanguageTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputLanguageTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.Test; * @param <T> the type of the builder used to build the language * @param <E> the type of the target expression */ +@Deprecated public abstract class AbstractSingleInputLanguageTest< T extends SingleInputExpressionDefinition.AbstractBuilder<T, E>, E extends SingleInputExpressionDefinition> extends ContextTestSupport { diff --git a/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputTypedLanguageTest.java b/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputTypedLanguageTest.java index 9abbb91603e..2f1b6f113b6 100644 --- a/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputTypedLanguageTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/language/AbstractSingleInputTypedLanguageTest.java @@ -18,7 +18,6 @@ package org.apache.camel.language; import java.util.function.Function; -import org.apache.camel.Message; import org.apache.camel.builder.LanguageBuilderFactory; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -36,6 +35,7 @@ public abstract class AbstractSingleInputTypedLanguageTest< T extends SingleInputTypedExpressionDefinition.AbstractBuilder<T, E>, E extends SingleInputTypedExpressionDefinition> extends AbstractTypedLanguageTest<T, E> { + protected AbstractSingleInputTypedLanguageTest(String expression, Function<LanguageBuilderFactory, T> factory) { super(expression, factory); } @@ -154,39 +154,4 @@ public abstract class AbstractSingleInputTypedLanguageTest< assertIsInstanceOf(testContext.getBodyReceivedType(), mockEndpoint.getReceivedExchanges().get(0).getIn().getBody()); } - @Test - void testAll() throws Exception { - TestContext testContext = testWithTypeContext(); - context.addRoutes(new RouteBuilder() { - @Override - public void configure() { - from("direct:all") - .setBody() - .expression( - expression( - factory.apply(expression()) - .expression(expression) - .headerName("someHeader") - .propertyName("someProperty") - .resultType(testContext.getBodyReceivedType()) - .end() - ) - ).to("mock:all"); - } - }); - context.start(); - MockEndpoint mockEndpoint = getMockEndpoint("mock:all"); - mockEndpoint.expectedBodiesReceived(testContext.getBodyReceived()); - - template.send("direct:all", exchange -> { - Message message = exchange.getIn(); - message.setBody("foo"); - message.setHeader("someHeader", testContext.getContentToSend()); - exchange.setProperty("someProperty", "bar"); - }); - - assertMockEndpointsSatisfied(); - assertIsInstanceOf(testContext.getBodyReceivedType(), mockEndpoint.getReceivedExchanges().get(0).getIn().getBody()); - } - } diff --git a/core/camel-core/src/test/java/org/apache/camel/language/XPathLanguageTest.java b/core/camel-core/src/test/java/org/apache/camel/language/XPathLanguageTest.java index 7609ea03e5d..939ccb3d73b 100644 --- a/core/camel-core/src/test/java/org/apache/camel/language/XPathLanguageTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/language/XPathLanguageTest.java @@ -21,14 +21,20 @@ import org.apache.camel.model.language.XPathExpression; /** * Ensures that the "xpath" language is compliant with the single input expectations. */ -class XPathLanguageTest extends AbstractSingleInputLanguageTest<XPathExpression.Builder, XPathExpression> { +class XPathLanguageTest extends AbstractSingleInputTypedLanguageTest<XPathExpression.Builder, XPathExpression> { XPathLanguageTest() { super("/foo/text()", factory -> factory.xpath().resultType(String.class)); } @Override - protected TestContext testContext() { - return new TestContext("<foo>1</foo>", "1", String.class); + protected Object defaultContentToSend() { + return "<foo>1</foo>"; } + + @Override + protected TestContext testWithTypeContext() { + return new TestContext(defaultContentToSend(), 1, String.class); + } + } 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 21625a8329e..e8b5e28bf2f 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 @@ -3024,8 +3024,7 @@ public class ModelParser extends BaseParser { switch (key) { case "group": def.setGroup(val); break; case "mode": def.setMode(val); break; - case "resultType": def.setResultTypeName(val); break; - default: return singleInputExpressionDefinitionAttributeHandler().accept(def, key, val); + default: return singleInputTypedExpressionDefinitionAttributeHandler().accept(def, key, val); } return true; }, namespaceAwareExpressionElementHandler(), expressionDefinitionValueHandler()); @@ -3039,17 +3038,6 @@ public class ModelParser extends BaseParser { return false; }; } - protected <T extends SingleInputExpressionDefinition> AttributeHandler<T> singleInputExpressionDefinitionAttributeHandler() { - return (def, key, val) -> { - switch (key) { - case "headerName": def.setHeaderName(val); break; - case "propertyName": def.setPropertyName(val); break; - case "variableName": def.setVariableName(val); break; - default: return expressionDefinitionAttributeHandler().accept(def, key, val); - } - return true; - }; - } protected XPathExpression doParseXPathExpression() throws IOException, XmlPullParserException { return doParse(new XPathExpression(), (def, key, val) -> { switch (key) { @@ -3061,7 +3049,7 @@ public class ModelParser extends BaseParser { case "resultType": def.setResultTypeName(val); break; case "saxon": def.setSaxon(val); break; case "threadSafety": def.setThreadSafety(val); break; - default: return singleInputExpressionDefinitionAttributeHandler().accept(def, key, val); + default: return singleInputTypedExpressionDefinitionAttributeHandler().accept(def, key, val); } return true; }, namespaceAwareExpressionElementHandler(), expressionDefinitionValueHandler()); @@ -3070,9 +3058,8 @@ public class ModelParser extends BaseParser { return doParse(new XQueryExpression(), (def, key, val) -> { switch (key) { case "configurationRef": def.setConfigurationRef(val); break; - case "resultType": def.setResultTypeName(val); break; case "type": def.setType(val); break; - default: return singleInputExpressionDefinitionAttributeHandler().accept(def, key, val); + default: return singleInputTypedExpressionDefinitionAttributeHandler().accept(def, key, val); } return true; }, namespaceAwareExpressionElementHandler(), expressionDefinitionValueHandler()); 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 aacf22cb78a..042df48a723 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 @@ -4087,7 +4087,7 @@ public class ModelWriter extends BaseWriter { protected void doWriteNamespaceAwareExpressionAttributes( NamespaceAwareExpression def) throws IOException { - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); } protected void doWriteNamespaceAwareExpressionElements( NamespaceAwareExpression def) @@ -4140,23 +4140,6 @@ public class ModelWriter extends BaseWriter { doWriteValue(def.getExpression()); endElement(name); } - protected void doWriteSingleInputExpressionDefinitionAttributes( - SingleInputExpressionDefinition def) - throws IOException { - doWriteExpressionDefinitionAttributes(def); - doWriteAttribute("headerName", def.getHeaderName()); - doWriteAttribute("variableName", def.getVariableName()); - doWriteAttribute("propertyName", def.getPropertyName()); - } - protected void doWriteSingleInputExpressionDefinition( - String name, - SingleInputExpressionDefinition def) - throws IOException { - startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } protected void doWriteSingleInputTypedExpressionDefinitionAttributes( SingleInputTypedExpressionDefinition def) throws IOException { @@ -4240,9 +4223,8 @@ public class ModelWriter extends BaseWriter { XMLTokenizerExpression def) throws IOException { startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); doWriteAttribute("mode", def.getMode()); - doWriteAttribute("resultType", def.getResultTypeName()); doWriteAttribute("group", def.getGroup()); doWriteNamespaces(def); doWriteValue(def.getExpression()); @@ -4253,7 +4235,7 @@ public class ModelWriter extends BaseWriter { XPathExpression def) throws IOException { startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); doWriteAttribute("preCompile", def.getPreCompile()); doWriteAttribute("objectModel", def.getObjectModel()); doWriteAttribute("logNamespaces", def.getLogNamespaces()); @@ -4271,10 +4253,9 @@ public class ModelWriter extends BaseWriter { XQueryExpression def) throws IOException { startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); doWriteAttribute("configurationRef", def.getConfigurationRef()); doWriteAttribute("type", def.getType()); - doWriteAttribute("resultType", def.getResultTypeName()); doWriteNamespaces(def); doWriteValue(def.getExpression()); 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 42bc845b360..9e9f0f67a48 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 @@ -4087,7 +4087,7 @@ public class ModelWriter extends BaseWriter { protected void doWriteNamespaceAwareExpressionAttributes( NamespaceAwareExpression def) throws IOException { - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); } protected void doWriteNamespaceAwareExpressionElements( NamespaceAwareExpression def) @@ -4140,23 +4140,6 @@ public class ModelWriter extends BaseWriter { doWriteValue(def.getExpression()); endElement(name); } - protected void doWriteSingleInputExpressionDefinitionAttributes( - SingleInputExpressionDefinition def) - throws IOException { - doWriteExpressionDefinitionAttributes(def); - doWriteAttribute("headerName", def.getHeaderName()); - doWriteAttribute("variableName", def.getVariableName()); - doWriteAttribute("propertyName", def.getPropertyName()); - } - protected void doWriteSingleInputExpressionDefinition( - String name, - SingleInputExpressionDefinition def) - throws IOException { - startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); - doWriteValue(def.getExpression()); - endElement(name); - } protected void doWriteSingleInputTypedExpressionDefinitionAttributes( SingleInputTypedExpressionDefinition def) throws IOException { @@ -4240,9 +4223,8 @@ public class ModelWriter extends BaseWriter { XMLTokenizerExpression def) throws IOException { startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); doWriteAttribute("mode", def.getMode()); - doWriteAttribute("resultType", def.getResultTypeName()); doWriteAttribute("group", def.getGroup()); doWriteNamespaces(def); doWriteValue(def.getExpression()); @@ -4253,7 +4235,7 @@ public class ModelWriter extends BaseWriter { XPathExpression def) throws IOException { startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); doWriteAttribute("preCompile", def.getPreCompile()); doWriteAttribute("objectModel", def.getObjectModel()); doWriteAttribute("logNamespaces", def.getLogNamespaces()); @@ -4271,10 +4253,9 @@ public class ModelWriter extends BaseWriter { XQueryExpression def) throws IOException { startElement(name); - doWriteSingleInputExpressionDefinitionAttributes(def); + doWriteSingleInputTypedExpressionDefinitionAttributes(def); doWriteAttribute("configurationRef", def.getConfigurationRef()); doWriteAttribute("type", def.getType()); - doWriteAttribute("resultType", def.getResultTypeName()); doWriteNamespaces(def); doWriteValue(def.getExpression()); endElement(name);