The advisor isn't a concept from AOP in general, but is specific to Spring AOP.
The advisor links together pointcuts and advice. So it contains both the action to be executed (defined in the advice) and the point where it is to be executed (defined in the pointcut). The advisor's role is to decouple pointcuts and advice, in order to reuse them independently from each other.
The Advisor interface allows support for different types of advice, such as before and after advice, which need not be implemented using interception.
public interface Advisor { Advice getAdvice (); boolean perInstance(); }
In the following figure, we can see the diagram of the hierarchy of advisors:
When we call addAdvice()
on a ProxyFactory:
pf.addAdvice(new AfterAdviceExample());
the addAdvice
delegates to addAdvisor()
behind the scenes, creating an instance of DefaultPointcutAdvisor
and configuring it with a pointcut that points to all methods.
The addAdvisor
creates a DefaultPointcutAdvisor
, and it applies...