This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 6986c54 CAMEL-15793: camel-bean - To make OSGi service reference in blueprint work again. Thanks to Josh Smith for reporting this. 6986c54 is described below commit 6986c54413eaba193d3a66ec50bd21e0e07a2a93 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. --- .../org/apache/camel/component/bean/BeanInfo.java | 20 +++++++++++++------- 1 file changed, 13 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 bc616e7..2d30aae 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 @@ -44,6 +44,7 @@ import org.apache.camel.Message; import org.apache.camel.PropertyInject; import org.apache.camel.RuntimeCamelException; 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; @@ -98,13 +99,18 @@ public class BeanInfo { public BeanInfo(CamelContext camelContext, Class<?> type, Method explicitMethod, ParameterMappingStrategy strategy, BeanComponent beanComponent) { - 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) { + // OSGi services wont work for this + 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); + } } } }