<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
/*
helloBEAN有一个str属性类型为String 它继承一个Pr的接口 实现方法print();
打印出str
*/
<bean id="hello" class="com.spring.bean.Hello">
<property name="str">
<value>wangzhenjia</value>
</property>
</bean>
/*
Advice ---处理逻辑 (通知) 可以是MethodBeforeAdvice ,AfterReturningAdvice,IntroductionInterceptor
里面之一种的实现 这将会在hello.print()方法时候根据具体的实现被调用
*/
<bean id="beforAdvice" class="com.spring.bean.BeforBean"></bean>
/*
切入点 advice指向处理逻辑 pattern指出当什么条件下触发advice
当然当有多个条件时候可以用patterns 它是个List
*/
<bean id="berforAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref local="beforAdvice"/>
</property>
<property name="pattern">
<value>com\.spring\.bean\.Pr\.print</value>
</property>
</bean>
/*
用ProxyFactoryBean创建AOP代理
proxyInterfaces 指定实现的接口
target目标
interceptorNames可以指定Advisor
或者interceptor MethodBeforeAdvice ,AfterReturningAdvice, IntroductionInterceptor 都可以
*/
<bean id="myproxyBean" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.spring.bean.Pr</value>
</property>
<property name="target">
<ref local="hello"/>
</property>
<property name="interceptorNames">
<list>
<value>berforAdvisor</value>
</list>
</property>
</bean>
</beans>