{
firstArg = message.getPayload(DataTypeFactory.create(transformMethod.getParameterTypes()[0]));
}
catch (TransformerException e)
{
throw new TransformerException(e.getI18nMessage(), this, e);
}
}
//if the source is annotated, the paramTransformer will figure out the first parameter
if (!sourceAnnotated)
{
params[0] = firstArg;
if (paramCounter == 0)
{
paramCounter++;
}
}
//Lets see if there are any context objects to inject (i.e. JAXB)
if (paramCounter < transformMethod.getParameterTypes().length)
{
for (int i = paramCounter; i < transformMethod.getParameterTypes().length; i++)
{
Object o;
Class<?> type = transformMethod.getParameterTypes()[i];
o = cachedObjects.get(type);
if (o != null)
{
params[paramCounter++] = o;
continue;
}
DataType<?> source = DataTypeFactory.createFromParameterType(transformMethod, 0);
for (TransformerArgumentResolver resolver : resolvers)
{
try
{
o = resolver.resolve(type, source, this.returnType, muleContext);
if (o != null)
{
params[paramCounter++] = o;
cachedObjects.put(type, o);
break;
}
}
catch (Exception e)
{
throw new TransformerException(this, e);
}
}
if (o == null)
{
throw new IllegalArgumentException("Failed to find resolver for object type: " + type + " for transform method: " + transformMethod);
}
}
}
try
{
return transformMethod.invoke(proxy, params);
}
catch (Exception e)
{
e.printStackTrace();
throw new TransformerException(this, e);
}
}