Advised->在Spring中建立了AOP代理以后,就可以使用org.springframework.aop.framework.Advised
接口对它们进行管理。 任何AOP代理都可以被转型为这个接口,不论它实现了哪些其它接口spring
Advisor->相似使用Aspect的@Aspect注解的类代理
Advice->@Before、@After、@AfterReturning、@AfterThrowing、@Around日志
Pointcut->@Pointcutcode
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; } }