I have a function under class MyController:
@RestController
@RequestMapping(value = "/api/service")
public class MyController {
@PostMapping(value = "add_person")
public MyResponse addPerson(@RequestBody Person person) {
// ...
}
@PostMapping(value = "add_person_2")
public MyResponse addPerson(@PathVariable(value = "person_age") Int age, @RequestBody Person person) {
// ...
}
}
I have setup AspectJ in my project to have a AOP logic to run whenever those two addPerson(...) method above is called:
@Around("execution(public MyResponse addPerson(..))")
public void around(ProceedingJoinPoint joinPoint) {
// NO matter which addPerson(...) is executing, I am only interested in the
// parameter value annotated with @RequestBody.
// How can I access the parameter that passed in addPerson(...) & is annotated with
// @RequestBody through ProceedingJoinPoint ?
}
My question is mentioned in above code comment. I wonder how can I access the parameter annotated with @RequestBody
in my AOP function? I don't want to check parameter type or name, but interested to know how to access parameter by checking the annotation through ProceedingJoinPoint
. Is it possible?