* @throws Exception Any exception caused by the intercepted method invocation. A {@link ConstraintViolationException}
* in case at least one constraint violation occurred either during parameter or return value validation.
*/
@AroundInvoke
public Object validateMethodInvocation(InvocationContext ctx) throws Exception {
ExecutableValidator executableValidator = validator.forExecutables();
Set<ConstraintViolation<Object>> violations = executableValidator.validateParameters(
ctx.getTarget(),
ctx.getMethod(),
ctx.getParameters()
);
if ( !violations.isEmpty() ) {
throw new ConstraintViolationException(
getMessage( ctx.getMethod(), ctx.getParameters(), violations ),
violations
);
}
Object result = ctx.proceed();
violations = executableValidator.validateReturnValue(
ctx.getTarget(),
ctx.getMethod(),
result
);