一、对于异常,只有抛出的才能被通知吗?要是捕捉了(用了try-catch)就不能了吗?
二、spring的aop支不支持嵌套?比如:methodA methodB, methodA调用methodB,我的配置文件对于这2个方法都会做通知,我分别调用的测试过,没问题的,但是如果我用methodA调用methodB,然后我的主程序只调用methodA ,那么就只能捕捉到methodA的通知,methodB就没有了,这是怎么回事?
这是我的配置文件,是不是有什么需要添加的?
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans> <!--CONFIG--> <bean id="bean" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>com.company.springaop.test.Bean</value> </property> <property name="target"> <ref local="beanTarget"/> </property> <property name="interceptorNames"> <list> <value>beforeAdvisor</value> <value>afterAdvisor</value> <value>nullPointerAdvisor</value> </list> </property> </bean>
<!--CLASS--> <bean id="beanTarget" class="com.company.springaop.test.BeanImpl"/>
<!--ADVISOR--> <!--Note: An advisor assembles pointcut and advice--> <bean id="beforeAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice"> <ref local="theBeforeAdvice"/> </property> <property name="patterns"> <value>.*Method*</value> </property> </bean>
<!--ADVICE--> <bean id="theBeforeAdvice" class="com.company.springaop.test.TestBeforeAdvice"/> <bean id="afterAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice"> <ref local="theAfterAdvice"/> </property> <property name="pattern"> <value>.*Method*</value> </property> </bean> <bean id="theAfterAdvice" class="com.company.springaop.test.TestAfterAdvice"/> <bean id="nullPointerAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice"> <ref local="theNullPointerAdvice"/> </property> <property name="pattern"> <value>.*Method*</value> </property> </bean> <bean id="theNullPointerAdvice" class="com.company.springaop.test.TestThrowAdvice"/> </beans>
|