achieve aop through xml
The main way to achive AOP is deploying a xml file。
Now a xml file is presented to be a explanation .
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<context:annotation-config />
<context:component-scan base-package="com.bjsxt"/>
<bean id="logInterceptor" class ="com.bjsxt.aop.LogInterceptor"></bean>
<aop:config>
<aop:pointcut
expression="execution(public * com.bjsxt.service..*.add(..))"
id="servicePointcut"/> <aop:aspect id="logAspect" ref="logInterceptor">
<aop:before method="before" pointcut-ref="servicePointcut" />
</aop:aspect>
</aop:config> </beans>
The tag <aop:config> declares that we will deploy a aop now.
While , I declare a "pointcut" at first. It is obvious that it's a globe pointcut and it works for every aspect behind it .
"expression="execution(public * com.bjsxt.service..*.add(..))" shows the pointcut represent all method like “add()” in the classes of the package named"com.bjsxt.service.."
the pointcut‘s id is “servicePointcut” in addition。
Next, a aspect is declared whose name is “logAspect” 。
(nobody care what name it has in this situation)。
pointcut-ref="servicePointcut" shows that it is a aspect for the pointcut named “servicePointcut”which we had created a moment ago.
Its ref = <span style="font-family: Arial, Helvetica, sans-serif;">"logInterceptor" ,so we can find a bean named logInterceptor to know what methods the aspect has。 And according to the sentence “<aop:before method</span>
<span style="font-family: Arial, Helvetica, sans-serif;">="before" " , I think we must do the method named "before" in "logIntercepor " as the type of" before method". It means the method woulb be done before pointcut.</span>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
<span style="font-family: Arial, Helvetica, sans-serif;">We can also complete the xml file in design mode。 It looks much more clear.</span>
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
achieve aop through xml的更多相关文章
- spring aop 使用xml方式的简单总结
spring aop的 xml的配置方式的简单实现: 1.编写自己的切面类:配置各个通知类型 /** * */ package com.lilin.maven.service.aop; import ...
- Spring的第三天AOP之xml版
Spring的第三天AOP之xml版 ssm框架 spring AOP介绍 AOP(Aspect Oriented Programming),面向切面编程.它出来的目的并不是去取代oop,而是对它的 ...
- spring中aop以xml配置方式
1 引jar包 springAOP\aopalliance.jar springAOP\aspectjrt.jar springAOP\aspectjweaver.jar springAOP\spri ...
- Spring中基于AOP的XML架构
以下内容引用自http://wiki.jikexueyuan.com/project/spring/aop-with-spring-framenwork/xml-schema-based-aop-wi ...
- Spring_IoC注解开发和AOP的XML开发(学习笔记2)
一:IoC注解开发 1,在applicationContext.xml中需要引入context约束 <beans xmlns="http://www.springframework.o ...
- Spring 中基于 AOP 的 XML架构
Spring 中基于 AOP 的 XML架构 为了使用 aop 命名空间标签,你需要导入 spring-aop j架构,如下所述: <?xml version="1.0" e ...
- [刘阳Java]_Spring AOP基于XML配置介绍_第9讲
基于注解配置的Spring AOP固然简单,但是这节我们会给大家介绍基于XML配置的AOP是如何应用的.为什么这么说了,因为后面我们还会介绍到Spring对Dao操作的事务管理(基于AOP的XML文件 ...
- Spring AOP基于xml配置实例
SpringAOP里的几个术语,什么切面,切点之类的,官方的说明太抽象.为了更好地理解记忆,这里几下我自己的通俗的理解. 切面:就是日记类,什么前置通知后置通知(这些都是所谓的Advice)的具体方法 ...
- spring中的aop的xml配置方式简单实例
aop,即面向切面编程,面向切面编程的目标就是分离关注点,比如:一个骑士只需要关注守护安全,或者远征,而骑士辉煌一生的事迹由谁来记录和歌颂呢,当然不会是自己了,这个完全可以由诗人去歌颂,比如当骑士出征 ...
随机推荐
- telerik 控件 SCRIPT5007: 无法获取未定义或 null 引用的属性“documentElement” (IE 文档模式)
IE对盒模型的渲染在 Standards Mode和Quirks Mode是有很大差别的,在Standards Mode下对于盒模型的解释和其他的标准浏览器是一样,但在Quirks Mode模式下则有 ...
- POJ - 1185 炮兵阵地 (状态压缩)
题目大意:中文题目就不多说大意了 解题思路: 1.每行最多仅仅有十个位置,且不是山地就是平原,那么就能够用1表示山地,0表示平原,将每一行的状态进行压缩了 2.接着找出每行能放炮兵的状态.先不考虑其它 ...
- Swift - 产生不重复数字的随机数生成器
在Swift中,可以使用函数类型的参数,也可以使用函数类型的返回值.而作为返回值的函数,还能“捕获”外部的值,并多次使用它.这个特性,常可用来创建各种生成器. 下面通过创建一个“随机数生成器函数”作为 ...
- Swift - 使用NSURLSession加载数据、下载、上传文件
NSURLSession类支持三种类型的任务:加载数据.下载和上传.下面通过样例分别进行介绍. 1,使用Data Task加载数据 使用全局的sharedSession()和dataTaskWithR ...
- Qt for Android 部署流程分析
原地址:http://blog.csdn.net/foruok/article/details/17796017 今天为了测试使用 Qt Creator 3.0.0 开发的纯 C 工程,利用了 Win ...
- jQuery中对 input 控件的操作
jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 1.获取值 jquery取radio单选按钮的值 $(" ...
- Swift - iCloud存储介绍
对于开发者而言,涉及iCloud存储的功能主要有两个: 一是 iCloud documnet storage,利用 iCloud 存储用户文件,比如保存一些用户在使用应用时生成的文件以及数据库文件等. ...
- 获取TBitMap图像缓冲区,提高图像处理速度
使用Dephi进行图像处理可以有多种方法,最常用的应该算是TBitmap,它提供方便的图像存取能力,结合Canvas可进行画线.画圆.图像拷贝等操作.不过在进行大量的图像处理操作时,为了获得更高的速度 ...
- delphi指针简单入门
delphi指针简单入门: 看一个指针用法的例子: 1 var 2 X, Y: Integer; // ...
- Windows 7如何建立一个FTP的快捷方式
原来,使用Windows XP的时候,在IE6的地址栏里输入FTP服务器的地址,就可以打开一个资源管理器的界面来管理文件.但是,随着IE的版本的提升或是装了Windows 7,原来的这种方法就不能用了 ...