<?xml version="1.0" encoding="UTF-8"?>
<!--将通知交给spring-->
<bean id="logger" class="Util.CustomerLogger"></bean>
<bean id="customerServer" class="com.liuqijun.spring.CustomerServerImp"></bean>
<!--配置aop切面-->
<aop:config>
<!--
id :是唯一标识一个切面
ref:是通知类的bean
before:表明通知类型(前置通知)
method:具体的通知方法,表明在切入点执行之前执行star方法
execution:是切入点表达式,用来表明要增强的切入点是哪个,切入点表达式有很多形式
1.全匹配方式:修饰符 返回值类型 包名.包名..类名.方法名(参数列表) 例如:public void com.liuqijun.spring.CustomerServerImp.save()
2.全通配方式:* *..*.*(..) *称为通配符
修饰符可以省略,所以第一个*表示返回值
包也可以用*代替,但是有多少个包就得有多少个*。例:com.liuqijun.spring.CustomerServerImp.save() <==> *.*.*.CustomerServerImp.save()
.. 表示当前包以及子包 com.liuqijun.spring.CustomerServerImp.save()可以写为com..CustomerServerImp.save() (表示com包下的所有子包中的CustomerServerImpl类中的save方法)或者*..CustomerServerImp.save() (任意包中的CustomerServerImp.save())
类名和函数名可以用*代替,com.liuqijun.spring.CustomerServerImp.save() <==> *..*.*()
参数列表:可以直接使用具体的类型,基本类型可以直接使用,引用类型 包名.类名
例: 基础类型 int
引用类型:java.lang.Integer
参数可以用*代替,但是切入点必须有参数才可以
参数也可以用..代替,表示有参无参都可以
-->
<aop:aspect id="loggerAspect" ref="logger">
<aop:before method="star" pointcut="execution(public void com.liuqijun.spring.CustomerServerImp.save())"/>
<aop:after method="stop" pointcut="execution(* *..*.*(..))"/>
</aop:aspect>
</aop:config>
168万+

被折叠的 条评论
为什么被折叠?



