题目一:
接口就不写了,看实现方法就能知道接口大概
1.SpeechImpl.java
2.ConcertImpl.java
前增强BeforeAvtice.java:
后增强AfterAtive.java:
环绕增强Around.java:
aspect_spring_aop.xml
Runtest.java
测试:
aspect_spring_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
测试:
题目三:
1.SpeechImpl.java:
2.Theatre.java:
3.Aspect_AOP.java
配置文件(Aspectj_2.xml):
RunTest.java:
测试:
题目四:
1.ConcertImpl.java:
2.Music.java:
3.Theatre.java:
4.Applicationioc.java
5.Runtest.java
测试: