spring基础----->aop全配置下的配置切入点
2017-02-25 23:22
375 查看
1.当我们不使用注解@pointcut来进行配置切入点,以xml配置方式如何去表达切入点了?
答:Xml配置切入点,由两个标签起作用:
1.1<aop:config....>标签下的<aop:pointcut>标签,
1.2<aop:aspect...>标签下的<aop:pointcut>标签.
2.一般情况下我们都是结合使用<aop:config>和<aop:aspect>下的pointcut标签
如何结合使用?
答:<aop:config>标签有两个属性: id和 expression 如:<aop:pointcut id="mypointcut" expression="execution(* test.*.*(..))"/> 在此情况下mypointcut就可以代表execution(* test.*.*(..))切入表达式,然后在<aop:aspect...>标签下使用pointcut-ref="mypointcut" 就可以引用,那么他们就达到了结合使用的效果
分别使用的话
<aop:config>下的pointcut就显得非常无力了,因为它可以反复被引用,而且它也是为了被引用而写的
<aop:aspect>下的pointcut是在当前的通知语句里面起作用 如:<aop:before pointcut=""execution(* test.*.*(..))" method=""> 出去该标签则无效了!
3.结合使用<aop:config>和<aop:aspect>的pointcut标签案例(全xml配置无注解)
<aop:config>
<aop:pointcut id="mypointcut" expression="execution(* aoptest.*.*(..))"/>
<aop:aspect id="aspectid" ref="aspect">
<aop:before pointcut-ref="mypointcut" method="play"/>
</aop:aspect>
</aop:config>
<bean id="person" class="aoptest.person"/>
<bean id="aspect" class="aoptest.aspect"/>
</beans>
今天学习xml配置切入点到此为止!
答:Xml配置切入点,由两个标签起作用:
1.1<aop:config....>标签下的<aop:pointcut>标签,
1.2<aop:aspect...>标签下的<aop:pointcut>标签.
2.一般情况下我们都是结合使用<aop:config>和<aop:aspect>下的pointcut标签
如何结合使用?
答:<aop:config>标签有两个属性: id和 expression 如:<aop:pointcut id="mypointcut" expression="execution(* test.*.*(..))"/> 在此情况下mypointcut就可以代表execution(* test.*.*(..))切入表达式,然后在<aop:aspect...>标签下使用pointcut-ref="mypointcut" 就可以引用,那么他们就达到了结合使用的效果
分别使用的话
<aop:config>下的pointcut就显得非常无力了,因为它可以反复被引用,而且它也是为了被引用而写的
<aop:aspect>下的pointcut是在当前的通知语句里面起作用 如:<aop:before pointcut=""execution(* test.*.*(..))" method=""> 出去该标签则无效了!
3.结合使用<aop:config>和<aop:aspect>的pointcut标签案例(全xml配置无注解)
<aop:config>
<aop:pointcut id="mypointcut" expression="execution(* aoptest.*.*(..))"/>
<aop:aspect id="aspectid" ref="aspect">
<aop:before pointcut-ref="mypointcut" method="play"/>
</aop:aspect>
</aop:config>
<bean id="person" class="aoptest.person"/>
<bean id="aspect" class="aoptest.aspect"/>
</beans>
今天学习xml配置切入点到此为止!
相关文章推荐
- Spring基础配置 - AOP
- 0047 Spring的AOP入门基础--切面组件--通知--切入点
- java 框架基础知识(5)----注解-->Spring配置
- Spring中利用AOP对领域对象(非依赖注入的对象,如new操作符、反射的方式生存的对象)下面是spring配置文件的一部分 <context:load-time-weaver /> <be
- Spring Aop配置时的切入点表达式
- <框架篇(4)>Spring配置AOP的方式
- spring注解时AOP失效,XML配置<bean>正常
- XML基础知识-->Spring配置
- Spring Aop配置时的切入点表达式
- Spring配置---<aop:aspectj-autoproxy />
- Spring AOP基础 <一>
- Spring Aop配置时的切入点表达式
- Spring配置AOP实现定义切入点和织入增强
- spring学习总结(九):AOP 基础及基于注解配置的AOP
- Spring基础配置(AOP切面编程)
- spring AOP中的<aop:config>配置
- 【Spring】Spring基础配置-AOP
- Spring Aop配置时的切入点表达式
- Spring基础---配置文件、Ioc、AOP
- <一>Spring基础之Bean在XML中的配置