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的更多相关文章

  1. spring aop 使用xml方式的简单总结

    spring aop的 xml的配置方式的简单实现: 1.编写自己的切面类:配置各个通知类型 /** * */ package com.lilin.maven.service.aop; import ...

  2. Spring的第三天AOP之xml版

    Spring的第三天AOP之xml版 ssm框架 spring  AOP介绍 AOP(Aspect Oriented Programming),面向切面编程.它出来的目的并不是去取代oop,而是对它的 ...

  3. spring中aop以xml配置方式

    1 引jar包 springAOP\aopalliance.jar springAOP\aspectjrt.jar springAOP\aspectjweaver.jar springAOP\spri ...

  4. Spring中基于AOP的XML架构

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/aop-with-spring-framenwork/xml-schema-based-aop-wi ...

  5. Spring_IoC注解开发和AOP的XML开发(学习笔记2)

    一:IoC注解开发 1,在applicationContext.xml中需要引入context约束 <beans xmlns="http://www.springframework.o ...

  6. Spring 中基于 AOP 的 XML架构

    Spring 中基于 AOP 的 XML架构 为了使用 aop 命名空间标签,你需要导入 spring-aop j架构,如下所述: <?xml version="1.0" e ...

  7. [刘阳Java]_Spring AOP基于XML配置介绍_第9讲

    基于注解配置的Spring AOP固然简单,但是这节我们会给大家介绍基于XML配置的AOP是如何应用的.为什么这么说了,因为后面我们还会介绍到Spring对Dao操作的事务管理(基于AOP的XML文件 ...

  8. Spring AOP基于xml配置实例

    SpringAOP里的几个术语,什么切面,切点之类的,官方的说明太抽象.为了更好地理解记忆,这里几下我自己的通俗的理解. 切面:就是日记类,什么前置通知后置通知(这些都是所谓的Advice)的具体方法 ...

  9. spring中的aop的xml配置方式简单实例

    aop,即面向切面编程,面向切面编程的目标就是分离关注点,比如:一个骑士只需要关注守护安全,或者远征,而骑士辉煌一生的事迹由谁来记录和歌颂呢,当然不会是自己了,这个完全可以由诗人去歌颂,比如当骑士出征 ...

随机推荐

  1. HDU 3468 BFS+二分匹配

    九野的博客,转载请注明出处 http://blog.csdn.net/acmmmm/article/details/10966383 开始建图打搓了,参考了大牛的题解打的版本比较清爽,后来改的基本雷同 ...

  2. SDUT 2893-B(DP || 记忆化搜索)

    B Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述 有n块地板排成一条直线,从左到右编号为1,2,3. . . n-1,n,每 ...

  3. HDU 2045 不easy系列之(3)—— LELE的RPG难题

    思路: 1.若前n-1位涂的颜色是符合条件的,则因为首尾不同,再加入一位时,仅仅有1种方法:即s[n] = s[n-1] 2.若前n-1位组成的串不符合,再加入一位后合法.即由于首尾同样而引起的不合法 ...

  4. string的不可变性

    1.不可变性 代码如下: static void Main(string[] args){string str1 = "a";string str2 = str1;str2 = & ...

  5. IOS详解TableView——对话聊天布局的实现

    上篇博客介绍了如何使用UITableView实现类似QQ的好友界面布局.这篇讲述如何利用自定义单元格来实现聊天界面的布局. 借助单元格实现聊天布局难度不大,主要要解决的问题有两个: 1.自己和其他人说 ...

  6. Boost::asio io_service 实现分析

    io_service的作用 io_servie 实现了一个任务队列,这里的任务就是void(void)的函数.Io_servie最常用的两个接口是post和run,post向任务队列中投递任务,run ...

  7. Oracle Data Guard 创建物理Standby数据库

    创建物理备库 机器名                    a1                    a2                    IP:                    192 ...

  8. WPF程序长时间无人操作

    在软件开发中为了安全性,特别是那些需要用到用户名和密码登录服务端的程序,常常考虑长期无人操作,程序自动跳转到用户登录界面. 判断程序是否长时间无人操作,有两个依据,第一个是鼠标长时间不动,第二个是鼠标 ...

  9. Mac AppStore 登陆提示 未知错误

    Mac Book 登陆的时候提示未知错误,刚开始以为是需要内建网卡后来才得知: 如果是黑苹果,或者是网卡没有对应上的,需要内建网卡 mac 系统默认的是无线网卡en0 其他都网卡 以此类推 如果是ma ...

  10. 【ASP.NET Web API教程】2.3.6 创建产品和订单控制器

    原文:[ASP.NET Web API教程]2.3.6 创建产品和订单控制器 注:本文是[ASP.NET Web API系列教程]的一部分,如果您是第一次看本博客文章,请先看前面的内容. Part 6 ...