2015-07-28 102 views
2

我有三類駱駝AmbiguousMethodCallException抽象類

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的具體實現。爲什麼我得到這個例外,我該如何解決?

+0

你使用什麼版本的駱駝? –

+0

我們使用的版本是2.15 – Airomega

+0

您是否也可以在課堂上添加摘要 –

回答

0

* UPDATE *

我已將此作爲答案,因爲這已經使用駱駝的當前版本解決了我的問題。然而,克勞斯易卜生的答案/錯誤修正將可能解決隨後駱駝版本中的這種情況。


我相信我已經找到了使用ognl而不是簡單的解決方法 - 它不是很漂亮,但它的工作原理。

我把它換成 <simple>${body.details.type} == 'myself'</simple>

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

我的想法是,我需要訪問的對象本身,而不是依靠基於變量名預計吸氣簽名。它似乎工作!

+0

https://camel.apache.org/ognl.html – Airomega