this.beanHolder = beanHolder;
this.methodName = methodName;
}
public void process(Exchange exchange) throws Exception {
BeanProcessor processor = new BeanProcessor(beanHolder);
if (methodName != null) {
processor.setMethod(methodName);
// enable OGNL like invocation
processor.setShorthandMethod(true);
}
try {
// copy the original exchange to avoid side effects on it
Exchange resultExchange = exchange.copy();
// force to use InOut to retrieve the result on the OUT message
resultExchange.setPattern(ExchangePattern.InOut);
processor.process(resultExchange);
result = resultExchange.getOut().getBody();
// propagate exceptions
if (resultExchange.getException() != null) {
exchange.setException(resultExchange.getException());