0
我有以下駱駝路線:Apache的駱駝:的setProperty和Groovy
<route id="myroute">
<from uri="timer://runOnce?repeatCount=1&delay=10" />
<!-- Set a new property on the exchange. -->
<to uri="bean:propSetter?method=setProp" />
<to uri="direct:fizz" />
</route>
我PropSetter
豆:
public class PropSetter {
// Add new "buzz" ArrayList<Long> to the exchange.
public void setProp(Exchange exchange) {
exchange.setProperty("buzz", new ArrayList<Long>());
}
}
我想改寫這個沒有一個Java bean,而是使用駱駝的<setProperty/>
元件。我可以想到的唯一的事情是使用內置的Groovy表達:
<route id="myroute">
<from uri="timer://runOnce?repeatCount=1&delay=10" />
<!-- Set a new property on the exchange. -->
<setProperty propertyName="buzz">
<groovy>new ArrayList<Long>();</groovy>
</setProperty>
<to uri="direct:fizz" />
</route>
但這似乎並沒有工作。那麼如何使用XML在名爲buzz
的交易所上設置新的ArrayList<Long>
?
你是什麼意思_「做似乎沒有工作「_? –
您可以引用一個bean,並在該bean內部指定一個列表。 – Ashish
謝謝@tim_yates(+1) - 雖然我無法破譯你是否需要我澄清我看到的錯誤的程度,或者如果你認爲它*應該*工作並且不明白爲什麼它不...你介意一點點介紹嗎?再次感謝! – IAmYourFaja