This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new c972c3d  CAMEL-15652: Add bean scope to method call expression and 
bean function in simple language.
c972c3d is described below

commit c972c3d4cb21ec1499ea4274569c32eefb239a77
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Oct 9 07:14:28 2020 +0200

    CAMEL-15652: Add bean scope to method call expression and bean function in 
simple language.
---
 .../apache/camel/catalog/docs/bean-language.adoc   |  2 +-
 .../org/apache/camel/catalog/models/bean.json      |  2 +-
 .../org/apache/camel/catalog/models/method.json    |  2 +-
 .../org/apache/camel/language/bean/bean.json       |  2 +-
 .../camel-bean/src/main/docs/bean-language.adoc    |  2 +-
 .../resources/org/apache/camel/model/bean.json     |  2 +-
 .../org/apache/camel/model/language/method.json    |  2 +-
 .../src/main/docs/modules/eips/pages/bean-eip.adoc |  2 +-
 .../org/apache/camel/builder/ExpressionClause.java | 25 +++++++++++
 .../camel/builder/ExpressionClauseSupport.java     | 29 ++++++++++++
 .../org/apache/camel/model/BeanDefinition.java     |  8 ++--
 .../camel/model/language/MethodCallExpression.java |  8 ++--
 .../bean/MethodCallBeanTypeFunctionScopeTest.java  | 46 +++++++++++++++++++
 .../SimpleLanguageBeanTypeFunctionScopeTest.java   | 52 ++++++++++++++++++++++
 .../modules/languages/pages/bean-language.adoc     |  2 +-
 15 files changed, 169 insertions(+), 17 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/bean-language.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/bean-language.adoc
index 8b68f89..6d6a131 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/bean-language.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/bean-language.adoc
@@ -37,7 +37,7 @@ The Bean method language supports 5 options, which are listed 
below.
 | ref |  | String | Reference to bean to lookup in the registry
 | method |  | String | Name of method to call
 | beanType |  | String | Class name of the bean to use
-| scope | Singleton | String | Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same time. When using request scope the bean 
is created or looked up once per request (exchange). This can be used if you 
want to store state on a bean while processing a request and you want to call 
the same bean instance multiple time [...]
+| scope | Singleton | String | Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same time. When using request scope the bean 
is created or looked up once per request (exchange). This can be used if you 
want to store state on a bean while processing a request and you want to call 
the same bean instance multiple time [...]
 | trim | true | Boolean | Whether to trim the value to remove leading and 
