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

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


The following commit(s) were added to refs/heads/camel-3.4.x by this push:
     new 2a941bb  CAMEL-15793: camel-bean - To make OSGi service reference in 
blueprint work again. Thanks to Josh Smith for reporting this.
2a941bb is described below

commit 2a941bbb28621b0e8b8e6c4df58003f9c442db49
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Nov 3 07:36:47 2020 +0100

    CAMEL-15793: camel-bean - To make OSGi service reference in blueprint work 
again. Thanks to Josh Smith for reporting this.
---
 .../java/org/apache/camel/component/bean/BeanInfo.java | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

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 0491065..b271ee0 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
@@ -45,6 +45,7 @@ import org.apache.camel.PropertyInject;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.support.ObjectHelper;
+import org.apache.camel.support.PlatformHelper;
 import org.apache.camel.support.builder.ExpressionBuilder;
 import org.apache.camel.support.language.AnnotationExpressionFactory;
 import org.apache.camel.support.language.DefaultAnnotationExpressionFactory;
@@ -94,13 +95,16 @@ public class BeanInfo {
     }
 
     public BeanInfo(CamelContext camelContext, Class<?> type, Method 
explicitMethod, ParameterMappingStrategy strategy) {
-        while (type.isSynthetic()) {
-            type = type.getSuperclass();
-            if (explicitMethod != null) {
-                try {
-                    explicitMethod = 
type.getDeclaredMethod(explicitMethod.getName(), 
explicitMethod.getParameterTypes());
-                } catch (NoSuchMethodException e) {
-                    throw new RuntimeCamelException("Unable to find a method " 
+ explicitMethod + " on " + type, e);
+        boolean osgi = PlatformHelper.isOsgiContext(camelContext);
+        if (!osgi) {
+            while (type.isSynthetic()) {
+                type = type.getSuperclass();
+                if (explicitMethod != null) {
+                    try {
+                        explicitMethod = 
type.getDeclaredMethod(explicitMethod.getName(), 
explicitMethod.getParameterTypes());
+                    } catch (NoSuchMethodException e) {
+                        throw new RuntimeCamelException("Unable to find a 
method " + explicitMethod + " on " + type, e);
+                    }
                 }
             }
         }

Reply via email to