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 9b4153e4d75f0f3436e7c30cfcae75a3664cdb3b Author: Claus Ibsen <[email protected]> AuthorDate: Fri Jun 25 16:44:40 2021 +0200 CAMEL-16630: camel-core - EIP model that is configured with bean from registry, can now use #class: to specify creating a new bean from the given class instead of lookup. --- .../org/apache/camel/catalog/models/aggregate.json | 2 +- .../apache/camel/catalog/models/claimCheck.json | 2 +- .../org/apache/camel/catalog/models/enrich.json | 2 +- .../apache/camel/catalog/models/pollEnrich.json | 2 +- .../org/apache/camel/model/aggregate.json | 2 +- .../org/apache/camel/model/claimCheck.json | 2 +- .../resources/org/apache/camel/model/enrich.json | 2 +- .../org/apache/camel/model/pollEnrich.json | 2 +- .../apache/camel/model/AggregateDefinition.java | 39 ++++++++++++++ .../apache/camel/model/ClaimCheckDefinition.java | 15 ++++++ .../org/apache/camel/model/EnrichDefinition.java | 15 ++++++ .../apache/camel/model/MulticastDefinition.java | 17 ++++++- .../apache/camel/model/PollEnrichDefinition.java | 15 ++++++ .../camel/model/RecipientListDefinition.java | 27 +++++++--- .../org/apache/camel/model/SplitDefinition.java | 15 ++++++ .../org/apache/camel/reifier/AbstractReifier.java | 59 ++++++++++++++++------ .../enricher/EnricherRefBeanClassTest.java | 3 +- ...ClassTest.java => EnricherRefBeanTypeTest.java} | 7 ++- 18 files changed, 195 insertions(+), 33 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/aggregate.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/aggregate.json index d4651eb..0482dca 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/aggregate.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/aggregate.json @@ -21,7 +21,7 @@ "executorServiceRef": { "kind": "attribute", "displayName": "Executor Service Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If using parallelProcessing you can specify a custom thread pool to be used. In fact also if you are not using parallelProcessing this custom thread pool is used to send out aggregated exchanges as well." }, "timeoutCheckerExecutorServiceRef": { "kind": "attribute", "displayName": "Timeout Checker Executor Service Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If using either of the completionTimeout, completionTimeoutExpression, or completionInterval options a background thread is created to check for the completion for every aggregator. Set this option to provide a custom thread pool t [...] "aggregationRepositoryRef": { "kind": "attribute", "displayName": "Aggregation Repository Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the custom aggregate repository to use. Will by default use org.apache.camel.processor.aggregate.MemoryAggregationRepository" }, - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A reference to lookup the AggregationStrategy in the Registry. Configuring an AggregationStrategy is required, and is used to merge the incoming Exchange with the existing already merged exchanges. At first call the oldExchange parameter is null. On subsequent invocations the [...] + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A reference to lookup the AggregationStrategy in the Registry. The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new bean: Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value) refe [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy Method Allow Null", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used for the very first aggregation. If this option is true then null values is used as the oldExchange (at the very first aggregation), when using POJOs as the Aggrega [...] "completionSize": { "kind": "attribute", "displayName": "Completion Size", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Number of messages aggregated before the aggregation is complete. This option can be set as either a fixed value or using an Expression which allows you to evaluate a size dynamically - will use Integer as result. If both are set Camel will fallback to use the fixed v [...] diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/claimCheck.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/claimCheck.json index c18153e..92fcd52 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/claimCheck.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/claimCheck.json @@ -14,7 +14,7 @@ "operation": { "kind": "attribute", "displayName": "Operation", "required": false, "type": "enum", "javaType": "org.apache.camel.model.ClaimCheckOperation", "enum": [ "Get", "GetAndRemove", "Pop", "Push", "Set" ], "deprecated": false, "autowired": false, "secret": false, "description": "The claim check operation to use. The following operations is supported: Get - Gets (does not remove) the claim check by the given key. GetAndRemove - Gets and remove the claim check by the given key. [...] "key": { "kind": "attribute", "displayName": "Key", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a specific key for claim check id (for dynamic keys use simple language syntax as the key)." }, "filter": { "kind": "attribute", "displayName": "Filter", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Specified a filter to control what data gets merging data back from the claim check repository. The following syntax is supported: body - to aggregate the message body attachments - to aggregate all the message attachments headers - to aggregate all the message headers header:pattern - [...] - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom AggregationStrategy instead of the default implementation. Notice you cannot use both custom aggregation strategy and configure data at the same time." }, + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom AggregationStrategy instead of the default implementation. Notice you cannot use both custom aggregation strategy and configure data at the same time. The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "id": { "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": { "kind": "element", "displayName": "Description", "required": false, "type": "object", "javaType": "org.apache.camel.model.DescriptionDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" } diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json index c92a660c..74228ac 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/enrich.json @@ -12,7 +12,7 @@ }, "properties": { "expression": { "kind": "expression", "displayName": "Expression", "required": true, "type": "object", "javaType": "org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant", "csimple", "datasonnet", "exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath", "language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize", "xpath", "xquery", "xtokenize" ], "deprecated": false, "autowired": false, "secret": false, "description": "Expression th [...] - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message." }, + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. The value can either refer to a bean to lookup, or to lookup a singleto [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy Method Allow Null", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStrategy." }, "aggregateOnException": { "kind": "attribute", "displayName": "Aggregate On Exception", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to true allows end users to control what to do if ther [...] diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json index c258f92..c56f351 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/pollEnrich.json @@ -13,7 +13,7 @@ "properties": { "expression": { "kind": "expression", "displayName": "Expression", "required": true, "type": "object", "javaType": "org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant", "csimple", "datasonnet", "exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath", "language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize", "xpath", "xquery", "xtokenize" ], "deprecated": false, "autowired": false, "secret": false, "description": "Expression th [...] "timeout": { "kind": "attribute", "displayName": "Timeout", "required": false, "type": "duration", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "-1", "description": "Timeout in millis when polling from the external service. The timeout has influence about the poll enrich behavior. It basically operations in three different modes: negative value - Waits until a message is available and then returns it. Warning that this meth [...] - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message." }, + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. The value can either refer to a bean to lookup, or to lookup a singleto [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy Method Allow Null", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStr [...] "aggregateOnException": { "kind": "attribute", "displayName": "Aggregate On Exception", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to true allows end users to control what to do if ther [...] diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/aggregate.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/aggregate.json index d4651eb..0482dca 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/aggregate.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/aggregate.json @@ -21,7 +21,7 @@ "executorServiceRef": { "kind": "attribute", "displayName": "Executor Service Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If using parallelProcessing you can specify a custom thread pool to be used. In fact also if you are not using parallelProcessing this custom thread pool is used to send out aggregated exchanges as well." }, "timeoutCheckerExecutorServiceRef": { "kind": "attribute", "displayName": "Timeout Checker Executor Service Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If using either of the completionTimeout, completionTimeoutExpression, or completionInterval options a background thread is created to check for the completion for every aggregator. Set this option to provide a custom thread pool t [...] "aggregationRepositoryRef": { "kind": "attribute", "displayName": "Aggregation Repository Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the custom aggregate repository to use. Will by default use org.apache.camel.processor.aggregate.MemoryAggregationRepository" }, - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A reference to lookup the AggregationStrategy in the Registry. Configuring an AggregationStrategy is required, and is used to merge the incoming Exchange with the existing already merged exchanges. At first call the oldExchange parameter is null. On subsequent invocations the [...] + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "A reference to lookup the AggregationStrategy in the Registry. The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new bean: Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value) refe [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy Method Allow Null", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used for the very first aggregation. If this option is true then null values is used as the oldExchange (at the very first aggregation), when using POJOs as the Aggrega [...] "completionSize": { "kind": "attribute", "displayName": "Completion Size", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "autowired": false, "secret": false, "description": "Number of messages aggregated before the aggregation is complete. This option can be set as either a fixed value or using an Expression which allows you to evaluate a size dynamically - will use Integer as result. If both are set Camel will fallback to use the fixed v [...] diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/claimCheck.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/claimCheck.json index c18153e..92fcd52 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/claimCheck.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/claimCheck.json @@ -14,7 +14,7 @@ "operation": { "kind": "attribute", "displayName": "Operation", "required": false, "type": "enum", "javaType": "org.apache.camel.model.ClaimCheckOperation", "enum": [ "Get", "GetAndRemove", "Pop", "Push", "Set" ], "deprecated": false, "autowired": false, "secret": false, "description": "The claim check operation to use. The following operations is supported: Get - Gets (does not remove) the claim check by the given key. GetAndRemove - Gets and remove the claim check by the given key. [...] "key": { "kind": "attribute", "displayName": "Key", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a specific key for claim check id (for dynamic keys use simple language syntax as the key)." }, "filter": { "kind": "attribute", "displayName": "Filter", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Specified a filter to control what data gets merging data back from the claim check repository. The following syntax is supported: body - to aggregate the message body attachments - to aggregate all the message attachments headers - to aggregate all the message headers header:pattern - [...] - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom AggregationStrategy instead of the default implementation. Notice you cannot use both custom aggregation strategy and configure data at the same time." }, + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom AggregationStrategy instead of the default implementation. Notice you cannot use both custom aggregation strategy and configure data at the same time. The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "id": { "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": { "kind": "element", "displayName": "Description", "required": false, "type": "object", "javaType": "org.apache.camel.model.DescriptionDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" } diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json index c92a660c..74228ac 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/enrich.json @@ -12,7 +12,7 @@ }, "properties": { "expression": { "kind": "expression", "displayName": "Expression", "required": true, "type": "object", "javaType": "org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant", "csimple", "datasonnet", "exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath", "language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize", "xpath", "xquery", "xtokenize" ], "deprecated": false, "autowired": false, "secret": false, "description": "Expression th [...] - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message." }, + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. The value can either refer to a bean to lookup, or to lookup a singleto [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy Method Allow Null", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStrategy." }, "aggregateOnException": { "kind": "attribute", "displayName": "Aggregate On Exception", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to true allows end users to control what to do if ther [...] diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json index c258f92..c56f351 100644 --- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json +++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/pollEnrich.json @@ -13,7 +13,7 @@ "properties": { "expression": { "kind": "expression", "displayName": "Expression", "required": true, "type": "object", "javaType": "org.apache.camel.model.language.ExpressionDefinition", "oneOf": [ "constant", "csimple", "datasonnet", "exchangeProperty", "groovy", "header", "hl7terser", "joor", "jsonpath", "language", "method", "mvel", "ognl", "ref", "simple", "spel", "tokenize", "xpath", "xquery", "xtokenize" ], "deprecated": false, "autowired": false, "secret": false, "description": "Expression th [...] "timeout": { "kind": "attribute", "displayName": "Timeout", "required": false, "type": "duration", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "defaultValue": "-1", "description": "Timeout in millis when polling from the external service. The timeout has influence about the poll enrich behavior. It basically operations in three different modes: negative value - Waits until a message is available and then returns it. Warning that this meth [...] - "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message." }, + "strategyRef": { "kind": "attribute", "displayName": "Strategy Ref", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. The value can either refer to a bean to lookup, or to lookup a singleto [...] "strategyMethodName": { "kind": "attribute", "displayName": "Strategy Method Name", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "This option can be used to explicit declare the method name to use, when using POJOs as the AggregationStrategy." }, "strategyMethodAllowNull": { "kind": "attribute", "displayName": "Strategy Method Allow Null", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was no data to enrich. If this option is true then null values is used as the oldExchange (when no data to enrich), when using POJOs as the AggregationStr [...] "aggregateOnException": { "kind": "attribute", "displayName": "Aggregate On Exception", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If this option is false then the aggregate method is not used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to true allows end users to control what to do if ther [...] diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/AggregateDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/AggregateDefinition.java index c4f719b..c079a23 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/AggregateDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/AggregateDefinition.java @@ -214,6 +214,15 @@ public class AggregateDefinition extends OutputDefinition<AggregateDefinition> /** * The AggregationStrategy to use. * <p/> + * For example to lookup a bean with the name foo, the value is simply just foo. However its also possible to create + * a new class: Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true). + * <p/> * Configuring an AggregationStrategy is required, and is used to merge the incoming Exchange with the existing * already merged exchanges. At first call the oldExchange parameter is null. On subsequent invocations the * oldExchange contains the merged exchanges and newExchange is of course the new incoming Exchange. @@ -229,6 +238,21 @@ public class AggregateDefinition extends OutputDefinition<AggregateDefinition> /** * A reference to lookup the AggregationStrategy in the Registry. * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> + * <p/> * Configuring an AggregationStrategy is required, and is used to merge the incoming Exchange with the existing * already merged exchanges. At first call the oldExchange parameter is null. On subsequent invocations the * oldExchange contains the merged exchanges and newExchange is of course the new incoming Exchange. @@ -244,6 +268,21 @@ public class AggregateDefinition extends OutputDefinition<AggregateDefinition> /** * A reference to lookup the AggregationStrategy in the Registry. * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> + * <p/> * Configuring an AggregationStrategy is required, and is used to merge the incoming Exchange with the existing * already merged exchanges. At first call the oldExchange parameter is null. On subsequent invocations the * oldExchange contains the merged exchanges and newExchange is of course the new incoming Exchange. diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java index 9e4dc6a..f8727d5 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java @@ -169,6 +169,21 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio /** * To use a custom {@link AggregationStrategy} instead of the default implementation. Notice you cannot use both * custom aggregation strategy and configure data at the same time. + * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> */ public ClaimCheckDefinition aggregationStrategyRef(String aggregationStrategyRef) { setAggregationStrategyRef(aggregationStrategyRef); diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java index 94fd2da..9d28893 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/EnrichDefinition.java @@ -108,6 +108,21 @@ public class EnrichDefinition extends ExpressionNode { /** * Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing * message. By default Camel will use the reply from the external service as outgoing message. + * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> */ public EnrichDefinition aggregationStrategyRef(String aggregationStrategyRef) { setAggregationStrategyRef(aggregationStrategyRef); diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/MulticastDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/MulticastDefinition.java index a52c9d2..11f35bc 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/MulticastDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/MulticastDefinition.java @@ -149,9 +149,24 @@ public class MulticastDefinition extends OutputDefinition<MulticastDefinition> /** * Sets a reference to the AggregationStrategy to be used to assemble the replies from the multicasts, into a single * outgoing message from the Multicast. By default Camel will use the last reply as the outgoing message. You can - * also use a POJO as the AggregationStrategy If an exception is thrown from the aggregate method in the + * also use a POJO as the AggregationStrategy. If an exception is thrown from the aggregate method in the * AggregationStrategy, then by default, that exception is not handled by the error handler. The error handler can * be enabled to react if enabling the shareUnitOfWork option. + * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> */ public MulticastDefinition aggregationStrategyRef(String aggregationStrategyRef) { setStrategyRef(aggregationStrategyRef); diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java index 3105977..ca45db2 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/PollEnrichDefinition.java @@ -126,6 +126,21 @@ public class PollEnrichDefinition extends ExpressionNode { /** * Refers to an AggregationStrategy to be used to merge the reply from the external service, into a single outgoing * message. By default Camel will use the reply from the external service as outgoing message. + * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> */ public PollEnrichDefinition aggregationStrategyRef(String aggregationStrategyRef) { setAggregationStrategyRef(aggregationStrategyRef); diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/RecipientListDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/RecipientListDefinition.java index e7d2bf2..7fb784b 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/RecipientListDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/RecipientListDefinition.java @@ -161,6 +161,21 @@ public class RecipientListDefinition<Type extends ProcessorDefinition<Type>> ext * Sets a reference to the AggregationStrategy to be used to assemble the replies from the recipients, into a single * outgoing message from the RecipientList. By default Camel will use the last reply as the outgoing message. You * can also use a POJO as the AggregationStrategy + * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> */ public RecipientListDefinition<Type> aggregationStrategyRef(String aggregationStrategyRef) { setStrategyRef(aggregationStrategyRef); @@ -363,16 +378,16 @@ public class RecipientListDefinition<Type extends ProcessorDefinition<Type>> ext /** * Sets the maximum size used by the {@link org.apache.camel.spi.ProducerCache} which is used to cache and reuse * producers when using this recipient list, when uris are reused. - * + * <p> * Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic * endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both * the producers and endpoints; they are regarded as prototype scoped and will be stopped and discarded after use. * This reduces memory usage as otherwise producers/endpoints are stored in memory in the caches. - * + * <p> * However if there are a high degree of dynamic endpoints that have been used before, then it can benefit to use * the cache to reuse both producers and endpoints and therefore the cache size can be set accordingly or rely on * the default size (1000). - * + * <p> * If there is a mix of unique and used before dynamic endpoints, then setting a reasonable cache size can help * reduce memory usage to avoid storing too many non frequent used producers. * @@ -387,16 +402,16 @@ public class RecipientListDefinition<Type extends ProcessorDefinition<Type>> ext /** * Sets the maximum size used by the {@link org.apache.camel.spi.ProducerCache} which is used to cache and reuse * producers when using this recipient list, when uris are reused. - * + * <p> * Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic * endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both * the producers and endpoints; they are regarded as prototype scoped and will be stopped and discarded after use. * This reduces memory usage as otherwise producers/endpoints are stored in memory in the caches. - * + * <p> * However if there are a high degree of dynamic endpoints that have been used before, then it can benefit to use * the cache to reuse both producers and endpoints and therefore the cache size can be set accordingly or rely on * the default size (1000). - * + * <p> * If there is a mix of unique and used before dynamic endpoints, then setting a reasonable cache size can help * reduce memory usage to avoid storing too many non frequent used producers. * diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java index b6dd618..602953e 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/SplitDefinition.java @@ -146,6 +146,21 @@ public class SplitDefinition extends OutputExpressionNode implements ExecutorSer * Sets a reference to the AggregationStrategy to be used to assemble the replies from the splitted messages, into a * single outgoing message from the Splitter. By default Camel will use the original incoming message to the * splitter (leave it unchanged). You can also use a POJO as the AggregationStrategy + * <p/> + * The value can either refer to a bean to lookup, or to lookup a singleton bean by its type, or to create a new + * bean: + * <ul> + * <li>Lookup bean - This is the default behavior to lookup an existing bean by the bean id (value)</li> + * <li>reference by type - Values can refer to singleton beans by their type in the registry by prefixing with + * #type: syntax, eg #type:com.foo.MyClassType</li> + * <li>reference new class - Values can refer to creating new beans by their class name by prefixing with #class, eg + * #class:com.foo.MyClassType. The class is created using a default no-arg constructor, however if you need to + * create the instance via a factory method then you specify the method as shown: + * #class:com.foo.MyClassType#myFactoryMethod. And if the factory method requires parameters they can be specified + * as follows: #class:com.foo.MyClassType#myFactoryMethod('Hello World', 5, true). Or if you need to create the + * instance via constructor parameters then you can specify the parameters as shown: #class:com.foo.MyClass('Hello + * World', 5, true)</li>. + * </ul> */ public SplitDefinition aggregationStrategyRef(String aggregationStrategyRef) { setStrategyRef(aggregationStrategyRef); diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/AbstractReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/AbstractReifier.java index efdd572..8269e69 100644 --- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/AbstractReifier.java +++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/AbstractReifier.java @@ -23,6 +23,7 @@ import java.util.Set; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.Expression; +import org.apache.camel.NoSuchBeanException; import org.apache.camel.NoSuchEndpointException; import org.apache.camel.Predicate; import org.apache.camel.Route; @@ -152,6 +153,8 @@ public abstract class AbstractReifier implements BeanRepository { public Object lookupByName(String name) { if (name != null && name.startsWith("#class:")) { return createBean(name, Object.class); + } else if (name != null && name.startsWith("#type:")) { + return lookupBean(name, Object.class); } else { return getRegistry().lookupByName(name); } @@ -160,6 +163,8 @@ public abstract class AbstractReifier implements BeanRepository { public <T> T lookup(String name, Class<T> type) { if (name != null && name.startsWith("#class:")) { return createBean(name, type); + } else if (name != null && name.startsWith("#type:")) { + return lookupBean(name, type); } else { return lookupByNameAndType(name, type); } @@ -168,11 +173,32 @@ public abstract class AbstractReifier implements BeanRepository { public <T> T lookupByNameAndType(String name, Class<T> type) { if (name != null && name.startsWith("#class:")) { return createBean(name, type); + } else if (name != null && name.startsWith("#type:")) { + return lookupBean(name, type); } else { return getRegistry().lookupByNameAndType(name, type); } } + @Override + public <T> Map<String, T> findByTypeWithName(Class<T> type) { + return getRegistry().findByTypeWithName(type); + } + + @Override + public <T> Set<T> findByType(Class<T> type) { + return getRegistry().findByType(type); + } + + @Override + public Object unwrap(Object value) { + return getRegistry().unwrap(value); + } + + public Endpoint resolveEndpoint(String uri) throws NoSuchEndpointException { + return CamelContextHelper.getMandatoryEndpoint(camelContext, uri); + } + private <T> T createBean(String name, Class<T> type) { try { return doCreateBean(name, type); @@ -215,23 +241,26 @@ public abstract class AbstractReifier implements BeanRepository { return type.cast(answer); } - @Override - public <T> Map<String, T> findByTypeWithName(Class<T> type) { - return getRegistry().findByTypeWithName(type); - } - - @Override - public <T> Set<T> findByType(Class<T> type) { - return getRegistry().findByType(type); - } - - @Override - public Object unwrap(Object value) { - return getRegistry().unwrap(value); + private <T> T lookupBean(String name, Class<T> type) { + try { + return doLookupBean(name, type); + } catch (Exception e) { + throw RuntimeCamelException.wrapRuntimeException(e); + } } - public Endpoint resolveEndpoint(String uri) throws NoSuchEndpointException { - return CamelContextHelper.getMandatoryEndpoint(camelContext, uri); + private <T> T doLookupBean(String name, Class<T> type) throws ClassNotFoundException { + Class<?> clazz = camelContext.getClassResolver().resolveMandatoryClass(name.substring(6)); + Set<?> found = getRegistry().findByType(clazz); + if (found == null || found.isEmpty()) { + throw new NoSuchBeanException(null, clazz.getName()); + } else if (found.size() > 1) { + throw new NoSuchBeanException( + "Found " + found.size() + " beans of type: " + clazz + ". Only one bean expected."); + } else { + Object answer = found.iterator().next(); + return type.cast(answer); + } } } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java index eabe781..44f203d 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java @@ -60,7 +60,8 @@ public class EnricherRefBeanClassTest extends ContextTestSupport { public void configure() throws Exception { cool.setCamelContext(context); - from("direct:start").enrich().simple("ref:cool").aggregationStrategyRef("#class:org.apache.camel.processor.aggregate.UseLatestAggregationStrategy"); + from("direct:start").enrich().simple("ref:cool") + .aggregationStrategyRef("#class:org.apache.camel.processor.aggregate.UseLatestAggregationStrategy"); } }; } diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanTypeTest.java similarity index 88% copy from core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java copy to core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanTypeTest.java index eabe781..fc6754c 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanClassTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherRefBeanTypeTest.java @@ -22,12 +22,13 @@ import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockComponent; import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.processor.aggregate.UseLatestAggregationStrategy; import org.apache.camel.spi.Registry; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; -public class EnricherRefBeanClassTest extends ContextTestSupport { +public class EnricherRefBeanTypeTest extends ContextTestSupport { private MockEndpoint cool = new MockEndpoint("mock:cool", new MockComponent(context)); @@ -35,6 +36,7 @@ public class EnricherRefBeanClassTest extends ContextTestSupport { protected Registry createRegistry() throws Exception { Registry jndi = super.createRegistry(); jndi.bind("cool", cool); + jndi.bind("latest", new UseLatestAggregationStrategy()); return jndi; } @@ -60,7 +62,8 @@ public class EnricherRefBeanClassTest extends ContextTestSupport { public void configure() throws Exception { cool.setCamelContext(context); - from("direct:start").enrich().simple("ref:cool").aggregationStrategyRef("#class:org.apache.camel.processor.aggregate.UseLatestAggregationStrategy"); + from("direct:start").enrich().simple("ref:cool") + .aggregationStrategyRef("#type:org.apache.camel.AggregationStrategy"); } }; }
