题目一:
![](https://img-blog.csdnimg.cn/a8c7109c4f1647dda9038c3c64abb03d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55qu54yq,size_20,color_FFFFFF,t_70,g_se,x_16)
接口就不写了,看实现方法就能知道接口大概
1.SpeechImpl.java
![](https://img-blog.csdnimg.cn/img_convert/5ea9ff6ffb60f2d866d3718b9458a412.png)
2.ConcertImpl.java
![](https://img-blog.csdnimg.cn/img_convert/3e88546af837c114263db5e6cddbc393.png)
前增强BeforeAvtice.java:
![](https://img-blog.csdnimg.cn/img_convert/f7270543faf5170473492c885cd77cd6.png)
后增强AfterAtive.java:
![](https://img-blog.csdnimg.cn/img_convert/731abbd45ab5aa832aeb84e62b444b7a.png)
环绕增强Around.java:
![](https://img-blog.csdnimg.cn/img_convert/dcf529b924eb3cc5106cbabb4a1b9604.png)
aspect_spring_aop.xml
![](https://img-blog.csdnimg.cn/img_convert/a5f232f81c237a8421283d5612c5659d.png)
Runtest.java
![](https://img-blog.csdnimg.cn/img_convert/3af700814f4af25dd740af568f30de92.png)
测试:
![](https://img-blog.csdnimg.cn/img_convert/7428dfe24e9370d2d842642d9166a524.png)
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:
![](https://img-blog.csdnimg.cn/fe01d519b4b540efa9711c2f88afab1d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55qu54yq,size_20,color_FFFFFF,t_70,g_se,x_16)
1.LookQ接口:
![](https://img-blog.csdnimg.cn/img_convert/5cd07fb286ecc6ad9873c885835a45af.png)
2. LookQImpl实现类:
![](https://img-blog.csdnimg.cn/img_convert/d9c6bfe6edd8fefeb67256f90e5cdf1a.png)
3.Userlevel_Aspect切面类
![](https://img-blog.csdnimg.cn/img_convert/b221459c7c620cc14eb8a895aa28b734.png)
4. 配置文件Aspectj_1.xml
![](https://img-blog.csdnimg.cn/img_convert/83da2728739b3bd8e8a2f288cf463661.png)
5. RunTest.java
![](https://img-blog.csdnimg.cn/img_convert/e349a5025e64205bf2ec74fba466d2be.png)
测试:
![](https://img-blog.csdnimg.cn/img_convert/c439f0110528909e3749fb7409ad2410.png)
题目三:
![](https://img-blog.csdnimg.cn/d6cd0da3f6254a32ada6deae46b109db.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55qu54yq,size_20,color_FFFFFF,t_70,g_se,x_16)
1.SpeechImpl.java:
![](https://img-blog.csdnimg.cn/img_convert/c2b510a776f2049d1d67368f1fa12060.png)
2.Theatre.java:
![](https://img-blog.csdnimg.cn/img_convert/7531bea7f6d5367716a0b3efe82bbb4b.png)
3.Aspect_AOP.java
![](https://img-blog.csdnimg.cn/img_convert/8dac818b4a2044795c971d120b25dbe8.png)
配置文件(Aspectj_2.xml):
![](https://img-blog.csdnimg.cn/img_convert/3fd266cca69520da0566948c24d2f77b.png)
RunTest.java:
![](https://img-blog.csdnimg.cn/img_convert/404bb4579fb829157b6ecf0387be9cfd.png)
测试:
![](https://img-blog.csdnimg.cn/img_convert/add6c3b63626ea83bbf20e7ff7849792.png)
题目四:
![](https://img-blog.csdnimg.cn/442b6de8295545fcb32bd01932822ed8.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5bCP55qu54yq,size_20,color_FFFFFF,t_70,g_se,x_16)
1.ConcertImpl.java:
![](https://img-blog.csdnimg.cn/img_convert/f70f7c04c86a316961ba86e7525b15c3.png)
2.Music.java:
![](https://img-blog.csdnimg.cn/img_convert/b28fd1cd0ddc22a0690100d3d2f7988f.png)
3.Theatre.java:
![](https://img-blog.csdnimg.cn/img_convert/d33786b1058cee6464303822b8fe9284.png)
4.Applicationioc.java
![](https://img-blog.csdnimg.cn/img_convert/9f6c3d5d5c6ffbc53b5747c9bc2118d0.png)
5.Runtest.java
![](https://img-blog.csdnimg.cn/img_convert/fadd68d819e9492077204814e76fa05b.png)
测试:
![](https://img-blog.csdnimg.cn/img_convert/767184db53afd3f7169ada36e22a7293.png)