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();
// remove any existing exception in case we do OGNL on the exception
resultExchange.setException(null);
// force to use InOut to retrieve the result on the OUT message
resultExchange.setPattern(ExchangePattern.InOut);
processor.process(resultExchange);
result = resultExchange.getOut().getBody();
// propagate properties and headers from result
if (resultExchange.hasProperties()) {
exchange.getProperties().putAll(resultExchange.getProperties());