Spring AOP
June 23, 2020

M02 Q09 What is ProceedingJoinPoint?

What is ProceedingJoinPoint?

ProceedingJoinPoint is an object that can be provided to @Around advice as the first argument. It is a type of JoinPoint which can be used to change method arguments during method execution in runtime or block execution of original method entirely.

ProceedingJoinPoint is used in @Around advice, it contains all methods from JoinPoint and also adds:

  • proceed – executes the original method
  • proceed(args) – executes original method with provided arguments

When is it used?

ProceedingJoinPoint can be used in the following use cases:

  • Conditionally block method execution
  • Filter arguments
  • Inject additional argument

Let's look into the code and implement a feature that can hide private keys when toString() is invoked.

Firstly, create an annotation that will mark the argument that needs to be hidden.

Added it to our bean

Then, create the Aspect with @Around advice

And create Runner class that executes our method

Finally, we got the next output