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 cbd1972c3f9 CAMEL-21851: camel-bean - Improve method selector cbd1972c3f9 is described below commit cbd1972c3f908101cb63edca677f19c19b029316 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Mar 7 21:58:02 2025 +0100 CAMEL-21851: camel-bean - Improve method selector --- .../org/apache/camel/catalog/components/bean.json | 3 - .../org/apache/camel/catalog/components/class.json | 3 - .../org/apache/camel/component/bean/bean.json | 3 - .../apache/camel/component/beanclass/class.json | 3 - .../component/bean/AbstractBeanProcessor.java | 16 +- .../apache/camel/component/bean/BeanConstants.java | 6 +- .../apache/camel/component/bean/BeanEndpoint.java | 2 +- .../org/apache/camel/component/bean/BeanInfo.java | 7 +- .../apache/camel/component/bean/MethodInfo.java | 4 +- .../camel/component/beanclass/ClassEndpoint.java | 3 +- .../apache/camel/language/bean/BeanExpression.java | 3 +- .../src/main/docs/cxf-component.adoc | 35 ----- .../jms/issues/JmsBeanMethodHeaderTest.java | 169 --------------------- .../camel/dataformat/soap/SoapConstants.java} | 13 +- .../camel/dataformat/soap/SoapDataFormat.java | 4 +- .../camel/dataformat/soap/SoapCxfClientTest.java | 4 +- .../camel/component/undertow/ExchangeHeaders.java | 2 +- .../src/main/java/org/apache/camel/Exchange.java | 1 + .../bean/BeanMethodNameHeaderIssueTest.java | 77 ---------- .../component/bean/BeanWithMethodHeaderTest.java | 35 ----- .../language/BeanAnnotationParameterTest.java | 13 -- .../language/BeanAnnotationParameterTwoTest.java | 13 -- .../org/apache/camel/processor/BeanRouteTest.java | 109 ------------- .../modules/ROOT/pages/bean-binding.adoc | 7 +- .../ROOT/pages/camel-4x-upgrade-guide-4_10.adoc | 10 ++ .../ROOT/pages/camel-4x-upgrade-guide-4_11.adoc | 10 ++ .../endpoint/dsl/BeanEndpointBuilderFactory.java | 36 ----- .../endpoint/dsl/ClassEndpointBuilderFactory.java | 36 ----- 28 files changed, 53 insertions(+), 574 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean.json index b1ff6b805ce..ba627520d66 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/bean.json @@ -29,9 +29,6 @@ "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] "beanInfoCacheSize": { "index": 3, "kind": "property", "displayName": "Bean Info Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Maximum cache size of internal cache for bean introspection. Setting a value of 0 or negative will disable the cache." } }, - "headers": { - "CamelBeanMethodName": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the method to invoke.", "constantName": "org.apache.camel.component.bean.BeanConstants#BEAN_METHOD_NAME" } - }, "properties": { "beanName": { "index": 0, "kind": "path", "displayName": "Bean Name", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the name of the bean to invoke" }, "method": { "index": 1, "kind": "parameter", "displayName": "Method", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the method to invoke on the bean" }, diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/class.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/class.json index 0bbba3802d0..0ae264c814f 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/class.json +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/class.json @@ -29,9 +29,6 @@ "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] "beanInfoCacheSize": { "index": 3, "kind": "property", "displayName": "Bean Info Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Maximum cache size of internal cache for bean introspection. Setting a value of 0 or negative will disable the cache." } }, - "headers": { - "CamelBeanMethodName": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the method to invoke.", "constantName": "org.apache.camel.component.bean.BeanConstants#BEAN_METHOD_NAME" } - }, "properties": { "beanName": { "index": 0, "kind": "path", "displayName": "Bean Name", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the name of the bean to invoke" }, "method": { "index": 1, "kind": "parameter", "displayName": "Method", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the method to invoke on the bean" }, diff --git a/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/bean/bean.json b/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/bean/bean.json index b1ff6b805ce..ba627520d66 100644 --- a/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/bean/bean.json +++ b/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/bean/bean.json @@ -29,9 +29,6 @@ "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] "beanInfoCacheSize": { "index": 3, "kind": "property", "displayName": "Bean Info Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Maximum cache size of internal cache for bean introspection. Setting a value of 0 or negative will disable the cache." } }, - "headers": { - "CamelBeanMethodName": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the method to invoke.", "constantName": "org.apache.camel.component.bean.BeanConstants#BEAN_METHOD_NAME" } - }, "properties": { "beanName": { "index": 0, "kind": "path", "displayName": "Bean Name", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the name of the bean to invoke" }, "method": { "index": 1, "kind": "parameter", "displayName": "Method", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the method to invoke on the bean" }, diff --git a/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/beanclass/class.json b/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/beanclass/class.json index 0bbba3802d0..0ae264c814f 100644 --- a/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/beanclass/class.json +++ b/components/camel-bean/src/generated/resources/META-INF/org/apache/camel/component/beanclass/class.json @@ -29,9 +29,6 @@ "autowiredEnabled": { "index": 2, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...] "beanInfoCacheSize": { "index": 3, "kind": "property", "displayName": "Bean Info Cache Size", "group": "advanced", "label": "advanced", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 1000, "description": "Maximum cache size of internal cache for bean introspection. Setting a value of 0 or negative will disable the cache." } }, - "headers": { - "CamelBeanMethodName": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the method to invoke.", "constantName": "org.apache.camel.component.bean.BeanConstants#BEAN_METHOD_NAME" } - }, "properties": { "beanName": { "index": 0, "kind": "path", "displayName": "Bean Name", "group": "common", "label": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Sets the name of the bean to invoke" }, "method": { "index": 1, "kind": "parameter", "displayName": "Method", "group": "common", "label": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the name of the method to invoke on the bean" }, diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java index 6f184389ea5..5c95e2d2282 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/AbstractBeanProcessor.java @@ -61,9 +61,8 @@ public abstract class AbstractBeanProcessor extends AsyncProcessorSupport { @Override public boolean process(Exchange exchange, AsyncCallback callback) { - // do we have an explicit method name we always should invoke (either configured on endpoint or as a header) - final String explicitMethodName = exchange.getIn().getHeader(BeanConstants.BEAN_METHOD_NAME, method, String.class); - + // do we have an explicit method name we always should invoke + final String explicitMethodName = method; final Object beanInstance; final BeanInfo beanInfo; try { @@ -83,7 +82,6 @@ public abstract class AbstractBeanProcessor extends AsyncProcessorSupport { final Processor target = getCustomAdapter(exchange, beanInstance); if (target != null) { useCustomAdapter(exchange, callback, target); - return true; } } @@ -95,22 +93,22 @@ public abstract class AbstractBeanProcessor extends AsyncProcessorSupport { Exchange exchange, AsyncCallback callback, String explicitMethodName, BeanInfo beanInfo, Object beanInstance) { final Message in = exchange.getIn(); - // set explicit method name to invoke as a header, which is how BeanInfo can detect it + // set explicit method name to invoke as a exchange property, which is how BeanInfo can detect it if (explicitMethodName != null) { - in.setHeader(BeanConstants.BEAN_METHOD_NAME, explicitMethodName); + exchange.setProperty(BeanConstants.BEAN_METHOD_NAME, explicitMethodName); } final MethodInvocation invocation; try { - invocation = beanInfo.createInvocation(beanInstance, exchange); + invocation = beanInfo.createInvocation(beanInstance, exchange, explicitMethodName); } catch (Exception e) { exchange.setException(e); callback.done(true); return true; } finally { - // must remove headers as they were provisional + // must remove property as they were provisional if (explicitMethodName != null) { - in.removeHeader(Exchange.BEAN_METHOD_NAME); + exchange.removeProperty(BeanConstants.BEAN_METHOD_NAME); } } diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java index 2048da17e9c..39e286c5f33 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java @@ -16,13 +16,9 @@ */ package org.apache.camel.component.bean; -import org.apache.camel.Exchange; -import org.apache.camel.spi.Metadata; - public final class BeanConstants { - @Metadata(description = "The name of the method to invoke.", javaType = "String") - public static final String BEAN_METHOD_NAME = Exchange.BEAN_METHOD_NAME; + public static final String BEAN_METHOD_NAME = "CamelBeanMethodName"; private BeanConstants() { // Utility class 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 eef1c278bc2..c9a008d35a5 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 @@ -35,7 +35,7 @@ import org.apache.camel.support.DefaultEndpoint; * Invoke methods of Java beans stored in Camel registry. */ @UriEndpoint(firstVersion = "1.0.0", scheme = "bean", title = "Bean", syntax = "bean:beanName", producerOnly = true, - remote = false, category = { Category.CORE, Category.SCRIPT }, headersClass = BeanConstants.class) + remote = false, category = { Category.CORE, Category.SCRIPT }) public class BeanEndpoint extends DefaultEndpoint { private transient BeanHolder beanHolder; private transient BeanProcessor processor; diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java index aa8e1d9e0f0..8127b34aee8 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -182,12 +182,15 @@ public class BeanInfo { return camelContext; } - public MethodInvocation createInvocation(Object pojo, Exchange exchange) + public MethodInvocation createInvocation(Object pojo, Exchange exchange) { + return createInvocation(pojo, exchange, null); + } + + public MethodInvocation createInvocation(Object pojo, Exchange exchange, String methodName) throws AmbiguousMethodCallException, MethodNotFoundException { MethodInfo methodInfo = null; - String methodName = exchange.getIn().getHeader(BeanConstants.BEAN_METHOD_NAME, String.class); if (methodName != null) { // do not use qualifier for name diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java index 6b553fcd073..52a1f19a766 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java @@ -581,7 +581,7 @@ public class MethodInfo { // if there was an explicit method name to invoke, then we should support using // any provided parameter values in the method name - String methodName = exchange.getIn().getHeader(BeanConstants.BEAN_METHOD_NAME, String.class); + String methodName = exchange.getProperty(BeanConstants.BEAN_METHOD_NAME, String.class); // the parameter values is between the parenthesis String methodParameters = StringHelper.betweenOuterPair(methodName, '(', ')'); // use an iterator to walk the parameter values @@ -598,7 +598,7 @@ public class MethodInfo { // a @Bean expression which would by mistake read these headers. So the headers // must be removed at this point of time if (methodName != null) { - exchange.getIn().removeHeader(Exchange.BEAN_METHOD_NAME); + exchange.removeProperty(BeanConstants.BEAN_METHOD_NAME); } Object[] answer = evaluateParameterExpressions(exchange, body, it); diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java b/components/camel-bean/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java index 5c9459fdfda..f00b922d4ef 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/beanclass/ClassEndpoint.java @@ -18,7 +18,6 @@ package org.apache.camel.component.beanclass; import org.apache.camel.Category; import org.apache.camel.Component; -import org.apache.camel.component.bean.BeanConstants; import org.apache.camel.component.bean.BeanEndpoint; import org.apache.camel.spi.UriEndpoint; @@ -26,7 +25,7 @@ import org.apache.camel.spi.UriEndpoint; * Invoke methods of Java beans specified by class name. */ @UriEndpoint(firstVersion = "2.4.0", scheme = "class", title = "Class", syntax = "class:beanName", producerOnly = true, - remote = false, category = { Category.CORE, Category.SCRIPT }, headersClass = BeanConstants.class) + remote = false, category = { Category.CORE, Category.SCRIPT }) public class ClassEndpoint extends BeanEndpoint { public ClassEndpoint(String endpointUri, Component component) { diff --git a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java index aa502a2b47b..049a152022d 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java +++ b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java @@ -30,6 +30,7 @@ import org.apache.camel.Predicate; import org.apache.camel.RuntimeCamelException; import org.apache.camel.TypeConverter; import org.apache.camel.component.bean.BeanComponent; +import org.apache.camel.component.bean.BeanConstants; import org.apache.camel.component.bean.BeanExpressionProcessor; import org.apache.camel.component.bean.BeanHolder; import org.apache.camel.component.bean.BeanInfo; @@ -407,7 +408,7 @@ public class BeanExpression implements Expression, Predicate { resultExchange.setPattern(ExchangePattern.InOut); // do not propagate any method name when using OGNL, as with OGNL we // compute and provide the method name to explicit to invoke - resultExchange.getIn().removeHeader(Exchange.BEAN_METHOD_NAME); + resultExchange.removeProperty(BeanConstants.BEAN_METHOD_NAME); // current ognl path as we go along String ognlPath = ""; diff --git a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc index 341e3e41fa3..3665755c975 100644 --- a/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc +++ b/components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc @@ -612,41 +612,6 @@ We can then create the simplest CXF service (note we didn't specify the `POJO` m }); ---- -For more dynamic implementation, we can create the implementation class as follows: - -[source,java] ----- - -package org.apache.camel.component.cxf.soap.server; - -import jakarta.jws.WebService; - -@WebService(name = "TextService", serviceName = "TextService", targetNamespace = "http://server.soap.cxf.component.camel.apache.org/") -public class TextServiceImpl implements TextService { - - @Override - public String upperCase(String text) { - return text.toUpperCase(); - } - - @Override - public String lowerCase(String text) { - return text.toLowerCase(); - } -} - ----- - - -Then we can use xref:components::quartz-component.adoc[Bean Component] (don't forget to add `camel-bean` dependency to your project) invocation based on requested operation name: - -[source,java] ----- - from("cxf:textServiceResponseFromImpl?serviceClass=org.apache.camel.component.cxf.soap.server.TextService&address=/text-impl") - .process(exchange -> exchange.getIn().setHeader(BeanConstants.BEAN_METHOD_NAME, exchange.getIn().getHeader(CxfConstants.OPERATION_NAME))) - .to("bean:org.apache.camel.component.cxf.soap.server.TextServiceImpl"); ----- - === How to prepare the message for the Camel CXF endpoint in POJO data format The Camel CXF endpoint producer is based on the diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsBeanMethodHeaderTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsBeanMethodHeaderTest.java deleted file mode 100644 index 26c4d821cca..00000000000 --- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsBeanMethodHeaderTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.jms.issues; - -import jakarta.jms.ConnectionFactory; - -import org.apache.camel.BindToRegistry; -import org.apache.camel.Body; -import org.apache.camel.CamelContext; -import org.apache.camel.ConsumerTemplate; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.jms.AbstractJMSTest; -import org.apache.camel.component.jms.ClassicJmsHeaderFilterStrategy; -import org.apache.camel.component.jms.JmsComponent; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.test.infra.core.CamelContextExtension; -import org.apache.camel.test.infra.core.DefaultCamelContextExtension; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -/** - * Unit test for sending the bean method name as a key over the JMS wire, that we now support this. - */ -public class JmsBeanMethodHeaderTest extends AbstractJMSTest { - - @Order(2) - @RegisterExtension - public static CamelContextExtension camelContextExtension = new DefaultCamelContextExtension(); - protected CamelContext context; - protected ProducerTemplate template; - protected ConsumerTemplate consumer; - @BindToRegistry("approveService") - private final ApproveService service = new ApproveService(); - - @Test - public void testPlainHeader() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedBodiesReceived("Hello World"); - mock.expectedHeaderReceived("foo", "yes"); - - template.sendBodyAndHeader("direct:in", "Hello World", "foo", "yes"); - - mock.assertIsSatisfied(); - } - - @Test - public void testUnderscoreHeader() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedBodiesReceived("Hello World"); - mock.expectedHeaderReceived("foo_bar", "yes"); - - template.sendBodyAndHeader("direct:in", "Hello World", "foo_bar", "yes"); - - mock.assertIsSatisfied(); - } - - @Test - public void testUsingBeanNoJMS() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:approve"); - mock.expectedBodiesReceived("Yes"); - - template.sendBodyAndHeader("direct:approve", ExchangePattern.InOut, "James", Exchange.BEAN_METHOD_NAME, "approveLoan"); - - mock.assertIsSatisfied(); - } - - @Test - public void testUsingBeanAndJMS() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:approve"); - mock.expectedBodiesReceived("Yes"); - - template.sendBodyAndHeader("activemq:JmsBeanMethodHeaderTest.approve", ExchangePattern.InOut, "James", - Exchange.BEAN_METHOD_NAME, - "approveLoan"); - - mock.assertIsSatisfied(); - } - - @Test - public void testUsingJMStoJMStoBean() throws Exception { - // the big one from jms to jms to test that we do not lost the bean - // method name - MockEndpoint mock = getMockEndpoint("mock:approve"); - mock.expectedBodiesReceived("No"); - - template.sendBodyAndHeader("activemq:JmsBeanMethodHeaderTest.queue", ExchangePattern.InOut, "James", - Exchange.BEAN_METHOD_NAME, - "approveSuperLoan"); - - mock.assertIsSatisfied(); - } - - @Override - protected String getComponentName() { - return "activemq"; - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:in").to("activemq:JmsBeanMethodHeaderTest.a"); - from("activemq:JmsBeanMethodHeaderTest.a").to("mock:result"); - - from("activemq:JmsBeanMethodHeaderTest.queue").to("activemq:JmsBeanMethodHeaderTest.approve"); - - from("activemq:JmsBeanMethodHeaderTest.approve").to("direct:approve"); - - from("direct:approve").to("bean:approveService").to("mock:approve"); - } - }; - } - - @Override - public CamelContextExtension getCamelContextExtension() { - return camelContextExtension; - } - - @Override - protected JmsComponent buildComponent(ConnectionFactory connectionFactory) { - JmsComponent amq = super.buildComponent(connectionFactory); - // need to use the classic header filter - amq.setHeaderFilterStrategy(new ClassicJmsHeaderFilterStrategy()); - return amq; - } - - @BeforeEach - void setUpRequirements() { - context = camelContextExtension.getContext(); - template = camelContextExtension.getProducerTemplate(); - consumer = camelContextExtension.getConsumerTemplate(); - } - - public static class ApproveService { - - public void doSomeStuff(String input) { - // just to confuse Camel with more public methods to choose among - } - - public String approveLoan(@Body String body) { - return "Yes"; - } - - public String approveSuperLoan(@Body String body) { - return "No"; - } - - } - -} diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java b/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapConstants.java similarity index 68% copy from components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java copy to components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapConstants.java index 2048da17e9c..998b9d6bdaa 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanConstants.java +++ b/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapConstants.java @@ -14,17 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.component.bean; +package org.apache.camel.dataformat.soap; -import org.apache.camel.Exchange; -import org.apache.camel.spi.Metadata; +public final class SoapConstants { -public final class BeanConstants { + public static String SOAP_METHOD_NAME = "CamelSoapMethodName"; - @Metadata(description = "The name of the method to invoke.", javaType = "String") - public static final String BEAN_METHOD_NAME = Exchange.BEAN_METHOD_NAME; - - private BeanConstants() { - // Utility class + private SoapConstants() { } } diff --git a/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapDataFormat.java b/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapDataFormat.java index b64739ee0a8..512829f1cfa 100644 --- a/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapDataFormat.java +++ b/components/camel-soap/src/main/java/org/apache/camel/dataformat/soap/SoapDataFormat.java @@ -39,6 +39,8 @@ import org.apache.camel.spi.annotations.Dataformat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.camel.dataformat.soap.SoapConstants.SOAP_METHOD_NAME; + /** * Data format supporting SOAP 1.1 and 1.2. */ @@ -165,7 +167,7 @@ public class SoapDataFormat extends JaxbDataFormat { if (soapAction != null && elementNameStrategy instanceof ServiceInterfaceStrategy) { ServiceInterfaceStrategy strategy = (ServiceInterfaceStrategy) elementNameStrategy; String methodName = strategy.getMethodForSoapAction(soapAction); - exchange.getOut().setHeader(Exchange.BEAN_METHOD_NAME, methodName); + exchange.getOut().setHeader(SOAP_METHOD_NAME, methodName); } // Store soap action for an eventual later marshal step. diff --git a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java b/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java index 2984408af7b..54f96269b80 100644 --- a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java +++ b/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapCxfClientTest.java @@ -103,6 +103,8 @@ public class SoapCxfClientTest extends RouteBuilder { @Override public void configure() throws Exception { + getCamelContext().getRegistry().bind("myServerBean", serverBean); + String jaxbPackage = GetCustomersByName.class.getPackage().getName(); ElementNameStrategy elNameStrat = new ServiceInterfaceStrategy(CustomerService.class, false); SoapDataFormat soapDataFormat = new SoapDataFormat(jaxbPackage, elNameStrat); @@ -110,7 +112,7 @@ public class SoapCxfClientTest extends RouteBuilder { from("direct:cxfclient") // .onException(Exception.class).handled(true).marshal(soapDataFormat).end() // .unmarshal(soapDataFormat) // - .bean(serverBean) // + .toD("bean:myServerBean?method=${header.CamelSoapMethodName}") .marshal(soapDataFormat); } diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/ExchangeHeaders.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/ExchangeHeaders.java index 47af57fb11f..cf62ba5b4da 100644 --- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/ExchangeHeaders.java +++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/ExchangeHeaders.java @@ -39,7 +39,7 @@ public final class ExchangeHeaders { public static final HttpString BATCH_INDEX = new HttpString("CamelBatchIndex"); public static final HttpString BATCH_SIZE = new HttpString("CamelBatchSize"); public static final HttpString BATCH_COMPLETE = new HttpString("CamelBatchComplete"); - public static final HttpString BEAN_METHOD_NAME = new HttpString("CamelBeanMethodName"); + @Deprecated public static final HttpString BEAN_MULTI_PARAMETER_ARRAY = new HttpString("CamelBeanMultiParameterArray"); public static final HttpString BINDING = new HttpString("CamelBinding"); // do not prefix with Camel and use lower-case starting letter as its a shared key diff --git a/core/camel-api/src/main/java/org/apache/camel/Exchange.java b/core/camel-api/src/main/java/org/apache/camel/Exchange.java index c0c0b285f32..6cadf4de452 100644 --- a/core/camel-api/src/main/java/org/apache/camel/Exchange.java +++ b/core/camel-api/src/main/java/org/apache/camel/Exchange.java @@ -102,6 +102,7 @@ public interface Exchange extends VariableAware { String BATCH_INDEX = "CamelBatchIndex"; String BATCH_SIZE = "CamelBatchSize"; String BATCH_COMPLETE = "CamelBatchComplete"; + @Deprecated String BEAN_METHOD_NAME = "CamelBeanMethodName"; String BINDING = "CamelBinding"; // do not prefix with Camel and use a lower-case starting letter as it's a shared key diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodNameHeaderIssueTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodNameHeaderIssueTest.java deleted file mode 100644 index 3a55c52cf73..00000000000 --- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodNameHeaderIssueTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.Handler; -import org.apache.camel.builder.RouteBuilder; -import org.junit.jupiter.api.Test; - -/** - * - */ -public class BeanMethodNameHeaderIssueTest extends ContextTestSupport { - - @Test - public void testBeanMethodNameHeaderIssue() throws Exception { - getMockEndpoint("mock:a").expectedBodiesReceived("foo"); - getMockEndpoint("mock:a").message(0).header(Exchange.BEAN_METHOD_NAME).isNull(); - getMockEndpoint("mock:b").expectedBodiesReceived("bar"); - getMockEndpoint("mock:b").message(0).header(Exchange.BEAN_METHOD_NAME).isNull(); - getMockEndpoint("mock:c").expectedBodiesReceived("Bye bar"); - getMockEndpoint("mock:c").message(0).header(Exchange.BEAN_METHOD_NAME).isNull(); - getMockEndpoint("mock:d").expectedBodiesReceived("Bye bar Bye bar"); - getMockEndpoint("mock:d").message(0).header(Exchange.BEAN_METHOD_NAME).isNull(); - - template.sendBodyAndHeader("direct:start", "Hello World", Exchange.BEAN_METHOD_NAME, "foo"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() { - from("direct:start").bean(BeanMethodNameHeaderIssueTest.class).to("mock:a") - .bean(BeanMethodNameHeaderIssueTest.class, "bar").to("mock:b") - .bean(BeanMethodNameHeaderIssueTest.class).to("mock:c") - .setHeader(Exchange.BEAN_METHOD_NAME, constant("echo")).bean(BeanMethodNameHeaderIssueTest.class) - .to("mock:d"); - } - }; - } - - public String foo() { - return "foo"; - } - - public String bar() { - return "bar"; - } - - public String echo(String body) { - return body + " " + body; - } - - @Handler - public String doSomething(String body) { - return "Bye " + body; - } - -} diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java index 52407ae4fe5..4e2827a15e8 100644 --- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanWithMethodHeaderTest.java @@ -18,15 +18,12 @@ package org.apache.camel.component.bean; import org.apache.camel.CamelExecutionException; import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; 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; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -41,36 +38,6 @@ public class BeanWithMethodHeaderTest extends ContextTestSupport { template.sendBody("direct:echo", "Hello World"); - assertMockEndpointsSatisfied(); - assertNull(mock.getExchanges().get(0).getIn().getHeader(Exchange.BEAN_METHOD_NAME), - "There should no Bean_METHOD_NAME header"); - } - - @Test - public void testEchoWithMethodHeaderHi() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedBodiesReceived("hi Hello World"); - // header should be removed after usage - mock.message(0).header(Exchange.BEAN_METHOD_NAME).isNull(); - - // header overrule endpoint configuration, so we should invoke the hi - // method - template.sendBodyAndHeader("direct:echo", ExchangePattern.InOut, "Hello World", Exchange.BEAN_METHOD_NAME, "hi"); - - assertMockEndpointsSatisfied(); - } - - @Test - public void testMixedBeanEndpoints() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedBodiesReceived("hi hi Hello World"); - // header should be removed after usage - mock.message(0).header(Exchange.BEAN_METHOD_NAME).isNull(); - - // header overrule endpoint configuration, so we should invoke the hi - // method - template.sendBodyAndHeader("direct:mixed", ExchangePattern.InOut, "Hello World", Exchange.BEAN_METHOD_NAME, "hi"); - assertMockEndpointsSatisfied(); } @@ -150,8 +117,6 @@ public class BeanWithMethodHeaderTest extends ContextTestSupport { from("direct:hi").bean("myBean", "hi").to("mock:result"); - from("direct:mixed").bean("myBean", "echo").bean("myBean", "hi").to("mock:result"); - from("direct:fail").bean("myBean").to("mock:result"); } }; diff --git a/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTest.java b/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTest.java index 7797306ed85..9f52b2ebd98 100644 --- a/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTest.java @@ -17,7 +17,6 @@ package org.apache.camel.language; import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.language.bean.Bean; import org.apache.camel.spi.Registry; @@ -46,15 +45,6 @@ public class BeanAnnotationParameterTest extends ContextTestSupport { assertMockEndpointsSatisfied(); } - @Test - public void testBeanAnnotationThree() throws Exception { - getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); - - template.sendBody("direct:three", "World"); - - assertMockEndpointsSatisfied(); - } - @Test public void testBeanAnnotationFour() throws Exception { getMockEndpoint("mock:middle").expectedBodiesReceived("Hello World"); @@ -81,9 +71,6 @@ public class BeanAnnotationParameterTest extends ContextTestSupport { from("direct:two").bean(MyBean.class, "callA").to("mock:result"); - from("direct:three").setHeader(Exchange.BEAN_METHOD_NAME, constant("callA")).bean(MyBean.class) - .to("mock:result"); - from("direct:four").bean(MyBean.class, "callA").to("mock:middle").bean(MyBean.class, "callB").to("mock:result"); } }; diff --git a/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTwoTest.java b/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTwoTest.java index 3a0f3becc78..95deb32a80c 100644 --- a/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTwoTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/language/BeanAnnotationParameterTwoTest.java @@ -17,7 +17,6 @@ package org.apache.camel.language; import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.language.bean.Bean; import org.apache.camel.spi.Registry; @@ -46,15 +45,6 @@ public class BeanAnnotationParameterTwoTest extends ContextTestSupport { assertMockEndpointsSatisfied(); } - @Test - public void testBeanAnnotationThree() throws Exception { - getMockEndpoint("mock:result").expectedBodiesReceived("Hello/Bonjour World"); - - template.sendBody("direct:three", "World"); - - assertMockEndpointsSatisfied(); - } - @Test public void testBeanAnnotationFour() throws Exception { getMockEndpoint("mock:middle").expectedBodiesReceived("Hello/Bonjour World"); @@ -81,9 +71,6 @@ public class BeanAnnotationParameterTwoTest extends ContextTestSupport { from("direct:two").bean(MyBean.class, "callA").to("mock:result"); - from("direct:three").setHeader(Exchange.BEAN_METHOD_NAME, constant("callA")).bean(MyBean.class) - .to("mock:result"); - from("direct:four").bean(MyBean.class, "callA").to("mock:middle").bean(MyBean.class, "callB").to("mock:result"); } }; diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/BeanRouteTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/BeanRouteTest.java deleted file mode 100644 index 90d786d2732..00000000000 --- a/core/camel-core/src/test/java/org/apache/camel/processor/BeanRouteTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.processor; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.spi.Registry; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.jupiter.api.Assertions.*; - -public class BeanRouteTest extends ContextTestSupport { - private static final Logger LOG = LoggerFactory.getLogger(BeanRouteTest.class); - protected final MyBean myBean = new MyBean(); - - @Test - public void testSendingMessageWithMethodNameHeader() { - String expectedBody = "Wobble"; - - template.sendBodyAndHeader("direct:in", expectedBody, Exchange.BEAN_METHOD_NAME, "read"); - - assertEquals(expectedBody, myBean.body, "bean received correct value for: " + myBean); - } - - @Test - public void testSendingMessageWithMethodNameHeaderWithMoreVerboseCoe() { - final String expectedBody = "Wibble"; - - template.send("direct:in", new Processor() { - public void process(Exchange exchange) { - Message in = exchange.getIn(); - in.setBody(expectedBody); - in.setHeader(Exchange.BEAN_METHOD_NAME, "read"); - } - }); - assertEquals(expectedBody, myBean.body, "bean received correct value"); - } - - @Override - @BeforeEach - public void setUp() throws Exception { - super.setUp(); - - Object lookedUpBean = context.getRegistry().lookupByName("myBean"); - assertSame(myBean, lookedUpBean, "Lookup of 'myBean' should return same object!"); - } - - @Override - protected Registry createCamelRegistry() throws Exception { - Registry answer = super.createCamelRegistry(); - answer.bind("myBean", myBean); - return answer; - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:in").bean("myBean"); - } - }; - } - - public static class MyBean { - private static final AtomicInteger counter = new AtomicInteger(); - public String body; - private final int id; - - public MyBean() { - id = counter.incrementAndGet(); - } - - @Override - public String toString() { - return "MyBean:" + id; - } - - public void read(String body) { - this.body = body; - LOG.info("read() method on {} with body: {}", this, body); - } - - public void wrongMethod(String body) { - fail("wrongMethod() called with: " + body); - } - } -} diff --git a/docs/user-manual/modules/ROOT/pages/bean-binding.adoc b/docs/user-manual/modules/ROOT/pages/bean-binding.adoc index 4d648474d95..f0f651e1d96 100644 --- a/docs/user-manual/modules/ROOT/pages/bean-binding.adoc +++ b/docs/user-manual/modules/ROOT/pages/bean-binding.adoc @@ -11,13 +11,10 @@ NOTE: This requires to include `camel-bean` as dependency on the classpath. The binding of a Camel xref:components:eips:message.adoc[Message] to a bean method call can occur in different ways, in the following order of importance: -* if the message contains the header `Exchange.BEAN_METHOD_NAME` / `CamelBeanMethodName` then that -method is invoked, converting the message to the type of the method's -parameter. -** You can qualify parameter types to select +* You can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details). -** You can specify parameter values directly in +* You can specify parameter values directly in the method option (see below for more details). * you can explicitly specify the method name in the xref:dsl.adoc[DSL] or when using xref:pojo-consuming.adoc[POJO Consuming] or diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc index 9d2f5d7609b..4b5c314403c 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc @@ -23,6 +23,16 @@ When MDC is enabled, then the WireTap and OnCompletion (in parallel mode) will n context when creating threads to process the exchanges. This makes these EIPs similar to how other EIPs such as Multicast EIP already does this. +=== camel-bean + +The header `Exchange.BEAN_METHOD_NAME` with constant value `CamelBeanMethodName` has been deprecated, and support for using this header has been removed. +Instead, you can specify the `method` option directly as shown, or using any other header of your choosing as follows. + +[source,java] +---- + toD("bean:myBean?method=${header.myMethodName}"); +---- + === camel-sql When inserting or updating many rows in `batch=true` mode (producer) then this component diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_11.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_11.adoc index 4462efaaa59..1339a049bc7 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_11.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_11.adoc @@ -46,6 +46,16 @@ am.addAttachment("message1.xml", new DataHandler(new FileDataSource(new File("sr The class `org.apache.camel.attachment.AttachmentMap` has been removed. Removed `getDelegateMessage` method from `org.apache.camel.attachment.AttachmentMessage`. +=== camel-bean + +The header `Exchange.BEAN_METHOD_NAME` with constant value `CamelBeanMethodName` has been deprecated, and support for using this header has been removed. +Instead, you can specify the `method` option directly as shown, or using any other header of your choosing as follows. + +[source,java] +---- + toD("bean:myBean?method=${header.myMethodName}"); +---- + === camel-main Remove the deprecated `camel.main.lightweight` option that was not in use. diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java index 7fb9ad07ff6..80f3d46d452 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/BeanEndpointBuilderFactory.java @@ -213,19 +213,6 @@ public interface BeanEndpointBuilderFactory { } public interface BeanBuilders { - /** - * Bean (camel-bean) - * Invoke methods of Java beans stored in Camel registry. - * - * Category: core,script - * Since: 1.0 - * Maven coordinates: org.apache.camel:camel-bean - * - * @return the dsl builder for the headers' name. - */ - default BeanHeaderNameBuilder bean() { - return BeanHeaderNameBuilder.INSTANCE; - } /** * Bean (camel-bean) * Invoke methods of Java beans stored in Camel registry. @@ -268,29 +255,6 @@ public interface BeanEndpointBuilderFactory { } } - /** - * The builder of headers' name for the Bean component. - */ - public static class BeanHeaderNameBuilder { - /** - * The internal instance of the builder used to access to all the - * methods representing the name of headers. - */ - private static final BeanHeaderNameBuilder INSTANCE = new BeanHeaderNameBuilder(); - - /** - * The name of the method to invoke. - * - * The option is a: {@code String} type. - * - * Group: producer - * - * @return the name of the header {@code BeanMethodName}. - */ - public String beanMethodName() { - return "CamelBeanMethodName"; - } - } static BeanEndpointBuilder endpointBuilder(String componentName, String path) { class BeanEndpointBuilderImpl extends AbstractEndpointBuilder implements BeanEndpointBuilder, AdvancedBeanEndpointBuilder { public BeanEndpointBuilderImpl(String path) { diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java index 3563d26d0fb..cc779942bc8 100644 --- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java +++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ClassEndpointBuilderFactory.java @@ -213,19 +213,6 @@ public interface ClassEndpointBuilderFactory { } public interface ClassBuilders { - /** - * Class (camel-bean) - * Invoke methods of Java beans specified by class name. - * - * Category: core,script - * Since: 2.4 - * Maven coordinates: org.apache.camel:camel-bean - * - * @return the dsl builder for the headers' name. - */ - default ClassHeaderNameBuilder clas() { - return ClassHeaderNameBuilder.INSTANCE; - } /** * Class (camel-bean) * Invoke methods of Java beans specified by class name. @@ -268,29 +255,6 @@ public interface ClassEndpointBuilderFactory { } } - /** - * The builder of headers' name for the Class component. - */ - public static class ClassHeaderNameBuilder { - /** - * The internal instance of the builder used to access to all the - * methods representing the name of headers. - */ - private static final ClassHeaderNameBuilder INSTANCE = new ClassHeaderNameBuilder(); - - /** - * The name of the method to invoke. - * - * The option is a: {@code String} type. - * - * Group: producer - * - * @return the name of the header {@code BeanMethodName}. - */ - public String beanMethodName() { - return "CamelBeanMethodName"; - } - } static ClassEndpointBuilder endpointBuilder(String componentName, String path) { class ClassEndpointBuilderImpl extends AbstractEndpointBuilder implements ClassEndpointBuilder, AdvancedClassEndpointBuilder { public ClassEndpointBuilderImpl(String path) {