trailing whitespaces and line breaks
 |===
 // language options: END
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/bean.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/bean.json
index 2fdeb6b..d4b9d1a 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/bean.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/bean.json
@@ -15,7 +15,7 @@
     "method": { "kind": "attribute", "displayName": "Method", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the method name on the bean to use" },
     "beanType": { "kind": "attribute", "displayName": "Bean Type", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the Class of the bean" },
     "cache": { "kind": "attribute", "displayName": "Cache", "required": false, 
"type": "boolean", "javaType": "java.lang.Boolean", "deprecated": true, 
"secret": false, "defaultValue": true, "description": "Use singleton option 
instead" },
-    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
+    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
     "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": 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, "secret": 
false, "description": "Sets the description of this node" }
   }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/method.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/method.json
index f5bb766..12a13f3 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/method.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/method.json
@@ -15,7 +15,7 @@
     "ref": { "kind": "attribute", "displayName": "Ref", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Reference to bean to lookup in the registry" },
     "method": { "kind": "attribute", "displayName": "Method", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Name of method to call" },
     "beanType": { "kind": "attribute", "displayName": "Bean Type", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Class name of the bean to use" },
-    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
+    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
     "trim": { "kind": "attribute", "displayName": "Trim", "required": false, 
"type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the id of this node" }
   }
diff --git 
a/components/camel-bean/src/generated/resources/org/apache/camel/language/bean/bean.json
 
b/components/camel-bean/src/generated/resources/org/apache/camel/language/bean/bean.json
index 772bec9..9651c5c 100644
--- 
a/components/camel-bean/src/generated/resources/org/apache/camel/language/bean/bean.json
+++ 
b/components/camel-bean/src/generated/resources/org/apache/camel/language/bean/bean.json
@@ -19,7 +19,7 @@
     "ref": { "kind": "attribute", "displayName": "Ref", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Reference to bean to lookup in the registry" },
     "method": { "kind": "attribute", "displayName": "Method", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Name of method to call" },
     "beanType": { "kind": "attribute", "displayName": "Bean Type", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Class name of the bean to use" },
-    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
+    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
     "trim": { "kind": "attribute", "displayName": "Trim", "required": false, 
"type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the id of this node" }
   }
diff --git a/components/camel-bean/src/main/docs/bean-language.adoc 
b/components/camel-bean/src/main/docs/bean-language.adoc
index 8b68f89..6d6a131 100644
--- a/components/camel-bean/src/main/docs/bean-language.adoc
+++ b/components/camel-bean/src/main/docs/bean-language.adoc
@@ -37,7 +37,7 @@ The Bean method language supports 5 options, which are listed 
below.
 | ref |  | String | Reference to bean to lookup in the registry
 | method |  | String | Name of method to call
 | beanType |  | String | Class name of the bean to use
-| scope | Singleton | String | Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same time. When using request scope the bean 
is created or looked up once per request (exchange). This can be used if you 
want to store state on a bean while processing a request and you want to call 
the same bean instance multiple time [...]
+| scope | Singleton | String | Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same time. When using request scope the bean 
is created or looked up once per request (exchange). This can be used if you 
want to store state on a bean while processing a request and you want to call 
the same bean instance multiple time [...]
 | trim | true | Boolean | Whether to trim the value to remove leading and 
trailing whitespaces and line breaks
 |===
 // language options: END
diff --git 
a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/bean.json
 
b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/bean.json
index 2fdeb6b..d4b9d1a 100644
--- 
a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/bean.json
+++ 
b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/bean.json
@@ -15,7 +15,7 @@
     "method": { "kind": "attribute", "displayName": "Method", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the method name on the bean to use" },
     "beanType": { "kind": "attribute", "displayName": "Bean Type", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the Class of the bean" },
     "cache": { "kind": "attribute", "displayName": "Cache", "required": false, 
"type": "boolean", "javaType": "java.lang.Boolean", "deprecated": true, 
"secret": false, "defaultValue": true, "description": "Use singleton option 
instead" },
-    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
+    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
     "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": 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, "secret": 
false, "description": "Sets the description of this node" }
   }
diff --git 
a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/language/method.json
 
b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/language/method.json
index f5bb766..12a13f3 100644
--- 
a/core/camel-core-engine/src/generated/resources/org/apache/camel/model/language/method.json
+++ 
b/core/camel-core-engine/src/generated/resources/org/apache/camel/model/language/method.json
@@ -15,7 +15,7 @@
     "ref": { "kind": "attribute", "displayName": "Ref", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Reference to bean to lookup in the registry" },
     "method": { "kind": "attribute", "displayName": "Method", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Name of method to call" },
     "beanType": { "kind": "attribute", "displayName": "Bean Type", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Class name of the bean to use" },
-    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
+    "scope": { "kind": "attribute", "displayName": "Scope", "required": false, 
"type": "enum", "javaType": "java.lang.String", "enum": [ "Prototype", 
"Request", "Singleton" ], "deprecated": false, "secret": false, "defaultValue": 
"Singleton", "description": "Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same tim [...]
     "trim": { "kind": "attribute", "displayName": "Trim", "required": false, 
"type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, 
"secret": false, "defaultValue": true, "description": "Whether to trim the 
value to remove leading and trailing whitespaces and line breaks" },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"secret": false, "description": "Sets the id of this node" }
   }
diff --git 
a/core/camel-core-engine/src/main/docs/modules/eips/pages/bean-eip.adoc 
b/core/camel-core-engine/src/main/docs/modules/eips/pages/bean-eip.adoc
index c6e7b53..e37f30c 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/bean-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/bean-eip.adoc
@@ -29,7 +29,7 @@ The Bean EIP supports 5 options which are listed below:
 | *method* | Sets the method name on the bean to use |  | String
 | *beanType* | Sets the Class of the bean |  | String
 | *cache* | *Deprecated* Use singleton option instead | true | Boolean
-| *scope* | Scope of bean. When using singleton scope (default) the bean is 
created or looked up only once and reused for the lifetime of the endpoint. The 
bean should be thread-safe in case concurrent threads is calling the bean at 
the same time. When using request scope the bean is created or looked up once 
per request (exchange). This can be used if you want to store state on a bean 
while processing a request and you want to call the same bean instance multiple 
times while processing  [...]
+| *scope* | Scope of bean. When using singleton scope (default) the bean is 
created or looked up only once and reused for the lifetime of the endpoint. The 
bean should be thread-safe in case concurrent threads is calling the bean at 
the same time. When using request scope the bean is created or looked up once 
per request (exchange). This can be used if you want to store state on a bean 
while processing a request and you want to call the same bean instance multiple 
times while processing  [...]
 |===
 // eip options: END
 
diff --git 
a/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClause.java
 
b/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClause.java
index 8c97230..e3fd6b1 100644
--- 
a/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClause.java
+++ 
b/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClause.java
@@ -295,6 +295,31 @@ public class ExpressionClause<T> implements Expression, 
Predicate {
     }
 
     /**
+     * Evaluates an expression using the <a 
href="http://camel.apache.org/bean-language.html";>bean language</a> which
+     * basically means the bean is invoked to determine the expression value.
+     *
+     * @param  beanType the Class of the bean which we want to invoke
+     * @param  scope    the scope of the bean
+     * @return          the builder to continue processing the DSL
+     */
+    public T method(Class<?> beanType, BeanScope scope) {
+        return delegate.method(beanType, scope);
+    }
+
+    /**
+     * Evaluates an expression using the <a 
href="http://camel.apache.org/bean-language.html";>bean language</a> which
+     * basically means the bean is invoked to determine the expression value.
+     *
+     * @param  beanType the Class of the bean which we want to invoke
+     * @param  method   the name of the method to invoke on the bean
+     * @param  scope    the scope of the bean
+     * @return          the builder to continue processing the DSL
+     */
+    public T method(Class<?> beanType, String method, BeanScope scope) {
+        return delegate.method(beanType, method, scope);
+    }
+
+    /**
      * Evaluates a <a href="http://camel.apache.org/groovy.html";>Groovy 
expression</a>
      *
      * @param  text the expression to be evaluated
diff --git 
a/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
 
b/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
index 37970f7..3f52873 100644
--- 
a/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
+++ 
b/core/camel-core-engine/src/main/java/org/apache/camel/builder/ExpressionClauseSupport.java
@@ -261,6 +261,35 @@ public class ExpressionClauseSupport<T> {
     }
 
     /**
+     * Evaluates an expression using the <a 
href="http://camel.apache.org/bean-language.html>bean language</a> which
+     * basically means the bean is invoked to determine the expression value.
+     *
+     * @param  beanType the Class of the bean which we want to invoke
+     * @param  scope    the scope of the bean
+     * @return          the builder to continue processing the DSL
+     */
+    public T method(Class<?> beanType, BeanScope scope) {
+        MethodCallExpression exp = new MethodCallExpression(beanType);
+        exp.setScope(scope.name());
+        return expression(exp);
+    }
+
+    /**
+     * Evaluates an expression using the <a 
href="http://camel.apache.org/bean-language.html>bean language</a> which
+     * basically means the bean is invoked to determine the expression value.
+     *
+     * @param  beanType the Class of the bean which we want to invoke
+     * @param  method   the name of the method to invoke on the bean
+     * @param  scope    the scope of the bean
+     * @return          the builder to continue processing the DSL
+     */
+    public T method(Class<?> beanType, String method, BeanScope scope) {
+        MethodCallExpression exp = new MethodCallExpression(beanType, method);
+        exp.setScope(scope.name());
+        return expression(exp);
+    }
+
+    /**
      * Evaluates a <a href="http://camel.apache.org/groovy.html";>Groovy 
expression</a>
      *
      * @param  text the expression to be evaluated
diff --git 
a/core/camel-core-engine/src/main/java/org/apache/camel/model/BeanDefinition.java
 
b/core/camel-core-engine/src/main/java/org/apache/camel/model/BeanDefinition.java
index 9f317b3..4c0cb35 100644
--- 
a/core/camel-core-engine/src/main/java/org/apache/camel/model/BeanDefinition.java
+++ 
b/core/camel-core-engine/src/main/java/org/apache/camel/model/BeanDefinition.java
@@ -186,10 +186,10 @@ public class BeanDefinition extends 
NoOutputDefinition<BeanDefinition> {
      * When using request scope the bean is created or looked up once per 
request (exchange). This can be used if you
      * want to store state on a bean while processing a request and you want 
to call the same bean instance multiple
      * times while processing the request. The bean does not have to be 
thread-safe as the instance is only called from
-     * the same request. When using delegate scope, then the bean will be 
looked up or created per call. However in case
-     * of lookup then this is delegated to the bean registry such as Spring or 
CDI (if in use), which depends on their
-     * configuration can act as either singleton or prototype scope. so when 
using delegate then this depends on the
-     * delegated registry.
+     * the same request. When using prototype scope, then the bean will be 
looked up or created per call. However in
+     * case of lookup then this is delegated to the bean registry such as 
Spring or CDI (if in use), which depends on
+     * their configuration can act as either singleton or prototype scope. so 
when using prototype scope then this
+     * depends on the bean registry implementation.
      */
     public void setScope(BeanScope scope) {
         this.scope = scope.name();
diff --git 
a/core/camel-core-engine/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
 
b/core/camel-core-engine/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
index d357ab3..3a36ae0 100644
--- 
a/core/camel-core-engine/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
+++ 
b/core/camel-core-engine/src/main/java/org/apache/camel/model/language/MethodCallExpression.java
@@ -145,10 +145,10 @@ public class MethodCallExpression extends 
ExpressionDefinition {
      * When using request scope the bean is created or looked up once per 
request (exchange). This can be used if you
      * want to store state on a bean while processing a request and you want 
to call the same bean instance multiple
      * times while processing the request. The bean does not have to be 
thread-safe as the instance is only called from
-     * the same request. When using delegate scope, then the bean will be 
looked up or created per call. However in case
-     * of lookup then this is delegated to the bean registry such as Spring or 
CDI (if in use), which depends on their
-     * configuration can act as either singleton or prototype scope. so when 
using delegate then this depends on the
-     * delegated registry.
+     * the same request. When using prototype scope, then the bean will be 
looked up or created per call. However in
+     * case of lookup then this is delegated to the bean registry such as 
Spring or CDI (if in use), which depends on
+     * their configuration can act as either singleton or prototype scope. so 
when using prototype scope then this
+     * depends on the bean registry implementation.
      */
     public void setScope(String scope) {
         this.scope = scope;
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanTypeFunctionScopeTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanTypeFunctionScopeTest.java
new file mode 100644
index 0000000..4ad2d07
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/bean/MethodCallBeanTypeFunctionScopeTest.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean;
+
+import org.apache.camel.BeanScope;
+import org.apache.camel.builder.RouteBuilder;
+
+public class MethodCallBeanTypeFunctionScopeTest extends 
SimpleLanguageBeanFunctionScopeTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:single").choice().when().method(MyBean.class, 
BeanScope.Singleton).to("mock:result")
+                        .otherwise().to("mock:other");
+
+                from("direct:proto").choice().when().method(MyBean.class, 
BeanScope.Prototype).to("mock:result")
+                        .otherwise().to("mock:other");
+
+                from("direct:request")
+                        .to("direct:sub")
+                        .to("direct:sub")
+                        .to("direct:sub");
+
+                from("direct:sub").choice().when().method(MyBean.class, 
BeanScope.Request).to("mock:result")
+                        .otherwise().to("mock:other");
+
+            }
+        };
+    }
+}
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/bean/SimpleLanguageBeanTypeFunctionScopeTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/bean/SimpleLanguageBeanTypeFunctionScopeTest.java
new file mode 100644
index 0000000..11d315c
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/bean/SimpleLanguageBeanTypeFunctionScopeTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.bean;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class SimpleLanguageBeanTypeFunctionScopeTest extends 
SimpleLanguageBeanFunctionScopeTest {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:single").choice().when().simple(
+                        
"${bean:type:org.apache.camel.component.bean.SimpleLanguageBeanFunctionScopeTest$MyBean?scope=Singleton}")
+                        .to("mock:result")
+                        .otherwise().to("mock:other");
+
+                from("direct:proto").choice().when().simple(
+                        
"${bean:type:org.apache.camel.component.bean.SimpleLanguageBeanFunctionScopeTest$MyBean?scope=Prototype}")
+                        .to("mock:result")
+                        .otherwise().to("mock:other");
+
+                from("direct:request")
+                        .to("direct:sub")
+                        .to("direct:sub")
+                        .to("direct:sub");
+
+                from("direct:sub").choice().when().simple(
+                        
"${bean:type:org.apache.camel.component.bean.SimpleLanguageBeanFunctionScopeTest$MyBean?scope=Request}")
+                        .to("mock:result")
+                        .otherwise().to("mock:other");
+
+            }
+        };
+    }
+
+}
diff --git a/docs/components/modules/languages/pages/bean-language.adoc 
b/docs/components/modules/languages/pages/bean-language.adoc
index 7fa8dd4..e488dfc 100644
--- a/docs/components/modules/languages/pages/bean-language.adoc
+++ b/docs/components/modules/languages/pages/bean-language.adoc
@@ -39,7 +39,7 @@ The Bean method language supports 5 options, which are listed 
below.
 | ref |  | String | Reference to bean to lookup in the registry
 | method |  | String | Name of method to call
 | beanType |  | String | Class name of the bean to use
-| scope | Singleton | String | Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same time. When using request scope the bean 
is created or looked up once per request (exchange). This can be used if you 
want to store state on a bean while processing a request and you want to call 
the same bean instance multiple time [...]
+| scope | Singleton | String | Scope of bean. When using singleton scope 
(default) the bean is created or looked up only once and reused for the 
lifetime of the endpoint. The bean should be thread-safe in case concurrent 
threads is calling the bean at the same time. When using request scope the bean 
is created or looked up once per request (exchange). This can be used if you 
want to store state on a bean while processing a request and you want to call 
the same bean instance multiple time [...]
 | trim | true | Boolean | Whether to trim the value to remove leading and 
trailing whitespaces and line breaks
 |===
 // language options: END

Reply via email to