You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/01/07 09:01:15 UTC

[camel] 08/08: CAMEL-14359: camel-bean - Adding bean scope option.

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

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

commit 123f92f9e7c5c36c63d08aa465358b59a41df2fd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 7 09:56:11 2020 +0100

    CAMEL-14359: camel-bean - Adding bean scope option.
---
 components/camel-bean/src/main/docs/bean-component.adoc  |  4 ++--
 components/camel-bean/src/main/docs/class-component.adoc |  4 ++--
 .../org/apache/camel/component/bean/BeanComponent.java   |  2 +-
 .../org/apache/camel/component/bean/BeanEndpoint.java    |  4 ++--
 core/camel-core-engine/src/main/docs/eips/bean-eip.adoc  | 16 ++++++++++++++--
 .../main/java/org/apache/camel/model/BeanDefinition.java | 12 ++++++++++++
 .../builder/endpoint/dsl/BeanEndpointBuilderFactory.java |  8 ++++----
 .../endpoint/dsl/ClassEndpointBuilderFactory.java        |  8 ++++----
 docs/components/modules/ROOT/pages/bean-component.adoc   |  4 ++--
 docs/components/modules/ROOT/pages/class-component.adoc  |  4 ++--
 docs/user-manual/modules/ROOT/pages/bean-eip.adoc        | 16 ++++++++++++++--
 11 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/components/camel-bean/src/main/docs/bean-component.adoc b/components/camel-bean/src/main/docs/bean-component.adoc
index d8df9fa..728f725 100644
--- a/components/camel-bean/src/main/docs/bean-component.adoc
+++ b/components/camel-bean/src/main/docs/bean-component.adoc
@@ -31,7 +31,7 @@ The Bean component supports 5 options, which are listed below.
 |===
 | Name | Description | Default | Type
 | *cache* (producer) | *Deprecated* Use singleton option instead. | true | Boolean
-| *scope* (producer) | 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  [...]
+| *scope* (producer) | 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  [...]
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
@@ -67,7 +67,7 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *cache* (common) | *Deprecated* Use scope option instead. |  | Boolean
 | *method* (common) | Sets the name of the method to invoke on the bean |  | String
-| *scope* (common) | 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 pr [...]
+| *scope* (common) | 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 pr [...]
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *parameters* (advanced) | Used for configuring additional properties on the bean |  | Map
diff --git a/components/camel-bean/src/main/docs/class-component.adoc b/components/camel-bean/src/main/docs/class-component.adoc
index 2caeb1e..864ff11 100644
--- a/components/camel-bean/src/main/docs/class-component.adoc
+++ b/components/camel-bean/src/main/docs/class-component.adoc
@@ -34,7 +34,7 @@ The Class component supports 5 options, which are listed below.
 |===
 | Name | Description | Default | Type
 | *cache* (producer) | *Deprecated* Use singleton option instead. | true | Boolean
-| *scope* (producer) | 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  [...]
+| *scope* (producer) | 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  [...]
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
@@ -70,7 +70,7 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *cache* (common) | *Deprecated* Use scope option instead. |  | Boolean
 | *method* (common) | Sets the name of the method to invoke on the bean |  | String
-| *scope* (common) | 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 pr [...]
+| *scope* (common) | 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 pr [...]
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *parameters* (advanced) | Used for configuring additional properties on the bean |  | Map
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanComponent.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanComponent.java
index 6142b4a..3168cc1 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanComponent.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanComponent.java
@@ -48,7 +48,7 @@ public class BeanComponent extends DefaultComponent {
             + " The bean should not 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.")
+            + " so when using prototype then this depends on the delegated registry.")
     private BeanScope scope = BeanScope.Singleton;
 
     public BeanComponent() {
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
index a76a22ba..2de53ba 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanEndpoint.java
@@ -50,9 +50,9 @@ public class BeanEndpoint extends DefaultEndpoint {
             + " 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 should not 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 "
+            + " 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 delegate then this depends on the delegated registry.")
+            + " so when using prototype then this depends on the delegated registry.")
     private BeanScope scope = BeanScope.Singleton;
     @UriParam(prefix = "bean.", label = "advanced", description = "Used for configuring additional properties on the bean", multiValue = true)
     private Map<String, Object> parameters;
diff --git a/core/camel-core-engine/src/main/docs/eips/bean-eip.adoc b/core/camel-core-engine/src/main/docs/eips/bean-eip.adoc
index 77f733e..6b862c8 100644
--- a/core/camel-core-engine/src/main/docs/eips/bean-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/eips/bean-eip.adoc
@@ -16,7 +16,7 @@ the xref:registry.adoc[Registry]
 == EIP options
 
 // eip options: START
-The Bean EIP supports 4 options which are listed below:
+The Bean EIP supports 5 options which are listed below:
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
@@ -24,10 +24,22 @@ The Bean EIP supports 4 options which are listed below:
 | *ref* | Sets a reference to a bean to use |  | String
 | *method* | Sets the method name on the bean to use |  | String
 | *beanType* | Sets the Class of the bean |  | String
-| *cache* | Caches the bean lookup, to avoid lookup up bean on every usage. | true | Boolean
+| *cache* | *Deprecated* Use scope option instead. |  | Boolean
+| *scope* | Scope of bean. See below for more details. | Singleton | String |
 |===
 // eip options: END
 
