Spring AOP 关键词的理解

1.如下图所示:

  

  AOP的执行就是在什么时候什么地方做什么

2.关键词理解:

  连接点(JoinPoint): 就是能够作为切点的一个个动作(方法),当然实际上不是所有连接点都当做切点的。

  切点(Poincut):链接点中的一个或多个,切面会在这些点上来做文章(切点就是什么地方)。

  通知(Advice):通知是在切点上什么时候做什么

      通知有下列几种类型:Before,After,After-returning,

      After-throwing,Around

  切面(Aspect):切面包括切点和切面(什么时候什么地方做什么)。

3.配置:

  <aop:config>  

   <!--切面 包括切点和通知-->

        <aop:aspect id="TestAspect" ref="aspectBean">  

    <!--切点 什么地方-->

            <aop:pointcut id="businessService"  expression="execution(* com.spring.service.*.*(..))" />  

    <!--通知 什么时候做什么-->

            <aop:before pointcut-ref="businessService" method="doBefore"/>  

            <aop:after pointcut-ref="businessService" method="doAfter"/>  

            <aop:around pointcut-ref="businessService" method="doAround"/>  

            <aop:after-throwing pointcut-ref="businessService" method="doThrowing" throwing="ex"/>  

        </aop:aspect>  

    </aop:config>

posted @ 2014-05-26 11:28  绿萝有枯叶了  阅读(1245)  评论(0编辑  收藏  举报