{
bean = getBeanFactory().getInstance(muleContext);
}
catch (Exception e)
{
throw new TransformerException(this, e);
}
Map<String, Object> args = new HashMap<String, Object>(arguments.size());
for (Iterator<ExpressionArgument> iterator = arguments.iterator(); iterator.hasNext();)
{
ExpressionArgument argument = iterator.next();
Object value = null;
try
{
value = argument.evaluate(message);
}
catch (RequiredValueException e)
{
logger.warn(e.getMessage());
}
catch (ExpressionRuntimeException e)
{
throw new TransformerException(this, e);
}
if (!argument.isOptional() && value == null)
{
throw new TransformerException(CoreMessages.expressionEvaluatorReturnedNull(
argument.getExpressionConfig().getEvaluator(), argument.getExpressionConfig().getExpression()), this);
}
args.put(argument.getName(), value);
}
try
{
BeanUtils.populate(bean, args);
}
catch (IllegalAccessException e)
{
throw new TransformerException(this, e);
}
catch (InvocationTargetException e)
{
throw new TransformerException(this, e.getTargetException());
}
return bean;
}