+=== Bean scope
+
+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 the request.
+The bean should not be thread-safe as the instance is only called from 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` then this depends on the delegated registry.
+
 == Bean as endpoint
 
 Camel also supports invoking xref:components::bean-component.adoc[Bean] as an Endpoint. In the
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 30cc5dc..3dc6b21 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
@@ -178,6 +178,18 @@ public class BeanDefinition extends NoOutputDefinition<BeanDefinition> {
         this.scope = 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 the request.
+     * The bean should not 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.
+     */
     public void setScope(BeanScope scope) {
         this.scope = scope.name();
     }
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java
index b7b49ff..8325253 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java
@@ -84,11 +84,11 @@ public interface BeanEndpointBuilderFactory {
          * 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 should not be thread-safe as the
-         * instance is only called from the same request. When using delegate
+         * instance is only called from 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 delegate
+         * act as either singleton or prototype scope. so when using prototype
          * then this depends on the delegated registry.
          * 
          * The option is a: <code>org.apache.camel.BeanScope</code> type.
@@ -108,11 +108,11 @@ public interface BeanEndpointBuilderFactory {
          * 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 should not be thread-safe as the
-         * instance is only called from the same request. When using delegate
+         * instance is only called from 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 delegate
+         * act as either singleton or prototype scope. so when using prototype
          * then this depends on the delegated registry.
          * 
          * The option will be converted to a
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java
index 0624ba3..93bae90 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java
@@ -84,11 +84,11 @@ public interface ClassEndpointBuilderFactory {
          * 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 should not be thread-safe as the
-         * instance is only called from the same request. When using delegate
+         * instance is only called from 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 delegate
+         * act as either singleton or prototype scope. so when using prototype
          * then this depends on the delegated registry.
          * 
          * The option is a: <code>org.apache.camel.BeanScope</code> type.
@@ -108,11 +108,11 @@ public interface ClassEndpointBuilderFactory {
          * 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 should not be thread-safe as the
-         * instance is only called from the same request. When using delegate
+         * instance is only called from 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 delegate
+         * act as either singleton or prototype scope. so when using prototype
          * then this depends on the delegated registry.
          * 
          * The option will be converted to a
diff --git a/docs/components/modules/ROOT/pages/bean-component.adoc b/docs/components/modules/ROOT/pages/bean-component.adoc
index 286bfd4..18e8f7d 100644
--- a/docs/components/modules/ROOT/pages/bean-component.adoc
+++ b/docs/components/modules/ROOT/pages/bean-component.adoc
@@ -32,7 +32,7 @@ The Bean component supports 5 options, which are listed below.
 |===
 | Name | Description | Default | Type
 | *cache* (producer) | *Deprecated* Use singleton option instead. | true | Boolean
-| *scope* (producer) | 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  [...]
+| *scope* (producer) | 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  [...]
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
@@ -68,7 +68,7 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *cache* (common) | *Deprecated* Use scope option instead. |  | Boolean
 | *method* (common) | Sets the name of the method to invoke on the bean |  | String
-| *scope* (common) | 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 pr [...]
+| *scope* (common) | 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 pr [...]
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *parameters* (advanced) | Used for configuring additional properties on the bean |  | Map
diff --git a/docs/components/modules/ROOT/pages/class-component.adoc b/docs/components/modules/ROOT/pages/class-component.adoc
index e657e82..674f2ad 100644
--- a/docs/components/modules/ROOT/pages/class-component.adoc
+++ b/docs/components/modules/ROOT/pages/class-component.adoc
@@ -35,7 +35,7 @@ The Class component supports 5 options, which are listed below.
 |===
 | Name | Description | Default | Type
 | *cache* (producer) | *Deprecated* Use singleton option instead. | true | Boolean
-| *scope* (producer) | 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  [...]
+| *scope* (producer) | 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  [...]
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
@@ -71,7 +71,7 @@ with the following path and query parameters:
 | Name | Description | Default | Type
 | *cache* (common) | *Deprecated* Use scope option instead. |  | Boolean
 | *method* (common) | Sets the name of the method to invoke on the bean |  | String
-| *scope* (common) | 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 pr [...]
+| *scope* (common) | 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 pr [...]
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
 | *parameters* (advanced) | Used for configuring additional properties on the bean |  | Map
diff --git a/docs/user-manual/modules/ROOT/pages/bean-eip.adoc b/docs/user-manual/modules/ROOT/pages/bean-eip.adoc
index ddb5e4b..1f1fce4 100644
--- a/docs/user-manual/modules/ROOT/pages/bean-eip.adoc
+++ b/docs/user-manual/modules/ROOT/pages/bean-eip.adoc
@@ -17,7 +17,7 @@ the xref:registry.adoc[Registry]
 == EIP options
 
 // eip options: START
-The Bean EIP supports 4 options which are listed below:
+The Bean EIP supports 5 options which are listed below:
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
@@ -25,10 +25,22 @@ The Bean EIP supports 4 options which are listed below:
 | *ref* | Sets a reference to a bean to use |  | String
 | *method* | Sets the method name on the bean to use |  | String
 | *beanType* | Sets the Class of the bean |  | String
-| *cache* | Caches the bean lookup, to avoid lookup up bean on every usage. | true | Boolean
+| *cache* | *Deprecated* Use scope option instead. |  | Boolean
+| *scope* | Scope of bean. See below for more details. | Singleton | String |
 |===
 // eip options: END
 
+=== Bean scope
+
+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 the request.
+The bean should not be thread-safe as the instance is only called from 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` then this depends on the delegated registry.
+
 == Bean as endpoint
 
 Camel also supports invoking xref:components::bean-component.adoc[Bean] as an Endpoint. In the