I have an @Aspect and @Pointcut method annotated to fire @Before a @Controller request method, it seems to be matching (as I'm not getting any errors) but it is not firing my advice method at all. I changed my pointcut for testing purposes to be as specific as possible and am not getting any binding errors during application startup.
Here's my controller method (the class is com.x.y.z.MyController):
@RequestMapping(method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
@ResponseBody
public SubmissionResponse submitMethod(@Valid @RequestBody final SubmissionRequest request, HttpServletRequest httpRequest, BindingResult result)
{
if (result.hasErrors()) { throw new BadRequestException(result); }
// ... do stuff ...
}
Here's the Aspect class:
@Aspect
@Component
public class RequestValidatingAspect
{
private static final Logger LOGGER = Logger.getLogger(RequestValidatingAspect.class);
@Inject
private ClientService clientService;
@Inject
private AccountService accountService;
@Pointcut("execution(* com.x.y.z.MyController.submitMethod(*.SubmissionRequest,*.HttpServletRequest,*.BindingResult)) && args(request, httpRequest, result)")
private void requestValidation(SubmissionRequest request, HttpServletRequest httpRequest, BindingResult result) {}
@Before("requestValidation(request,httpRequest,result)")
public void theAdvice(SubmissionRequest request, HttpServletRequest httpRequest, BindingResult result) throws Throwable
{
System.out.println("Before - The Advice");
LOGGER.info("Entering The Advice!");
if(result.hasErrors()){ throw new BadRequestException(result); }
// ... do stuff ...
LOGGER.info("Exiting - The Advice!");
return;
}
}