{
return invokedMethod.invoke(resource, args);
}
catch (IllegalAccessException e)
{
throw new InternalServerErrorException("Not allowed to reflect on method: " + method.toString(), e);
}
catch (InvocationTargetException e)
{
Throwable cause = e.getCause();
if (cause instanceof WebApplicationException)
{
WebApplicationException wae = (WebApplicationException) cause;
throw wae;
}
throw new ApplicationException(cause);
}
catch (IllegalArgumentException e)
{
String msg = "Bad arguments passed to " + method.toString() + " (";
if (args != null)
{
boolean first = false;
for (Object arg : args)
{
if (!first)
{
first = true;
}
else
{
msg += ",";
}
if (arg == null)
{
msg += " null";
continue;
}
msg += " " + arg.getClass().getName() + " " + arg;
}
}
msg += " )";
throw new InternalServerErrorException(msg, e);
}
}