<?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 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 首先配置核心类 -->
<bean id="ibookBiz" class="com.springaop.biz.imp.IBookBiz"/>
<!-- 配置拦截切面 -->
<bean id="log" class="com.springaop.aspect.LogAspect"/>
<!-- 用spring里的代理工厂类来代理所要实现的接口(实现动态代理) -->
<bean id="bookBizProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<!-- 把要被代理的接口注入 -->
<property name="proxyInterfaces"><!-- 名字是固定的!! 是spring中代理工厂的属性-->
<value>
com.springaop.biz.inter.BookBiz
</value>
</property>
<!-- 把切面注入 (拦截)-->
<property name="interceptorNames"><!-- 名字是固定的!! 是spring中代理工厂的属性-->
<!-- 应为可能不止一个切面,所以用list装 -->
<list>
<value>log</value>
</list>
</property>
<!-- 指明被代理的实现类(核心类)(target) -->
<property name="target" ref="ibookBiz"></property>
</bean>
</beans>