I'm trying to configure Spring so that it executes advice when a specific exception subclass (MyTestException) is thrown:
And the XML config:Code:public class MyTestExceptionInterceptor implements ThrowsAdvice { public void afterThrowing(Method method, Object[] args, Object target, Exception exc) { // I want this to get executed every time a MyTestException is thrown, // regardless of the package/class/method that is throwing it. } }
I have a feeling that I should be using the target pointcut specifier (instead of "execution") since - according to the Spring docs (Ch 6) - it seems as though target allows me to specify the type of exception to match against, but I'm not sure if that's wrong, or what my "pointcut" attribute needs to look like.Code:<bean name="interceptor" class="org.me.myproject.MyTestExceptionInterceptor"/> <aop:config> <aop:advisor advice-ref="interceptor" pointcut="execution(???)"/> </aop:config>
I would greatly prefer to keep the AOP config done in XML (as opposed to Java/annotations, but I could probably translate an annotation-based solution into XML if need be.
Thanks in advance for any suggestions!


Reply With Quote
