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


The following commit(s) were added to refs/heads/main by this push:
     new ff6c17ac05f Update docs about bean binding and returning Exchange is 
not permitted.
ff6c17ac05f is described below

commit ff6c17ac05fe8561e4f4a2ec0fa204fdf75e1683
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Oct 15 17:51:31 2024 +0200

    Update docs about bean binding and returning Exchange is not permitted.
---
 .../component/bean/BeanExchangeInputTest.java      | 60 ++++++++++++++++++++++
 .../modules/ROOT/pages/bean-binding.adoc           |  5 +-
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanExchangeInputTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanExchangeInputTest.java
new file mode 100644
index 00000000000..62ac1d6358e
--- /dev/null
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanExchangeInputTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spi.Registry;
+import org.junit.jupiter.api.Test;
+
+public class BeanExchangeInputTest extends ContextTestSupport {
+
+    @Test
+    public void testExchangeInput() throws Exception {
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:in", "World");
+
+        result.assertIsSatisfied();
+    }
+
+    @Override
+    protected Registry createCamelRegistry() throws Exception {
+        Registry answer = super.createCamelRegistry();
+        answer.bind("myBean", new MyBean());
+        return answer;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:in").to("bean:myBean").to("mock:result");
+            }
+        };
+    }
+
+    public static class MyBean {
+        public String doSomething(Exchange exchange) {
+            return "Hello " + exchange.getMessage().getBody(String.class);
+        }
+    }
+
+}
diff --git a/docs/user-manual/modules/ROOT/pages/bean-binding.adoc 
b/docs/user-manual/modules/ROOT/pages/bean-binding.adoc
index f5a951f80e9..4d648474d95 100644
--- a/docs/user-manual/modules/ROOT/pages/bean-binding.adoc
+++ b/docs/user-manual/modules/ROOT/pages/bean-binding.adoc
@@ -33,8 +33,9 @@ can use the same mechanism to integrate Camel into any other
 messaging/remoting frameworks.
 * the type of the body is used to find a matching method; an
 error is thrown if a single method cannot be chosen unambiguously.
-* you can also use `Exchange` as the parameter itself, but then the return
-type must be void.
+* you can also use `Exchange` as the parameter itself
+* the return type cannot be `Exchange`. However, you can use `Exchange` as 
input parameter, and let
+the method be `void`, or return some other Object type (cannot be `Exchange`).
 * if the bean class is private (or package-private), interface methods
 will be preferred since Camel can't invoke class methods on such beans
 

Reply via email to