代理模式、静态代理、动态代理、aop
/>
??? <bean id="knightTarget"
?????? class="com.springinaction.chapter01.knight.KnightOfTheRoundTable">
?????? <constructor-arg>
?????????? <value>Bedivere</value>
?????? </constructor-arg>
?????? <property name="quest">
?????????? <ref bean="quest" />
?????? </property>
??? </bean>
??? <bean id="minstrel"
?????? class="com.springinaction.chapter01.knight.MinstrelAdvice" />
??? <bean id="knight"
?????? class="org.springframework.aop.framework.ProxyFactoryBean">
?????? <property name="proxyInterfaces">
?????????? <list>
????????????? <value>
????????????????? com.springinaction.chapter01.knight.Knight
????????????? </value>
????????????? <value>
????????????????? com.springinaction.chapter01.knight.Knight2
????????????? </value>??
?????????? </list>
?????? </property>
?????? <property name="interceptorNames">
?????????? <list>
????????????? <value>minstrel</value>
?????????? </list>
?????? </property>
?????? <property name="target">
?????????? <ref bean="knightTarget" />
?????? </property>
??? </bean>
</beans>
?????? BeanFactory factory = new XmlBeanFactory(new ClassPathResource(
????????????? "applicationContext.xml"));
?????? Knight knight = (Knight) factory.getBean("knight");
//knight就是一个动态代理对象!
knight.embarkOnQuest();
看到上面的配置文件,然后再看一下动态代理,你会发现spring 的aop就是基于动态代理模式来实现的