1.关于before advice: 对于before advice,是最简单的advice。不管是基于XmlSchema或者是基于Annotation,其advice对应的方法的参数只有一个,即JoinPoint类型的参数。在XmlSchema中其<aop:before.../>标签中的属性为①pointcut-ref或者piointcut②method 在Annotation中,也仅有一个属性,即pointcut,且这个属性能够被省略掉。如:@Before("execution(...)") 2.关于 after-returning advice: after-returning advice就其对应的方法而言,须要分状况讨论。当基于XmlSchema来代理时,其对应方法的参数仅有一个,即JoinPoint类型的参数。而当基于Annotation的时候,其对应方法有两个参数,一个是JoinPoint型参数,另一个是Object类型的参数(表明返回值)。 在Xml中,其标签对应的是<aop:after-returning.../>其属性有①pointcut-ref或者pointcut②method 在Annotation中,有两个属性:pointcut与returning。如: @AfterRteturning(pointcut="execution(...)",returning="retVal")这个retVal就是Annotation状况下Advice对应方法中表明返回值的那个Object类型参数。 3.关于after-throwing advice: after-throwing advice就对应方法来讲,不管是基于XML仍是基于Annotation都是具备两个参数:JoinPoint类型参数,与表明返回异常的Throwable类型参数。在xml中,对应标签为<aop:after-returning....>标签属性除了pintcut-ref(或者pintcut)与method外,还有一个属性throwing,其值通常为throwable。 基于Annotation时,带有两个属性:pointcut与throwing。如:@AfterThrowing(pointcut="execution(...)",throwing="throwable")这个throwable就是对应Annotation里面方法中的表明抛出异常的那个参数。 这里的异常类型须要在目标对象的接口中预先定义,异常类型能够是任何异常类型。 也就是说after returning advice在基于XmlSchema的时候对应方法仅一个参数,而throw advice不管在xmlSchema或者是基于Annotation都是有两个参数。并且,第二个参数老是要在xml或者Annotation中进行显示声明。即throwing=throwable 4.关于around advice around advice是对before advice 与afterreturning advice二者都须要插入对象时的简化。相似before advice ,比较简单,这里不在赘述 另外,使用Annotation,须要引入aspectjweaver.jar