This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new f05b4efd29d CAMEL-20410: documentation fixes for camel-bean f05b4efd29d is described below commit f05b4efd29d41c8945ff198ceb60314101fb8b12 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Fri Feb 16 12:30:09 2024 +0100 CAMEL-20410: documentation fixes for camel-bean - Fixed samples - Converted to use tabs - Fixed grammar and typos - Fixed punctuation - Added and/or fixed links --- .../camel-bean/src/main/docs/bean-component.adoc | 44 ++++++++++++---------- .../camel-bean/src/main/docs/bean-language.adoc | 30 +++++++++------ .../camel-bean/src/main/docs/class-component.adoc | 17 ++++----- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/components/camel-bean/src/main/docs/bean-component.adoc b/components/camel-bean/src/main/docs/bean-component.adoc index f723cdb7950..2267c6cdc90 100644 --- a/components/camel-bean/src/main/docs/bean-component.adoc +++ b/components/camel-bean/src/main/docs/bean-component.adoc @@ -23,8 +23,7 @@ The Bean component binds beans to Camel message exchanges. bean:beanName[?options] ---- -Where *beanName* can be any string which is used to look up the bean in -the Registry +Where `beanName` can be any string used to look up the bean in the Registry // component-configure options: START @@ -45,7 +44,7 @@ include::partial$component-endpoint-headers.adoc[] == Examples -A *bean:* endpoint cannot be defined as the input to the route; i.e. you +A *bean:* endpoint cannot be defined as the input to the route; i.e., you cannot consume from it, you can only route from some inbound message Endpoint to the bean endpoint as output, such as the *direct* endpoint as input. @@ -63,16 +62,20 @@ public class MyBean { } ---- -Then the bean can be called in a Camel route by the fully qualified classname: +Then the bean can be called in a Camel route by the fully qualified class name: +[tabs] +==== +Java:: ++ [source,java] ---- from("direct:hello") .to("bean:com.foo.MyBean"); ---- -And in XML DSL: - +XML:: ++ [source,xml] ---------------------------- <route> @@ -80,38 +83,42 @@ And in XML DSL: <to uri="bean:com.foo.MyBean"/> </route> ---------------------------- +==== What happens is that when the exchange is routed to the MyBean, then Camel will use the Bean Binding to invoke the bean, in this case the _saySomething_ method, by converting the `Exchange` in body to the `String` type and storing the output of the method back to the Exchange again. -TIP: The bean component can also call a bean by _bean id_ by looking up the bean +[TIP] +==== +The bean component can also call a bean by _bean id_ by looking up the bean in the xref:manual::registry.adoc[Registry] instead of using the class name. +==== == Java DSL specific bean syntax Java DSL comes with syntactic sugar for the xref:bean-component.adoc[Bean] component. Instead of specifying the bean explicitly as the endpoint -(i.e. `to("bean:beanName")`) you can use the following syntax: +(i.e., `to("bean:beanName")`) you can use the following syntax: [source,java] ------------------------------------------------------- -// Send message to the bean endpoint -// and invoke method resolved using Bean Binding. +// Send a message to the bean endpoint +// and invoke method using Bean Binding. from("direct:start").bean("beanName"); -// Send message to the bean endpoint +// Send a message to the bean endpoint // and invoke given method. from("direct:start").bean("beanName", "methodName"); ------------------------------------------------------- -Instead of passing name of the reference to the bean (so that Camel will -lookup for it in the xref:manual::registry.adoc[Registry]), you can specify the bean itself: +Instead of passing the name of the reference to the bean (so that Camel will +look up for it in the xref:manual::registry.adoc[Registry]), you can specify the bean itself: [source,java] --------------------------------------------------------------- -// Send message to the given bean instance. +// Send a message to the given bean instance. from("direct:start").bean(new ExampleBean()); // Explicit selection of bean method to be invoked. @@ -136,13 +143,10 @@ from("direct:start") == Bean Binding -How bean methods to be invoked are chosen (if they are not specified -explicitly through the *method* parameter) and how parameter values are -constructed from the Message are all defined by the -xref:manual::bean-binding.adoc[Bean Binding] mechanism which is used throughout -all the various xref:manual::bean-integration.adoc[Bean Integration] mechanisms in Camel. +The xref:manual::bean-binding.adoc[Bean Binding] mechanism defines how methods to be invoked are chosen (if they are not specified +explicitly through the *method* parameter) and how parameter values are constructed from the Message. +These are used throughout all the various xref:manual::bean-integration.adoc[Bean Integration] mechanisms in Camel. See also related xref:languages:bean-language.adoc[Bean Language]. - include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-bean/src/main/docs/bean-language.adoc b/components/camel-bean/src/main/docs/bean-language.adoc index f7138e4e5ce..560524e5de3 100644 --- a/components/camel-bean/src/main/docs/bean-language.adoc +++ b/components/camel-bean/src/main/docs/bean-language.adoc @@ -14,9 +14,9 @@ The Bean language is used for calling a method on an existing Java bean. Camel adapts to the method being called via xref:manual::bean-binding.adoc[Bean Binding]. -The binding process will for example automatic convert the message payload to the parameter -of type of the first parameter in the method. The binding process has a lot more features so -it is recommended to read the xref:manual::bean-binding.adoc[Bean Binding] documentation for mor details. +The binding process will, for example, automatically convert the message payload to the parameter +of type of the first parameter in the method. +The binding process has a lot more features, so it is recommended to read the xref:manual::bean-binding.adoc[Bean Binding] documentation for mor details. == Bean Method options @@ -30,18 +30,25 @@ In the given route below, we call a Java Bean Method with `method`, where "myBea is the id of the bean to use (lookup from xref:manual::registry.adoc[Registry]), and "isGoldCustomer" is the name of the method to call. +[tabs] +==== +Java:: ++ [source,java] ---- from("activemq:topic:OrdersTopic") .filter().method("myBean", "isGoldCustomer") .to("activemq:BigSpendersQueue"); ---- - -TIP: It is also possible to omit the method name, then Camel would have to choose the best suitable -method to use; this process is a complex, so it is good practice to specify the method name, - -And in XML DSL - ++ +[TIP] +===== +It is also possible to omit the method name. In this case, then Camel would choose the best suitable +method to use. This process is complex, so it is good practice to specify the method name. +===== + +XML:: ++ [source,xml] ---- <route> @@ -52,6 +59,7 @@ And in XML DSL </filter> </route> ---- +==== The bean could be implemented as follows: @@ -65,7 +73,7 @@ public class MyBean { ---- How this method uses `Exchange` in the method signature. You would often not do that, -and use non Camel types. For example by using `String` then Camel will automatically +and use non-Camel types. For example, by using `String` then Camel will automatically convert the message body to this type when calling the method: [source,java] @@ -102,7 +110,7 @@ from("activemq:topic:OrdersTopic") .to("activemq:BigSpendersQueue"); ---- -The 1st parameter can also be an existing instance of a Bean such as: +The first parameter can also be an existing instance of a Bean such as: [source,java] ---- diff --git a/components/camel-bean/src/main/docs/class-component.adoc b/components/camel-bean/src/main/docs/class-component.adoc index b3e2c93b196..606d5bb7bf7 100644 --- a/components/camel-bean/src/main/docs/class-component.adoc +++ b/components/camel-bean/src/main/docs/class-component.adoc @@ -16,8 +16,8 @@ *{component-header}* The Class component binds beans to Camel message exchanges. It works -in the same way as the xref:bean-component.adoc[Bean] component but instead of -looking up beans from a Registry it creates the bean +in the same way as the xref:bean-component.adoc[Bean] component, but instead of +looking up beans from a Registry, it creates the bean based on the class name. == URI format @@ -26,8 +26,7 @@ based on the class name. class:className[?options] ---- -Where *className* is the fully qualified class name to create and use as -bean. +Where `className` is the fully qualified class name to create and use as bean. // component-configure options: START @@ -50,8 +49,8 @@ include::partial$component-endpoint-headers.adoc[] == Using You simply use the *class* component just as the xref:bean-component.adoc[Bean] -component but by specifying the fully qualified classname instead. + - For example to use the `MyFooBean` you have to do as follows: +component but by specifying the fully qualified class name instead. +For example to use the `MyFooBean` you have to do as follows: [source,java] ------------------------------------------------------------------------------------------------- @@ -73,7 +72,7 @@ from("direct:start") == Setting properties on the created instance In the endpoint uri you can specify properties to set on the created -instance, for example if it has a `setPrefix` method: +instance, for example, if it has a `setPrefix` method: [source,java] --------------------------------------------------------------------------------- @@ -92,13 +91,13 @@ from("direct:start") .to("mock:result"); -------------------------------------------------------------------------------- -Which will lookup a bean from the Registry with the +Which will look up a bean from the Registry with the id `foo` and invoke the `setCool` method on the created instance of the `MyPrefixBean` class. [TIP] ==== -See more details at the xref:bean-component.adoc[Bean] component as the *class* +See more details on the xref:bean-component.adoc[Bean] component as the *class* component works in much the same way. ====