Camel AmbiguousMethodCallException抽象类

时间:2015-07-28 09:07:13

标签: java exception apache-camel

我有三节课

public abstract FoundationReport
{
    public abstract FoundationDetails getDetails();
}

public abstract BaseReport extends FoundationReport
{
    public abstract BaseDetails getDetails();
}

public Report extends BaseReport
{

    ReportDetails reportDetails;

    public ReportDetails getDetails()
    {
        return reportDetails
    }
}

ReportDetails扩展了BaseDetails,BaseDetails扩展了FoundationDetails。

在我的骆驼xml中,我有一个部分:

<convertBodyTo type="path.to.Report" />
        <when>
            <simple>${body.details.type} == 'myself'</simple>
...

然而,对body.details.type的调用导致:

Caused by: org.apache.camel.component.bean.AmbiguousMethodCallException:     
Ambiguous method invocations possible: 
[public path.to.ReportDetails  path.to.Report.getDetails(), 
public abstract path.to.BaseDetails path.to.BaseReport.getDetails(), 
public abstract path.to.FoundationDetails path.to.FoundationReport()]

我假设(错误地)将使用Report类中唯一具体的getDetails实现。为什么我得到这个例外,我该如何解决?

2 个答案:

答案 0 :(得分:1)

它是Apache Camel中的一个错误。我已经复制了它,并记录了一张票来解决这个问题:https://issues.apache.org/jira/browse/CAMEL-9032

答案 1 :(得分:0)

*更新*

我已将此标记为答案,因为这已使用当前版本的camel解决了我的问题。然而,克劳斯易卜生的答案/错误修复可能会在随后的骆驼版本中解决这种情况。

我相信我已经找到了使用ognl而不是简单的解决方法 - 它并不漂亮,但它有效。

我已经被替换了 <simple>${body.details.type} == 'myself'</simple>

<ognl>exchange.getIn().getBody().getDetails().getType() == 'myself'</ognl>

我的想法是我需要访问对象本身,而不是依赖于基于变量名称的预期getter签名。它似乎工作!