The Advisor API in Spring

在 Spring 中,Advisor 是切面,它只包含与切点表达式关联的单个通知对象。

In Spring, an Advisor is an aspect that contains only a single advice object associated with a pointcut expression.

除了引入的特殊情况之外,任何 Advisor 都可以使用任何通知。org.springframework.aop.support.DefaultPointcutAdvisor 是最常用的 Advisor 类。它可与 MethodInterceptorBeforeAdviceThrowsAdvice 一起使用。

Apart from the special case of introductions, any advisor can be used with any advice. org.springframework.aop.support.DefaultPointcutAdvisor is the most commonly used advisor class. It can be used with a MethodInterceptor, BeforeAdvice, or ThrowsAdvice.

在 Spring 中的同一 AOP 代理中混合 Advisor 和通知类型是可能的。例如,你可以在一个代理配置中使用前置通知、抛出通知和环绕通知。Spring 将自动创建必要的拦截器链。

It is possible to mix advisor and advice types in Spring in the same AOP proxy. For example, you could use an interception around advice, throws advice, and before advice in one proxy configuration. Spring automatically creates the necessary interceptor chain.