Advised->在Spring中创建了AOP代理之后,就能够使用org.springframework.aop.framework.Advised
接口对它们进行管理。 任何AOP代理都能够被转型为这个接口,不论它实现了哪些其它接口
Advisor->类似使用Aspect的@Aspect注解的类
Advice->@Before、@After、@AfterReturning、@AfterThrowing、@Around
Pointcut->@Pointcut
package com.enjoy.cap10.aop; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; //日志切面类 @Aspect public class LogAspects { @Pointcut("execution(public int com.enjoy.cap10.aop.Calculator.*(..))") public void pointCut(){}; //@before代表在目标方法执行前切入, 并指定在哪个方法前切入 @Before("pointCut()") public void logStart(JoinPoint point){ System.out.println("除法运行....参数列表是:{}"); } @After("pointCut()") public void logEnd(){ System.out.println("除法结束......"); } @AfterReturning("pointCut()") public void logReturn(){ System.out.println("除法正常返回......运行结果是:{}"); } @AfterThrowing("pointCut()") public void logException(){ System.out.println("运行异常......异常信息是:{}"); } @Around("pointCut()") public Object Around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{ System.out.println("@Arount:执行目标方法之前..."); Object obj = proceedingJoinPoint.proceed();//相当于开始调div地 System.out.println("@Arount:执行目标方法之后..."); return obj; } }