一:基于XML配置
<!--目标对象 -->
<bean id="AOPservice" class="com.study.spring.service.impl.AOPServiceImpl"/>
<!-- advice通知 -->
<bean id="adviceMessage" class="com.study.spring.aop.advice.Advicer"/>
<bean id="perfAdvice" class="com.study.spring.aop.advice.PerfAdvicer"/>
<!-- 切入点adviser -->
<bean id="adviser" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice" ref="adviceMessage"/>
<property name="pattern" value="com.study.spring.service.impl.AOPServiceImpl.print"></property>
</bean>
<bean id="perfAdviser" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice" ref="perfAdvice"/>
<property name="pattern" value="com.study.spring.service.impl.AOPServiceImpl.*(..)"></property>
</bean>
<!-- 代理对象 返回实例是目标对象 target属性指定的AOPservice对象-->
<bean id="proxyService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref bean="AOPservice"/>
</property>
<!--源码内固定的属性private String[] interceptorNames; -->
<property name="interceptorNames">
<list>
<value>adviser</value>
<value>perfAdviser</value>
</list>
</property>
</bean>
二:基于XML配置
<bean id="perfAdviser" class="com.study.spring.aop.advice.PerfAdvicer2" />
<aop:config proxy-target-class="true">
<aop:aspect ref="perfAdviser">
<aop:pointcut id="methodPoint" expression="execution(* com.study.spring.service.impl.AOPServiceImpl.*(..)) "/>
<!--在该切入点使用自定义拦截器-->
<aop:before pointcut-ref="methodPoint" method="before"/>
<aop:around pointcut-ref="methodPoint" method="around"/>
<aop:after pointcut-ref="methodPoint" method="after"/>
<aop:after-returning pointcut-ref="methodPoint" method="afterRet"/>
<aop:after-throwing pointcut-ref="methodPoint" method="afterError"/>
</aop:aspect>
</aop:config>
三:基于注解配置
<bean id="AOPservice" class="com.study.spring.service.impl.AOPServiceImpl"/>
<bean id="perfAdvice" class="com.study.spring.aop.advice.PerfAdvicer3"/>
<aop:aspectj-autoproxy proxy-target-class="true"/>