|
@@ -0,0 +1,50 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
|
+ https://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
|
+
|
|
|
+ <!-- 注册被监控的实现类 -->
|
|
|
+ <bean id="person" class="com.sf.aop.Person"></bean>
|
|
|
+
|
|
|
+ <!-- 注册通知实现类 -->
|
|
|
+ <bean id="before" class="com.sf.aop.MyBeforeAdvice"></bean>
|
|
|
+ <bean id="after" class="com.sf.aop.MyAfterAdvice"></bean>
|
|
|
+
|
|
|
+ <!-- 注册类型过滤器 -->
|
|
|
+ <bean id="classFilter" class="com.sf.aop.advisor.MyClassFilter"></bean>
|
|
|
+ <!-- 注册方法匹配器 -->
|
|
|
+ <bean id="eatMethodMatcher" class="com.sf.aop.advisor.EatMethodMatcher"></bean>
|
|
|
+ <bean id="wcMethodMatcher" class="com.sf.aop.advisor.WcMethodMatcher"></bean>
|
|
|
+
|
|
|
+ <!-- 注册切入点 -->
|
|
|
+ <bean id="eatPointcut" class="com.sf.aop.advisor.MyPointCut">
|
|
|
+ <property name="classFilter" ref="classFilter"></property>
|
|
|
+ <property name="methodMatcher" ref="eatMethodMatcher"></property>
|
|
|
+ </bean>
|
|
|
+ <bean id="wcPointcut" class="com.sf.aop.advisor.MyPointCut">
|
|
|
+ <property name="classFilter" ref="classFilter"></property>
|
|
|
+ <property name="methodMatcher" ref="wcMethodMatcher"></property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+ <!-- 注册顾问 -->
|
|
|
+ <bean id="eatAdvisor" class="com.sf.aop.advisor.MyPointCutAdvisor">
|
|
|
+ <property name="advice" ref="before"></property>
|
|
|
+ <property name="pointcut" ref="eatPointcut"></property>
|
|
|
+ </bean>
|
|
|
+ <bean id="wcAdvisor" class="com.sf.aop.advisor.MyPointCutAdvisor">
|
|
|
+ <property name="advice" ref="after"></property>
|
|
|
+ <property name="pointcut" ref="wcPointcut"></property>
|
|
|
+ </bean>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 注册代理对象工厂 -->
|
|
|
+ <!--
|
|
|
+ 此时生成的代理对象,只会负责 Person.eat() 方法进行监控,
|
|
|
+ 与 Advice 不同,不会对 BaseService 所有的方法进行监控
|
|
|
+ -->
|
|
|
+ <bean id="personProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
|
|
|
+ <property name="target" ref="person"></property>
|
|
|
+ <property name="interceptorNames" value="eatAdvisor,wcAdvisor"></property>
|
|
|
+ </bean>
|
|
|
+</beans>
|