首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

署理模式、静态代理、动态代理、aop

2012-10-31 
代理模式、静态代理、动态代理、aop/??? bean idknightTarget?????? classcom.springinaction.chapter

代理模式、静态代理、动态代理、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就是基于动态代理模式来实现的

热点排行