基于API 的spring aop(自动代理)
BeanNameAutoProxyCreator通过匹配bean的id值来决定自动代理那些target。自动代理可以不用为每个目标对象制定advice。配置文件如下。
<?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: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 "><bean id="hello" value="s*n"></property><property name="advice"><ref local="logger" /></property></bean><bean id="regadvisor"value=".*Again"></property><property name="advice" ref="logger"></property></bean><bean id="proxyhello" name="code"><?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: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 "><bean id="hello" value="s*n"></property><property name="advice"><ref local="logger" /></property></bean><bean id="regadvisor"value=".*Again"></property><property name="advice" ref="logger"></property></bean><bean id="proxyhello" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"></bean></beans>