private void validateMethodParameters(MethodInvocation invocation) throws InvalidArgumentException {
boolean isInvalid = false;
InvalidArgumentException ex = new InvalidArgumentException();
for (int i = 0; i < invocation.getMethod().getParameterCount(); i++) {
Parameter parameter = invocation.getMethod().getParameters()[i];
// Only validate arguments which implement ValidatingRequest.
if (ValidatingRequest.class.isAssignableFrom(parameter.getType())) {
ValidatingRequest request = (ValidatingRequest) invocation.getArguments()[i];
if (request == null) {
// Don't allow null request objects.
ex.addValidationError(InvalidArgumentException.ErrorMessage.NULL, parameter.getName(), "NULL");
isInvalid = true;
} else {
isInvalid |= validateRequest(request, ex);
}
}
}
if (isInvalid) {
// If violations exist abort invoked service call.
throw ex;
}
}
ValidationAspect.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:act-platform
作者:
评论列表
文章目录