トピック1:
インターフェースは書かれておらず、実装方法を見ればインターフェースがわかります。
1.SpeechImpl.java
2.ConcertImpl.java
BeforeAvtice.javaを拡張する前に:
AfterAtive.javaを拡張した後:
サラウンドの機能強化Around.java:
アスペクト_スプリング_aop.xml
Runtest.java
テスト:
アスペクト_スプリング_aop.xmlコード:
<?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.xsd">
<!--实现类-->
<bean id="speech_impl_bean" class="cn.spring.aop_xml.SpeechImpl"/>
<bean id="concert_impl_bean" class="cn.spring.aop_xml.ConcertImpl"/>
<!--切面-->
<bean id="before_bean" class="cn.spring.aop_xml.BeforeAvtice"/>
<bean id="after_bean" class="cn.spring.aop_xml.AfterRAtive"/>
<bean id="wrap_bean" class="cn.spring.aop_xml.Around"/>
<!-- 配置前增强的方法 -->
<bean name="takeSpeak_advice" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<!-- 注入advice -->
<property name="advice" ref="before_bean"/>
<!-- 注入需要被拦截的目标对象中的方法(连接点) -->
<property name="patterns">
<list>
<value>.*takeSpeak</value>
</list>
</property>
</bean>
<!-- 配置后增强的方法 -->
<bean name="printText_advice" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<!-- 注入advice -->
<property name="advice" ref="after_bean"/>
<!-- 注入需要被拦截的目标对象中的方法(连接点) -->
<property name="patterns">
<list>
<value>.*printText</value>
</list>
</property>
</bean>
<bean id="spring_Speech_proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<!--Speech接口增强-->
<property name="proxyInterfaces">
<value>cn.spring.aop_xml.Speech</value>
</property>
<property name="target" ref="speech_impl_bean"/>
<property name="interceptorNames">
<list>
<value>takeSpeak_advice</value>
<value>printText_advice</value>
</list>
</property>
</bean>
<bean id="spring_Concert_proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<!--Concert接口增强-->
<property name="proxyInterfaces">
<value>cn.spring.aop_xml.Concert</value>
</property>
<property name="target" ref="concert_impl_bean"/>
<property name="interceptorNames">
<list>
<value>wrap_bean</value>
</list>
</property>
</bean>
</beans>
トピック2:
1. LookQインターフェース:
2. LookQImpl実装クラス:
3.Userlevel_Aspectアスペクトクラス
4.構成ファイルAspectj_1.xml
5. RunTest.java
テスト:
トピック3:
1.SpeechImpl.java:
2.Theatre.java:
3.Aspect_AOP.java
構成ファイル(Aspectj_2.xml):
RunTest.java:
テスト:
トピック4:
1.ConcertImpl.java:
2.Music.java:
3.Theatre.java:
4.Applicationioc.java
5.Runtest.java
テスト: