Spring3.0中的AOP(二)
来源:互联网 发布:知乎是什么时候成立的 编辑:程序博客网 时间:2024/03/29 05:14
2、基于 XML配置文件的管理方式。
- 不配置切入点
81. <?xml version="1.0" encoding="UTF-8"?> 82. <beans xmlns="http://www.springframework.org/schema/beans" 83. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 84. xmlns:aop="http://www.springframework.org/schema/aop" 85. xsi:schemaLocation="http://www.springframework.org/schema/beans 86. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 87. http://www.springframework.org/schema/aop 88. http://www.springframework.org/schema/beans/spring-aop-3.0.xsd"> 89. <aop:config> 90. <!-- 将 fourAdviceBean 转换成切面 Bean, 切面 Bean 的新名称为:fourAdviceAspect,指定该切面的优先级为2 --> 91. <aop:aspect id="fourAdviceAspect" ref="fourAdviceBean" order="2"> 92. <!-- 定义个After增强处理,直接指定切入点表达式,以切面 Bean 中的 Release() 方法作为增强处理方法 --> 93. <aop:after pointcut="execution(* com.wicresoft.app.service.impl.*.*(..))" method="release" /> 94. 95. <!-- 定义个Before增强处理,直接指定切入点表达式,以切面 Bean 中的 authority() 方法作为增强处理方法 --> 96. <aop:before pointcut="execution(* com.wicresoft.app.service.impl.*.*(..))" method="authority" /> 97. 98. <!-- 定义个AfterReturning增强处理,直接指定切入点表达式,以切面 Bean 中的 log() 方法作为增强处理方法 --> 99. <aop:after-returning pointcut="execution(* com.wicresoft.app.service.impl.*.*(..))" method="log" /> 100. 101. <!-- 定义个Around增强处理,直接指定切入点表达式,以切面 Bean 中的 processTx() 方法作为增强处理方法 --> 102. <aop:around pointcut="execution(* com.wicresoft.app.service.impl.*.*(..))" method="processTx" /> 103. 104. </aop:aspect> 105. </aop:config> 106. 107. <!-- 省略各个Bean 的配置 --> 108. <!-- ... --> 109. 110. </beans>
配置切入点
111. <?xml version="1.0" encoding="UTF-8"?> 112. <beans xmlns="http://www.springframework.org/schema/beans" 113. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 114. xmlns:aop="http://www.springframework.org/schema/aop" 115. xsi:schemaLocation="http://www.springframework.org/schema/beans 116. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 117. http://www.springframework.org/schema/aop 118. http://www.springframework.org/schema/beans/spring-aop-3.0.xsd"> 119. <aop:config> 120. <!-- 定义一个切入点,myPointcut,直接知道它对应的切入点表达式 --> 121. <aop:pointcut id="myPointcut" expression="execution(* com.wicresoft.app.service.impl.*.*(..))" method="release" /> 122. <aop:aspect id="afterThrowingAdviceAspect" ref="afterThrowingAdviceBean" order="1"> 123. <!-- 使用上面定于切入点定义增强处理 --> 124. <!-- 定义一个AfterThrowing 增强处理,指定切入点以切面 Bean 中的 doRecovertyActions() 方法作为增强处理方法 --> 125. <aop:after-throwing pointcut-ref="myPointcut" method="doRecovertyActions" throwing="ex" /> 126. </aop:aspect> 127. </aop:config> 128. 129. <!-- 省略各个Bean 的配置 --> 130. <!-- ... --> 131. 132. </beans>参考:http://blog.csdn.net/a906998248/article/details/7514969
0 0
- Spring3.0中的AOP(二)
- Spring3.0中的AOP(一)
- Spring3.0中的AOP注解配置
- Spring3.0中的AOP配置方法
- Spring3.0中的AOP配置方法
- Spring3.0中的AOP配置方法
- [Spring3.x源码]AOP(二)组装配置信息
- Spring3.0 AOP 详解
- Spring3.0 AOP
- Spring3.0 AOP 详解
- spring3.0AOP详解
- Spring3.0 AOP 详解
- Spring3.0 AOP 详解
- Spring3.0 AOP 详解
- spring3.0 aop原理
- Spring3.0 AOP 详解
- Spring3.0 AOP 详解
- Spring3.0 AOP 详解
- mac下不识别android设备的解决
- sdcms的内容的上一篇一下篇的调用
- 减少C++代码编译时间的方法
- 黑马程序员————C语言——基本语法3
- 社説 20150323 公示地価 街の魅力向上で回復を地方に
- Spring3.0中的AOP(二)
- iOS8 学习新技术
- Entity Framework中IQueryable, IEnumerable, IList的区别
- Cocos2d-x 3.1 Lua Binding
- 社説 20150323 国連防災会議 「仙台枠組み」で被害の抑制を
- ios xmpp探索研究:了解什么是XMPP协议
- Python正则表达式的用法
- 图片上传方法
- TextRenderer.MeasureText计算字符串文本所占的尺寸